Authored by min.ling

商家管理优化需求

package com.yoho.ufo.constants;
/**
* 商家类型
* Created by min.ling on 2019/4/23.
*/
public enum SellerTypeEnum {
COMMONENTER(1,"入驻卖家"),
SUPERENTER(2,"超级入驻"),
WHITE(3,"前期白名单"),
COMMON(4,"普通卖家");
private Integer code;
private String desc;
SellerTypeEnum(Integer code,String desc){
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
... ...
package com.yoho.order.dal;
import com.yoho.order.model.SellerReqBO;
import com.yoho.order.model.ZhimaCert;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ZhimaCertMapper {
ZhimaCert selectByPrimaryKey(Integer id);
int selectCountByCondition(@Param("sellerReqBO") SellerReqBO req);
List<ZhimaCert> selectByConditionPage(@Param("sellerReqBO") SellerReqBO req);
}
\ No newline at end of file
... ...
package com.yoho.order.model;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
/**
* 商家管理列表页请求
* Created by min.ling on 2019/4/23.
*/
@Data
@ToString
@Builder
public class SellerReqBO {
private Integer uid;
private String mobile;
//商家证件名称
private String certName;
// status 入驻状态
private Integer validStatus;
//商家类型 1:普通入驻,2:超级,3:前期白名单,4:普通卖家
private Integer sellerType;
}
... ...
package com.yoho.order.model;
public class ZhimaCert {
private Integer id;
private Integer uid;
private Integer validStatus;
private String certName;
private String certNo;
private String bizNo;
private Integer createTime;
private Integer updateTime;
private Byte validPhoto;
private String imageUrl;
private String investName;
private Integer entryType;
private Integer enterTime;
private Integer quitTime;
private Integer sCreateTime;
private Integer sValidStatus;
public Integer getsValidStatus() {
return sValidStatus;
}
public void setsValidStatus(Integer sValidStatus) {
this.sValidStatus = sValidStatus;
}
public Integer getEnterTime() {
return enterTime;
}
public void setEnterTime(Integer enterTime) {
this.enterTime = enterTime;
}
public Integer getQuitTime() {
return quitTime;
}
public void setQuitTime(Integer quitTime) {
this.quitTime = quitTime;
}
public Integer getsCreateTime() {
return sCreateTime;
}
public void setsCreateTime(Integer sCreateTime) {
this.sCreateTime = sCreateTime;
}
public Integer getEntryType() {
return entryType;
}
public void setEntryType(Integer entryType) {
this.entryType = entryType;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Integer getValidStatus() {
return validStatus;
}
public void setValidStatus(Integer validStatus) {
this.validStatus = validStatus;
}
public String getCertName() {
return certName;
}
public void setCertName(String certName) {
this.certName = certName == null ? null : certName.trim();
}
public String getCertNo() {
return certNo;
}
public void setCertNo(String certNo) {
this.certNo = certNo == null ? null : certNo.trim();
}
public String getBizNo() {
return bizNo;
}
public void setBizNo(String bizNo) {
this.bizNo = bizNo == null ? null : bizNo.trim();
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public Byte getValidPhoto() {
return validPhoto;
}
public void setValidPhoto(Byte validPhoto) {
this.validPhoto = validPhoto;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl == null ? null : imageUrl.trim();
}
public String getInvestName() {
return investName;
}
public void setInvestName(String investName) {
this.investName = investName == null ? null : investName.trim();
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.order.dal.ZhimaCertMapper" >
<resultMap id="BaseResultMap" type="com.yoho.order.model.ZhimaCert" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="valid_status" property="validStatus" jdbcType="TINYINT" />
<result column="cert_name" property="certName" jdbcType="VARCHAR" />
<result column="cert_no" property="certNo" jdbcType="VARCHAR" />
<result column="biz_no" property="bizNo" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="valid_photo" property="validPhoto" jdbcType="TINYINT" />
<result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
<result column="invest_name" property="investName" jdbcType="VARCHAR" />
<result column="entry_type" property="entryType" jdbcType="INTEGER" />
<result column="enter_time" property="enterTime" jdbcType="INTEGER" />
<result column="quit_time" property="quitTime" jdbcType="INTEGER" />
<result column="s_create_time" property="sCreateTime" jdbcType="INTEGER" />
<result column="s_valid_status" property="sValidStatus" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, valid_status, cert_name, cert_no, biz_no, create_time, update_time, valid_photo,
image_url, invest_name
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from zhima_cert
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectCountByCondition" resultType="java.lang.Integer" >
select count(1)
from zhima_cert z left join ufo_order.stored_seller s
on z.uid = s.uid
where z.valid_status = 1
<include refid="Query_Condition_Sql" />
</select>
<select id="selectByConditionPage" resultMap="BaseResultMap">
select z.uid,z.cert_name,s.entry_type,z.cert_no,z.image_url,z.invest_name,s.enter_time,s.quit_time,s.create_time s_create_time,
s.valid_status s_valid_status
from zhima_cert z left join ufo_order.stored_seller s
on z.uid = s.uid
where z.valid_status = 1
<include refid="Query_Condition_Sql" />
</select>
<sql id="Query_Condition_Sql" >
<if test="sellerReqBO.uid != null">
and z.uid = #{sellerReqBO.uid}
</if>
<if test="sellerReqBO.certName != null">
and z.cert_name = #{sellerReqBO.certName}
</if>
<if test="sellerReqBO.validStatus != null and sellerReqBO.validStatus != 0">
and s.valid_status = #{sellerReqBO.validStatus}
</if>
<if test="sellerReqBO.sellerType != null and sellerReqBO.sellerType != 0 and sellerReqBO.sellerType != 4">
and s.entry_type = #{sellerReqBO.sellerType}
</if>
<if test="sellerReqBO.sellerType != null and sellerReqBO.sellerType == 4">
and (s.entry_type = null or s.entry_type = '')
</if>
</sql>
</mapper>
\ No newline at end of file
... ...
... ... @@ -43,4 +43,16 @@ public class StoredSellerRespVo {
//账户总金额
private String money;
//1-普通卖家 2-入驻卖家 3-超级入驻卖家
private Integer sellerType;
//招商人员姓名
private String investName;
//身份证正面照片url
private String idCardFrontUrl;
//身份证背面照片url
private String idCardBackUrl;
}
... ...
... ... @@ -6,16 +6,9 @@ import com.google.common.cache.CacheBuilder;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.SellerOrderGoodsMapper;
import com.yoho.order.dal.SellerWalletDetailMapper;
import com.yoho.order.dal.SellerWalletMapper;
import com.yoho.order.dal.StoredSellerMapper;
import com.yoho.order.dal.TradeBillsMapper;
import com.yoho.order.model.SellerWallet;
import com.yoho.order.model.StoredSeller;
import com.yoho.order.model.StoredSellerReqVo;
import com.yoho.order.model.TradeBills;
import com.yoho.order.model.TradeBillsReq;
import com.yoho.order.dal.*;
import com.yoho.order.model.*;
import com.yoho.ufo.constants.SellerTypeEnum;
import com.yoho.ufo.order.constant.MoneyTypeEnum;
import com.yoho.ufo.order.constant.TradeStatusEnum;
import com.yoho.ufo.order.response.StoredSellerRespVo;
... ... @@ -38,6 +31,7 @@ import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
... ... @@ -77,6 +71,9 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private ZhimaCertMapper zhimaCertMapper;
@Override
public PageResponseBO<StoredSellerRespVo> queryStoredSeller(StoredSellerReqVo req){
if(req.getUid()==null&&StringUtils.isNotBlank(req.getMobile())){
... ... @@ -86,17 +83,26 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
}
}
int total = storedSellerMapper.selectCountByCondition(req);
//int total = storedSellerMapper.selectCountByCondition(req);
SellerReqBO sellerReqBO = SellerReqBO.builder().sellerType(req.getEntryType())
.certName(req.getCertName())
.mobile(req.getMobile())
.uid(req.getUid())
.validStatus(req.getValidStatus()).build();
int total = zhimaCertMapper.selectCountByCondition(sellerReqBO);
if(total == 0) {
LOGGER.warn("queryStoredSeller with total is 0, req is {}",req);
return null;
}
List<StoredSeller> storedSellerList = storedSellerMapper.selectByConditionWithPage(req);
if(CollectionUtils.isEmpty(storedSellerList)) {
//List<StoredSeller> storedSellerList = storedSellerMapper.selectByConditionWithPage(req);
List<ZhimaCert> zhimaCertList = zhimaCertMapper.selectByConditionPage(sellerReqBO);
if(CollectionUtils.isEmpty(zhimaCertList)) {
return null;
}
List<StoredSellerRespVo> respList = convertToStoreSellerResp(storedSellerList);
List<StoredSellerRespVo> respList = convertToStoreSellerResp(zhimaCertList);
PageResponseBO<StoredSellerRespVo> result=new PageResponseBO<>();
result.setList(respList);
... ... @@ -109,43 +115,66 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
}
private List<StoredSellerRespVo> convertToStoreSellerResp(List<StoredSeller> ls ){
private List<StoredSellerRespVo> convertToStoreSellerResp(List<ZhimaCert> ls ){
List<StoredSellerRespVo> respList = Lists.newArrayList();
List<SellerWallet> sws = sellerWalletMapper.selectByUidAndMerchantUids(null, CollectionUtil.distinct(ls,StoredSeller::getUid), 0, ls.size());
List<SellerWallet> sws = sellerWalletMapper.selectByUidAndMerchantUids(null, CollectionUtil.distinct(ls,ZhimaCert::getUid), 0, ls.size());
Map<Integer, SellerWallet> swsMap = CollectionUtil.extractMap(sws, SellerWallet::getUid);
for(StoredSeller item : ls) {
StoredSellerRespVo resp=new StoredSellerRespVo();
for(ZhimaCert item : ls) {
StoredSellerRespVo resp = new StoredSellerRespVo();
resp.setUid(item.getUid());
resp.setCertName(item.getCertName());
resp.setCertNo(KeyWordHiddenUtil.hiddenKeyWord(item.getCertNo(), 2, 2));
resp.setValidStatus(item.getValidStatus());
resp.setValidStatusDesc(StoredSellerStatusEnum.getDescriptionByCode(item.getValidStatus()));
resp.setMobile(getMobileByUidFromCache(item.getUid()));
// 之前fore项目有bug,导致enterTime被更新成0了,如果为0,则去createTime作为入驻时间
if(item.getEnterTime()==0){
resp.setEnterTime(1000L * item.getCreateTime());
}else {
resp.setEnterTime(1000L * item.getEnterTime());
}
resp.setQuitTime(1000L * item.getQuitTime());
// 身份等级
resp.setEntryType(item.getEntryType());
resp.setEntryType(item.getEntryType() == null ? SellerTypeEnum.COMMON.getCode() : item.getEntryType());
//卖家类型
resp.setSellerType(item.getEntryType() == null ? SellerTypeEnum.COMMON.getCode() : item.getEntryType());
//处理入驻商家的一些数据
setEnterInfo(item,resp,swsMap);
resp.setValidStatusDesc(Objects.equals(resp.getEntryType(), SellerTypeEnum.COMMON.getCode()) ? "未入驻" :StoredSellerStatusEnum.getDescriptionByCode(item.getsValidStatus()));
// 上架skuP
resp.setSelfSkuNum(sellerOrderGoodsMapper.selectCountCanCell(item.getUid()));
// 违约次数
resp.setBreakRuleTimes(sellerWalletDetailMapper.selectUserBreakRulesCount(item.getUid()));
// 总余额
SellerWallet sw = swsMap.get(item.getUid());
if (sw != null) {
resp.setMoney(sw.getLockAmount().add(sw.getAmount()).setScale(2).toString());
} else {
resp.setMoney("");
//身份证图片
if(StringUtils.isNotEmpty(item.getImageUrl())){
String[] imgArray = item.getImageUrl().split(",");
resp.setIdCardFrontUrl(imgArray[0]);
resp.setIdCardFrontUrl(imgArray.length > 1 ? imgArray[1] : "");
}
//招商人
resp.setInvestName(item.getInvestName());
respList.add(resp);
}
return respList;
}
public void setEnterInfo(ZhimaCert item,StoredSellerRespVo resp,Map<Integer, SellerWallet> swsMap){
if(Objects.equals(resp.getSellerType(), SellerTypeEnum.COMMON.getCode())){
return;
}
//入驻状态
resp.setValidStatus(item.getsValidStatus());
// 之前fore项目有bug,导致enterTime被更新成0了,如果为0,则去createTime作为入驻时间
if(item.getEnterTime()==0){
resp.setEnterTime(1000L * item.getsCreateTime());
}else {
resp.setEnterTime(1000L * item.getEnterTime());
}
resp.setQuitTime(1000L * item.getQuitTime());
// 总余额
SellerWallet sw = swsMap.get(item.getUid());
if (sw != null) {
resp.setMoney(sw.getLockAmount().add(sw.getAmount()).setScale(2).toString());
} else {
resp.setMoney("");
}
}
public PageResponseBO<TradeBillsResp> queryTradeBillsList(TradeBillsReq req) {
if(req.getMoneyType()!=null){
MoneyTypeEnum moneyTypeClass =MoneyTypeEnum.getMoneyTypeByCode(req.getMoneyType());
... ...
... ... @@ -86,4 +86,15 @@ datasources:
- com.yoho.ufo.dal.CouponProductLimitMapper
- com.yoho.ufo.dal.CouponTypeMapper
- com.yoho.ufo.dal.UserCouponMapper
ufo_passport:
servers:
- 192.168.102.219:3306
- 192.168.102.219:3306
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
maxTotal: 100
daos:
- com.yoho.order.dal.ZhimaCertMapper
readOnlyInSlave: true
... ...
... ... @@ -86,4 +86,15 @@ datasources:
- com.yoho.ufo.dal.CouponProductLimitMapper
- com.yoho.ufo.dal.CouponTypeMapper
- com.yoho.ufo.dal.UserCouponMapper
ufo_passport:
servers:
- ${jdbc.mysql.ufo.master}
- ${jdbc.mysql.ufo.slave}
username: ${jdbc.mysql.ufo.username}
password: ${jdbc.mysql.ufo.password}
maxTotal: 100
daos:
- com.yoho.order.dal.ZhimaCertMapper
readOnlyInSlave: ${readOnlyInSlave}
... ...