Authored by Lixiaodi

Merge branch 'test6.8.5' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.5

Showing 30 changed files with 690 additions and 346 deletions
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.OrderOperateRecord;
/**
* Created by caoyan on 2018/9/12.
*/
public interface OrderOperateRecordMapper {
int insert(OrderOperateRecord orderOperateRecord);
}
... ...
package com.yohoufo.dal.order.model;
import lombok.ToString;
@ToString
public class MetaConfig {
private Integer id;
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
import lombok.ToString;
/**
* @author caoyan
* @date 2018/9/13
*/
@Data
@ToString
public class OrderOperateRecord {
private Integer id;
private String orderCode;
private Integer type;
private Integer uid;
private String userName;
private String oldInfo;
private Integer updateTime;
}
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
@Data
public class SellerEnterApply {
private Integer id;
... ... @@ -17,67 +20,4 @@ public class SellerEnterApply {
private Short status;
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 Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public Integer getPreEnterType() {
return preEnterType;
}
public void setPreEnterType(Integer preEnterType) {
this.preEnterType = preEnterType;
}
public Integer getEnterType() {
return enterType;
}
public void setEnterType(Integer enterType) {
this.enterType = enterType;
}
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 Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
@Data
public class SellerFunc {
private Integer id;
... ... @@ -9,35 +12,4 @@ public class SellerFunc {
private Integer code;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCnName() {
return cnName;
}
public void setCnName(String cnName) {
this.cnName = cnName == null ? null : cnName.trim();
}
public String getEnName() {
return enName;
}
public void setEnName(String enName) {
this.enName = enName == null ? null : enName.trim();
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
@Data
public class SellerLevelFunc {
private Integer id;
... ... @@ -9,35 +12,4 @@ public class SellerLevelFunc {
private String funcList;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getEnterType() {
return enterType;
}
public void setEnterType(Integer enterType) {
this.enterType = enterType;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getFuncList() {
return funcList;
}
public void setFuncList(String funcList) {
this.funcList = funcList == null ? null : funcList.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.yohoufo.dal.order.OrderOperateRecordMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.OrderOperateRecord">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="user_name" property="userName" jdbcType="VARCHAR" />
<result column="old_info" property="oldInfo" jdbcType="VARCHAR" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id, order_code, uid, type, user_name, old_info, update_time
</sql>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.OrderOperateRecord">
insert into order_operate_record(order_code, uid, type, user_name, old_info, update_time)
values (#{orderCode}, #{uid}, #{type}, #{userName}, #{oldInfo}, #{updateTime})
</insert>
</mapper>
\ No newline at end of file
... ...
... ... @@ -111,7 +111,7 @@ public class PaymentController {
* 退款结果确认
* @return
*/
@RequestMapping(params = "/erp/order/refund")
@RequestMapping(value = "/erp/order/refund")
public ApiResponse refund(@RequestParam(name = "orderCode") long orderCode,
@RequestParam(name = "refundAmount") double refundAmount){
... ...
... ... @@ -367,7 +367,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
logger.warn("getWalletLeftAmount SellerWallet cannot use uid {}", uid);
return defaultLeft;
}
return sw.getAmount().add(sw.getLockAmount());
BigDecimal left = sw.getAmount().add(sw.getLockAmount());
logger.info("in getWalletLeftAmount uid {} left {}", uid, left);
return left;
}
public com.yohoufo.common.ApiResponse getMerchantWalletInfo(Integer uid) {
... ...
... ... @@ -56,7 +56,16 @@ public class CacheKeyBuilder {
BUYER_ORDER_NUMS("ufo:order:buyer:orderNums:", "uid:{}"),
BUYER_CANCEL_PENALTY("ufo:order:buyer:cancel:penalty:config", "");
BUYER_CANCEL_PENALTY("ufo:order:buyer:cancel:penalty:config", ""),
ENTRY_THRESHOLD("ufo:order:seller:entry:threshold", ""),
SELLER_BASE_FUNC_CONFIG("ufo:order:seller:base:func:Config", ""),
SELLER_LEVEL_FUNC_CONFIG("ufo:order:seller:stageLevel:func:Config", "");
private String fix;
private String placeHolder;
... ... @@ -130,4 +139,17 @@ public class CacheKeyBuilder {
public static RedisKeyBuilder buyerCancelPenaltyConfigKey(){
return KeyTemp.BUYER_CANCEL_PENALTY.builderKeyOnlyFixed();
}
public static RedisKeyBuilder entryThresholdConfigKey(){
return KeyTemp.ENTRY_THRESHOLD.builderKeyOnlyFixed();
}
public static RedisKeyBuilder sellerBaseFuncConfigKey(){
return KeyTemp.SELLER_BASE_FUNC_CONFIG.builderKeyOnlyFixed();
}
public static RedisKeyBuilder sellerFuncLevelConfigKey(){
return KeyTemp.SELLER_LEVEL_FUNC_CONFIG.builderKeyOnlyFixed();
}
}
... ...
... ... @@ -29,6 +29,7 @@ import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderOperateRecordService;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.utils.PaymentHelper;
import com.yohoufo.order.utils.PubThreadFactory;
... ... @@ -99,6 +100,12 @@ public class AppraiseService {
@Autowired
private ExpressRecordMapper expressRecordMapper;
@Autowired
private QualityCheckMapper qualityCheckMapper;
@Autowired
private OrderOperateRecordService orderOperateRecordService;
public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
... ... @@ -292,81 +299,10 @@ public class AppraiseService {
}
}
/*
* 发货
* (1)更新订单状态
* (2)记录物流
* (3)消息
*/
/*public void deliverGoods(AppraiseExpressInfoBo appraiseExpressInfoBo){
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
Long orderCode=appraiseExpressInfoBo.getOrderCode();
String wayBillCode=appraiseExpressInfoBo.getWayBillCode();
Integer depotNum=appraiseExpressInfoBo.getDepotNum();
String mobile=appraiseExpressInfoBo.getMobile();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("deliverGoods getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
OrderStatus expectStatus = OrderStatus.JUDGE_PASS;
final OrderStatus targetStatus = OrderStatus.WAITING_RECEIVE;
if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("deliverGoods expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
//更新状态为 (待收货[买家])
int buyerUid = buyerOrder.getUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectStatus.getCode(), targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("deliverGoods updateBuyerCnt {} ,expectStatus {}, actual status {}, orderCode {}", updateBuyerCnt ,expectStatus,
buyerOrder.getStatus(), orderCode);
if(updateBuyerCnt==1){
int sellerUid = buyerOrder.getSellerUid();
//记录物流信息
expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//平台已发货给买家 TODO
//inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
//记录订单的状态变更信息
LOGGER.info("in deliverGoods record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
//清理
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
EventBusPublisher.publishEvent(event);
}else{
LOGGER.warn("in deliverGoods update buyer count fail ,expectStatus {}, actual status {}, orderCode {}", updateBuyerCnt ,expectStatus,
buyerOrder.getStatus(), orderCode);
throw new UfoServiceException(400,"更新订单状态失败");
}
}*/
/**
* 鉴定不通过退回
* (1)记录物流
* (2)消息
* (2)消息 :寄回有三种情形: 质检不通过的而商品、瑕疵不接受的 、瑕疵不接受(超时)的
*/
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
... ... @@ -393,8 +329,27 @@ public class AppraiseService {
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//发消息给卖家 TODO
//inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid,wayBillCode);
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
//发消息给卖家
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode,wayBillCode);
}
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode,int uid,int sellerUid){
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
LOGGER.info("in appraise service cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(uid)));
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid);
EventBusPublisher.publishEvent(event);
return sellerOrderGoods;
}
/**
... ... @@ -426,6 +381,10 @@ public class AppraiseService {
//发送消息
inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid,wayBillCode);
//清缓存
cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
return apiResponse;
}
... ... @@ -563,48 +522,81 @@ public class AppraiseService {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//TODO 消息
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
if(type == 1){
//鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}else if(type==2 ){
//质检不通过
inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}else if(type==3 || type == 4){
//瑕疵不接受(用户不接受和超时不接受),只给买家发消息
boolean outTime=false;
if(type == 4){
outTime=true;
}
inBoxFacade.buyerMiniFaultUnAccept(buyerUid,buyerOrder.getOrderCode(), sellerOrderGoods.getProductName(),outTime);
}
}catch(Exception ex) {
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
}finally {
//更新物流信息,写到最后
//鉴定不通过,发物流
if(type == 1){
//补:鉴定不通过
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//发货物流(平台已发货)
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
}else if(type == 2){
//质检不通过,不发物流
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//再加一个鉴定不通过的物流
operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
}else if(type == 3||type == 4){
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
}
/// 物流信息异步执行
executorService.execute(()->{
//更新物流信息,写到最后
//鉴定不通过,发物流
if(type == 1){
//补:鉴定不通过
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//发货物流(平台已发货)
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
}else if(type == 2){
//质检不通过,不发物流
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//再加一个鉴定不通过的物流
operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
}else if(type == 3||type == 4){
//记录操作记录
if(type == 3){
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode,EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by buyer orderCode {} ,update quality check record status num {} ", orderCode,updateNum);
orderOperateRecordService.addRecord(orderCode,"买家操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT);
}else{
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode,EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by auto orderCode {} ,update quality check record status num {} ", orderCode,updateNum);
orderOperateRecordService.addRecord(orderCode,"系统操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT_BY_OUT_TIME);
}
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
}
});
}
}else{
... ...
... ... @@ -44,6 +44,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderOperateRecordService;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -113,6 +114,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
private AppraiseService appraiseService;
@Autowired
private OrderOperateRecordService orderOperateRecordService;
@Autowired
private TransferService transferService;
@Autowired
... ... @@ -351,7 +355,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_accept;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
//记录操作记录
orderOperateRecordService.addRecord(orderCode,"买家操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS);
//TODO 发消息
}else{
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
... ... @@ -384,10 +391,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
ApiResponse result=appraiseService.appraiseFail(appraiseExpressInfoBo,expectStatus,type);
if(result!=null&&result.getCode()==200){
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode,EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
logger.info("Buyer Order miniFaultReject (OrderRequest) {} ,update quality check record status num {} ", orderRequest,updateNum);
//TODO 发消息
}else{
... ... @@ -765,6 +768,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
//记录订单的状态变更信息
if(num>=1){
logger.info("in confirmReceive record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
inBoxFacade.noticeBuyerWhenPlatformReceiveGoods(uid,orderCode);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
}else{
logger.warn("in confirmReceive not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
... ... @@ -777,21 +781,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
/*
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(uid)));
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid);
EventBusPublisher.publishEvent(event);
*/
}
}
... ... @@ -864,6 +853,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
logger.info("in miniFaultCreate, push event uid {} ,order code {} ", miniFaultOuterTimeEvent.getUid(),miniFaultOuterTimeEvent.getOrderCode());
EventBusPublisher.publishEvent(miniFaultOuterTimeEvent);
//消息
inBoxFacade.buyerMiniFaultCreate(uid,orderCode);
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
}
... ...
... ... @@ -682,7 +682,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//yoho_to_seller_appraise_fail("物流详情", EnumExpressType.EXPRESS_TYPE_3.intValue()),
//yoho_to_seller_return_back("物流详情", EnumExpressType.EXPRESS_TYPE_REBACK.intValue()),;
LOGGER.info("getSenderName expressType is {} ", expressType);
return "物流详情";
return "订单跟踪";
}
... ...
... ... @@ -82,13 +82,21 @@ public class MetaConfigService {
}
public Map<EntrySellerType,EntryThreshold> getEntryThreshold(){
RedisKeyBuilder rkb = CacheKeyBuilder.entryThresholdConfigKey();
String configVal = cacheClient.get(rkb, String.class);
Map<EntrySellerType,EntryThreshold> map = new HashMap<>(2);
String key = MetaConfigKey.SELLER_ENTER_THRESHOLD;
MetaConfig metaConfig = metaConfigMapper.selectByCode(key);
logger.info("in getEntryThreshold from DB {}", metaConfig);
String configVal = null;
if (StringUtils.isBlank(configVal)){
String key = MetaConfigKey.SELLER_ENTER_THRESHOLD;
MetaConfig metaConfig = metaConfigMapper.selectByCode(key);
logger.info("in getEntryThreshold from DB {}", metaConfig);
configVal=metaConfig.getValue();
if (StringUtils.isNotBlank(configVal)){
cacheClient.setEx(rkb, configVal, 300);
}
}
try {
map = JSONObject.parseObject(configVal=metaConfig.getValue(), new TypeReference<Map<EntrySellerType,EntryThreshold>>(){});
map = JSONObject.parseObject(configVal, new TypeReference<Map<EntrySellerType,EntryThreshold>>(){});
}catch (Exception ex){
map = buildDefaultEntryThreshold();
logger.warn("in getEntryThreshold parse value fail,configVal {} use default {}", configVal, map, ex);
... ...
... ... @@ -113,6 +113,7 @@ public class QiniuLiveRecordService {
buyerOrders.stream().forEach(item -> {
OrderVideoResp orderVideoResp = new OrderVideoResp();
QiniuLiveRecord qiniuLiveRecord = recordMap.get(item.getOrderCode());
orderVideoResp.setCreateTimeInt(qiniuLiveRecord.getEndTime());
orderVideoResp.setCreateTime(DateUtil.getDateFormatEx(qiniuLiveRecord.getEndTime(), DateUtil.MM_dd_yyyy_HH_mm_ssEx));
orderVideoResp.setDesc(configReader.getString("ufo.order.realDesc", "鉴定结果:真"));
orderVideoResp.setVideoPictureUrl(configReader.getString("ufo.order.realVideoPic", "http://img11.static.yhbimg.com/goodsimg/2019/01/15/17/01e7093ff7effcdf76ed191e68e4a5c4ca.png"));
... ... @@ -121,7 +122,8 @@ public class QiniuLiveRecordService {
resps.add(orderVideoResp);
});
return resps;
List<OrderVideoResp> sortResp = resps.stream().sorted((s1, s2) -> s2.getCreateTimeInt().compareTo(s1.getCreateTimeInt())).collect(Collectors.toList());
return sortResp.subList(0, sortResp.size() > 10 ? 10 : sortResp.size());
}
// 查询宣传视频
... ...
package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo;
import com.yohobuy.ufo.model.order.common.CommonEnterStageLevel;
... ... @@ -18,6 +19,7 @@ import com.yohoufo.order.constants.SellerConfig;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerHelper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -149,29 +151,7 @@ public class SellerEnterApplyService {
}
}
private Integer getType2Level(EntrySellerType targetEst, Map<EntrySellerType,EntryThreshold> estMap,
BigDecimal left){
Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL;
switch (targetEst){
case COMMON:
EntryThreshold et = estMap.get(targetEst);
if (et.getPrepaymentAmount().compareTo(left) <= 0) {
level = CommonEnterStageLevel.ALL.getCode();
}
break;
case SUPER_ENTRY:
et = estMap.get(targetEst);
if (et.getPrepaymentAmount().compareTo(left) <= 0) {
level = SuperEnterStageLevel.FULL.getCode();
}else if (et.getGoodsOnOffShelveAmount().compareTo(left) <= 0){
level = SuperEnterStageLevel.PARTITION.getCode();
}else if (et.getHiddenGoodsAmount().compareTo(left) <=0){
level = SuperEnterStageLevel.PARTITION.getCode();
}
break;
}
return level;
}
/**
*
... ... @@ -210,6 +190,8 @@ public class SellerEnterApplyService {
public void upgradeLevel(SellerWrapper sellerWrapper,
Long orderCode, BigDecimal left, List<SellerEnterApply> seaList){
int uid = sellerWrapper.getUid();
logger.info("in upgradeLevel uid {} orderCode {} left wallet {}",
uid, orderCode, left );
//持久化的入驻信息
StoredSeller pss = sellerWrapper.getStoredSeller();
SellerBo sellerBo = sellerWrapper.build();
... ... @@ -225,7 +207,7 @@ public class SellerEnterApplyService {
//申请是否已经通过
boolean isPassedApply = Objects.equals(SellerEnterApplyStatus.PASS.getCode(), msea.getStatus());
//目标身份对应的等级
Integer level = getType2Level(targetEst, estMap, left);
Integer level = SellerHelper.getType2Level(targetEst, estMap, left);
//当前身份和申请时身份是否一致
Integer preEnterType;
boolean isMatchedET = Objects.equals(preEnterType=msea.getPreEnterType(), currentEnterType);
... ... @@ -272,7 +254,9 @@ public class SellerEnterApplyService {
private int upgradeSuperLevel(SellerWrapper sellerWrapper,Integer level, Long orderCode,
EntrySellerType targetEst, boolean isMatchedET){
Integer uid = sellerWrapper.getUid();
logger.info("in upgradeSuperLevel uid {} orderCode {}", uid, orderCode);
sellerWrapper.buildSuperEnterStageLevel(sellerLevelFuncMapper::selectByPrimaryKey);
SellerBo sellerBo = sellerWrapper.build();
SuperEnterStageLevel sesl = sellerBo.getSuperEnterStageLevel();
... ... @@ -292,6 +276,8 @@ public class SellerEnterApplyService {
}
public int doUpgradeSuper(EntrySellerType targetEst,Integer currentLevel, Integer level, Integer uid){
logger.info("doUpgradeSuper uid {} targetEst {} currentLevel {} target level {}",
uid, targetEst, currentLevel, level);
SellerLevelFuncBo slfb = sellerFuncService.getSellerLevelFunc(targetEst.getCode(), level);
int result = storedSellerService.updateEnterSeller(uid, targetEst, slfb);
processWithLevel(currentLevel, level, uid);
... ... @@ -333,13 +319,13 @@ public class SellerEnterApplyService {
EntrySellerType targetEST = EntrySellerType.SUPER_ENTRY;
boolean isMactchedEST = Objects.equals(currentEnterType, targetEST.getCode());
if (!isMactchedEST){
logger.info("changeLevel4Super is not super, uid {} left in wallet {}", uid, left);
logger.warn("changeLevel4Super is not super, uid {} left in wallet {}", uid, left);
return 0;
}
//身份等级配置
Map<EntrySellerType,EntryThreshold> estMap = metaConfigService.getEntryThreshold();
//目标身份对应的等级
Integer level = getType2Level(currentEST, estMap, left);
Integer level = SellerHelper.getType2Level(currentEST, estMap, left);
logger.info("in changeLevel4Super ready change StoredSeller level func, uid {} currentEnterType {} target Level {}",
uid, currentEnterType, level);
//超级卖家
... ... @@ -350,7 +336,7 @@ public class SellerEnterApplyService {
&& Objects.nonNull(currentLevel = sesl.getCode())
&& !currentLevel.equals(level);
StoredSeller pss = sellerWrapper.getStoredSeller();
boolean isValid = Objects.equals(pss.getValidStatus(), SellerEnterApplyStatus.PASS.getCode());
boolean isValid = Objects.equals(pss.getValidStatus(), StoredSellerStatusEnum.entered.getId());
logger.info("in changeLevel4Super update StoredSeller, uid {} currentLevel {} target level {} levelNeedUpgrade {} isValid {}",
uid, currentLevel, level, levelNeedUpgrade, isValid);
int result = 0;
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.bo.SellerFuncBo;
import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohoufo.common.cache.CacheClient;
import com.yohoufo.dal.order.SellerFuncMapper;
import com.yohoufo.dal.order.SellerLevelFuncMapper;
import com.yohoufo.dal.order.model.SellerFunc;
import com.yohoufo.dal.order.model.SellerLevelFunc;
import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.order.constants.SellerConfig;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -20,6 +28,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
... ... @@ -37,7 +46,14 @@ public class SellerFuncService {
@Autowired
private SellerFuncMapper sellerFuncMapper;
@Autowired
private MerchantOrderPaymentService merchantOrderPaymentService;
@Autowired
private MetaConfigService metaConfigService;
@Autowired
private CacheClient cacheClient;
public List<Integer> getFuncIdList(String lflStr){
List<Integer> funcIds = null;
... ... @@ -66,15 +82,63 @@ public class SellerFuncService {
return slfMap;
}
private SellerLevelFuncBo getDefaultSLFB(){
SellerLevelFuncBo defaultSLFB = new SellerLevelFuncBo();
defaultSLFB.setLevel(SellerConfig.ENTER_TYPE_DEFAULT_LEVEL);
defaultSLFB.setFuncList(SellerConfig.ENTER_TYPE_DEFAULT_FUNCS);
defaultSLFB.setFuncIdList(new ArrayList<>(1));
return defaultSLFB;
}
/**
* 钱包余额判定
* @param sellerWrapper
* @return
*/
public SellerLevelFuncBo getSellerLevelFuncWithWallet(SellerWrapper sellerWrapper){
int uid = sellerWrapper.getUid();
//left enter type is 入驻超级
BigDecimal leftInWallet = merchantOrderPaymentService.getWalletLeftAmount(uid);
SellerBo sellerBo = sellerWrapper.build();
//当前身份
EntrySellerType currentEST = sellerBo.getEntrySellerType();
//身份等级配置
Map<EntrySellerType,EntryThreshold> estMap = metaConfigService.getEntryThreshold();
Integer currentLevel = SellerHelper.getType2Level(currentEST, estMap, leftInWallet);
//持久化的入驻信息
StoredSeller pss = sellerWrapper.getStoredSeller();
boolean isValid = Objects.equals(pss.getValidStatus(), StoredSellerStatusEnum.entered.getId());
boolean existLevel = Objects.nonNull(currentLevel);
if (existLevel && isValid){
SellerLevelFuncBo slfb = getSellerLevelFunc(currentEST.getCode(), currentLevel);
logger.info("in getSellerLevelFuncWithWallet SellerLevelFuncBo {} uid {}", slfb, uid);
return slfb;
}else{
logger.warn("in getSellerLevelFuncWithWallet getDefaultSLFB uid {}", uid);
return getDefaultSLFB();
}
}
public SellerLevelFuncBo getSellerLevelFunc(SellerWrapper sellerWrapper){
int uid = sellerWrapper.getUid();
//持久化的入驻信息
SellerBo sellerBo = sellerWrapper.build();
//当前身份
EntrySellerType currentEST = sellerBo.getEntrySellerType();
if (SellerHelper.isSuper(currentEST)){
return getSellerLevelFuncWithWallet(sellerWrapper);
}else{
return getSellerLevelFuncWithSetting(sellerWrapper);
}
}
public SellerLevelFuncBo getSellerLevelFuncWithSetting(SellerWrapper sellerWrapper){
int uid = sellerWrapper.getUid();
sellerWrapper.buildSuperEnterStageLevel(sellerLevelFuncMapper::selectByPrimaryKey);
//持久化的入驻信息
StoredSeller pss = sellerWrapper.getStoredSeller();
... ... @@ -85,16 +149,18 @@ public class SellerFuncService {
Integer currentLevel = null;
boolean existLevel = Objects.nonNull(sesl)
&& Objects.nonNull(currentLevel = sesl.getCode());
if (existLevel){
boolean isValid = Objects.equals(pss.getValidStatus(), StoredSellerStatusEnum.entered.getId());
if (existLevel && isValid){
SellerLevelFuncBo slfb = getSellerLevelFunc(currentEST.getCode(), currentLevel);
logger.info("in getSellerLevelFunc SellerLevelFuncBo {} uid {}", slfb, uid);
logger.info("in getSellerLevelFuncWithSetting SellerLevelFuncBo {} uid {}", slfb, uid);
return slfb;
}else{
logger.warn("in getSellerLevelFunc getDefaultSLFB uid {}", uid);
logger.warn("in getSellerLevelFuncWithSetting getDefaultSLFB uid {}", uid);
return getDefaultSLFB();
}
}
public SellerLevelFuncBo getSellerLevelFunc(Integer enterType,Integer level){
if (level==null || level == SellerConfig.ENTER_TYPE_DEFAULT_LEVEL){
return getDefaultSLFB();
... ... @@ -112,37 +178,61 @@ public class SellerFuncService {
return slfb;
}
private Map<Integer,SellerFuncBo> buildCodeSellerFuncMap(){
List<SellerFunc> sellerFuncs = sellerFuncMapper.selectAll();
Map<Integer,SellerFuncBo> codeSellerFuncMap = sellerFuncs.parallelStream()
.map(sf->{
SellerFuncBo sfb = new SellerFuncBo();
sfb.setId(sf.getId());
sfb.setCode(sf.getCode());
sfb.setCnName(sf.getCnName());
sfb.setEnName(sf.getEnName());
return sfb;
}).collect(Collectors.toMap(SellerFuncBo::getId, Function.identity()));
RedisKeyBuilder rkb = CacheKeyBuilder.sellerBaseFuncConfigKey();
String scsf = cacheClient.get(rkb, String.class);
Map<Integer,SellerFuncBo> codeSellerFuncMap;
if(StringUtils.isBlank(scsf)){
List<SellerFunc> sellerFuncs = sellerFuncMapper.selectAll();
codeSellerFuncMap = sellerFuncs.parallelStream()
.map(sf->{
SellerFuncBo sfb = new SellerFuncBo();
sfb.setId(sf.getId());
sfb.setCode(sf.getCode());
sfb.setCnName(sf.getCnName());
sfb.setEnName(sf.getEnName());
return sfb;
}).collect(Collectors.toMap(SellerFuncBo::getId, Function.identity()));
scsf = JSONObject.toJSONString(codeSellerFuncMap);
logger.info("in buildCodeSellerFuncMap fetch from DB {}", scsf);
cacheClient.setEx(rkb, scsf, 300);
}else{
logger.info("in buildCodeSellerFuncMap hit cache {}", scsf);
codeSellerFuncMap = JSONObject.parseObject(scsf, new TypeReference<Map<Integer,SellerFuncBo>>(){});
}
return codeSellerFuncMap;
}
public Map<Integer, Map<Integer,SellerLevelFuncBo>> getETLVLELFMap(){
List<SellerLevelFunc> slfList = sellerLevelFuncMapper.selectAll();
if (CollectionUtils.isEmpty(slfList)){
return Collections.EMPTY_MAP;
}
Map<Integer,SellerFuncBo> codeSellerFuncMap = buildCodeSellerFuncMap();
RedisKeyBuilder rkb = CacheKeyBuilder.sellerFuncLevelConfigKey();
String sslf = cacheClient.get(rkb, String.class);
Map<Integer, Map<Integer, SellerLevelFuncBo>> ETLVLELFMap = new HashMap<>();
if (StringUtils.isNotBlank(sslf)){
logger.info("in getETLVLELFMap fetch SellerLevelFunc list from cache => {}", sslf);
ETLVLELFMap = JSONObject.parseObject(sslf, new TypeReference<Map<Integer, Map<Integer, SellerLevelFuncBo>>>(){});
}else {
List<SellerLevelFunc> slfList = sellerLevelFuncMapper.selectAll();
if (CollectionUtils.isEmpty(slfList)) {
return Collections.EMPTY_MAP;
}
Map<Integer, SellerFuncBo> codeSellerFuncMap = buildCodeSellerFuncMap();
Map<Integer, Map<Integer,SellerLevelFuncBo>> ETLVLELFMap = new HashMap<>();
for(SellerLevelFunc slf: slfList){
Integer enterType;
if (!ETLVLELFMap.containsKey(enterType=slf.getEnterType())){
ETLVLELFMap.put(enterType, new HashMap<Integer,SellerLevelFuncBo>());
for (SellerLevelFunc slf : slfList) {
Integer enterType;
if (!ETLVLELFMap.containsKey(enterType = slf.getEnterType())) {
ETLVLELFMap.put(enterType, new HashMap<Integer, SellerLevelFuncBo>());
}
SellerLevelFuncBo slfb = do2bo(slf, codeSellerFuncMap);
ETLVLELFMap.get(enterType).put(slf.getLevel(), slfb);
}
SellerLevelFuncBo slfb = do2bo(slf, codeSellerFuncMap);
ETLVLELFMap.get(enterType).put(slf.getLevel(), slfb);
sslf = JSONObject.toJSONString(ETLVLELFMap);
logger.info("in getETLVLELFMap fetch SellerLevelFunc list from DB => {}", sslf);
cacheClient.setEx(rkb, sslf, 300);
}
return ETLVLELFMap;
}
... ... @@ -154,6 +244,7 @@ public class SellerFuncService {
slfb.setFuncList(slf.getFuncList());
List<Integer> funcIdList = getFuncIdList(slf.getFuncList());
if (CollectionUtils.isNotEmpty(funcIdList)){
slfb.setFuncIdList(funcIdList);
List<SellerFuncBo> sellerFuncList = funcIdList.parallelStream().map(codeSellerFuncMap::get).collect(Collectors.toList());
slfb.setSellerFuncList(sellerFuncList);
}
... ...
... ... @@ -14,6 +14,7 @@ import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.cache.StoredSellerCacheService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerHelper;
import com.yohoufo.user.cache.CacheKeyEnum;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
... ... @@ -107,33 +108,29 @@ public class SellerService {
return uidList;
}
public SellerBo getSellerWithAuth(Integer uid){
public SellerWrapper getBaseSellerWrapper(Integer uid){
SellerWrapper sellerWrapper = new SellerWrapper(uid,logger)
.storedSellerDataSource(storedSellerMapper::selectByUid)
.addSpecialSuperFunc(this::isSpecialSuper)
.buildBase();
return sellerWrapper;
}
public SellerBo getSellerWithAuth(Integer uid){
logger.info("getSellerWithAuth uid {}", uid);
SellerWrapper sellerWrapper = getBaseSellerWrapper(uid);
SellerLevelFuncBo slfb = sellerFuncService.getSellerLevelFunc(sellerWrapper);
SellerBo sellerBo = sellerWrapper.build();
sellerBo.setSellerLevelFunc(slfb);
return sellerBo;
}
public boolean isNormalSuper(EntrySellerType est){
return Objects.equals(est, EntrySellerType.SUPER_ENTRY);
}
public boolean isSuper(EntrySellerType est){
boolean result = Objects.equals(est, EntrySellerType.SPECIAL_SUPER)
|| isNormalSuper(est);
return result;
}
public boolean isSuperEntrySeller(int uid){
if(storedSellerService.isStoredSeller(uid)){
EntrySellerType est = getEntrySellerType(uid);
boolean result = isSuper(est);
boolean result = SellerHelper.isSuper(est);
return result;
}
return false;
... ...
... ... @@ -45,6 +45,7 @@ public class TransferService {
try{
Integer sellerUid;
if(Objects.nonNull(sellerUid=req.getSellerUid()) && Objects.equals(transferCase, TransferCase.EARNEST_MONEY_TO_BUYER)) {
logger.info("ready 2 processAfterWalletChange TransferCase {} sellerUid {}", transferCase, sellerUid);
sellerService.processAfterWalletChange(sellerUid);
}
}catch (Exception ex){
... ...
... ... @@ -4,15 +4,16 @@ import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerHelper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.List;
/**
* Created by chao.chen on 2019/1/15.
... ... @@ -28,22 +29,18 @@ public class SellerAuthCheckService {
public SellerBo checkAuth(Integer uid, SellerFuncEnum sellerFunc){
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
EntrySellerType est;
boolean isSuper = sellerService.isSuper(est=sellerBo.getEntrySellerType());
boolean isNormalSuper = sellerService.isNormalSuper(est);
boolean isSuper = SellerHelper.isSuper(est=sellerBo.getEntrySellerType());
boolean isNormalSuper = SellerHelper.isNormalSuper(est);
if (isNormalSuper){
SellerLevelFuncBo slfb = sellerBo.getSellerLevelFunc();
List<Integer> funcIdList = slfb.getFuncIdList();
Integer level = slfb.getLevel();
switch (sellerFunc){
case BATCH_PUBLISH:
case BATCH_OFFSHELVE:
if (!Objects.equals(SuperEnterStageLevel.FULL.getCode(), level)){
logger.warn("in checkAuth fail uid {} est {} level {}", uid, est, level);
throw new UfoServiceException(511, "您已经被降级");
}
break;
case BATCH_CHANGEPRICE:
if (!Objects.equals(SuperEnterStageLevel.FULL.getCode(), level)
|| !Objects.equals(SuperEnterStageLevel.PARTITION.getCode(), level)){
if (CollectionUtils.isEmpty(funcIdList)
||!funcIdList.contains(sellerFunc.getCode())){
logger.warn("in checkAuth fail uid {} est {} level {}", uid, est, level);
throw new UfoServiceException(511, "您已经被降级");
}
... ... @@ -54,4 +51,8 @@ public class SellerAuthCheckService {
sellerBo.setIsNormalSuper(isNormalSuper);
return sellerBo;
}
}
... ...
... ... @@ -287,6 +287,129 @@ public class InBoxFacade {
}
/**
* 平台收货
*/
public void noticeBuyerWhenPlatformReceiveGoods(int buyerUid, long orderCode) {
try {
executorService.execute(() -> {
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_PLATFORM_RECEIVE;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeBuyerWhenPlatformReceiveGoods inbox msg, buyerUid {}, orderCode {}, resp {}",
buyerUid, orderCode, resp);
});
} catch (Exception e) {
logger.warn("InBoxFacade buyerCancelOrder error inbox msg, buyerUid {}, orderCode {} ",
buyerUid, orderCode, e);
}
}
/**
* 平台收货
*/
public void noticeBuyerWhenQualityCheckNotPass(int buyerUid, long orderCode,String prdName) {
try {
executorService.execute(() -> {
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_QUALITY_NOT_PASS;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeBuyerWhenQualityCheckNotPass inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
buyerUid, orderCode,prdName, resp);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeBuyerWhenQualityCheckNotPass sms fail, buyerUid {} orderCode {} ,prdName {}", buyerUid, orderCode,prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content=getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_QUALITY_NOT_PASS.getContent(),prdName,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeBuyerWhenQualityCheckNotPass inbox sms msg, buyerUid {}, orderCode {}, prdName {}",
buyerUid, orderCode,prdName);
});
} catch (Exception e) {
logger.warn("InBoxFacade noticeBuyerWhenQualityCheckNotPass error inbox msg, buyerUid {}, orderCode {} ,prdName {}",
buyerUid, orderCode,prdName, e);
}
}
/**
* 瑕疵提醒,给买家消息
*/
public void buyerMiniFaultCreate(int buyerUid, long orderCode) {
try {
executorService.execute(() -> {
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_PROBLEM_ORDER;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record buyerMiniFaultCreate inbox msg, buyerUid {} ,orderCode {} ,resp {}",
buyerUid, orderCode ,resp);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("buyerMiniFaultCreate sms send fail,buyerUid {} ,orderCode {}", buyerUid, orderCode);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_CHECK_ORDER_PROBLEM.getContent(),orderCode);
sendSmsService.smsSendByMobile(content, mobileList);
logger.info("record buyerMiniFaultCreate inbox sms msg,buyerUid {}, porderCode {}",
buyerUid ,orderCode);
});
} catch (Exception e) {
logger.warn("InBoxFacade buyerMiniFaultCreate error inbox msg, buyerUid {},orderCode {} ",
buyerUid, orderCode , e);
}
}
/**
* 不接受瑕疵,给买家消息
*/
public void buyerMiniFaultUnAccept(int buyerUid, long orderCode,String prdName,boolean outTimeFlag) {
try {
executorService.execute(() -> {
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_MINI_FAULT_UN_ACCEPT;
if(outTimeFlag){
ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_MINI_FAULT_UN_ACCEPT_OUT_TIME;
}
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record buyerQualityCheckNotPass inbox msg, buyerUid {} ,orderCode {},prdName {} ,resp {}",
buyerUid, orderCode, prdName ,resp);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("buyerQualityCheckNotPass sms send fail,buyerUid {} ,orderCode {}", buyerUid, orderCode);
return;
}
List<String> mobileList = Arrays.asList(phone);
InboxBusinessTypeEnum sms = InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_MINI_FAULT_UN_ACCEPT;
String content = getReplacedContent(sms.getContent(),prdName,orderCode);
sendSmsService.smsSendByMobile(content, mobileList);
logger.info("record buyerQualityCheckNotPass inbox sms msg,buyerUid {}, prdName {},orderCode {}",
buyerUid , prdName,orderCode);
});
} catch (Exception e) {
logger.warn("InBoxFacade sellerSkupPaidByBuyer error inbox msg, buyerUid {},orderCode {}, prdName {} ",
buyerUid, orderCode ,prdName, e);
}
}
/*********************************************************************
* 卖家消息
********************************************************************/
... ... @@ -383,6 +506,43 @@ public class InBoxFacade {
}
/**
* 质检不通过,给卖家消息
*/
public void sellerQualityCheckNotPass(SellerOrderGoods sog,long orderCode,String wayBillCode) {
Integer sellerUid = sog.getUid();
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
try {
executorService.execute(() -> {
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_QUALITY_CHECK_REJECT;
String params = buildParams(prdName, sizeName);
InboxReqVO req = buildInboxReqVO(sellerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record sellerQualityCheckNotPass inbox msg, SellerOrderGoods {} ,sellerUid {}, prdName {}, sizeName {},resp {}",
JSON.toJSONString(sog),sellerUid, prdName, sizeName, resp);
//短信
String phone = userProxyService.getMobile(sellerUid);
if (StringUtils.isBlank(phone)){
logger.warn("sellerQualityCheckNotPass sms send fail,sellerUid {}, prdName {}", sellerUid, prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_QUALITY_CHECK_REJECT.getContent(),prdName,orderCode,wayBillCode);
sendSmsService.smsSendByMobile(content, mobileList);
logger.info("record sellerQualityCheckNotPass inbox sms msg,sellerUid {}, prdName {},orderCode {}",
sellerUid, prdName,orderCode);
});
} catch (Exception e) {
logger.warn("InBoxFacade sellerSkupPaidByBuyer error inbox msg, sellerUid {}, prdName {} ",
sellerUid, prdName, e);
}
}
/**
* 卖家发货提醒,买家支付购买后
*
* @param sog SellerOrderGoods
... ...
package com.yohoufo.order.service.proxy;
import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.OrderOperateRecordMapper;
import com.yohoufo.dal.order.model.OrderOperateRecord;
import com.yohoufo.order.utils.PubThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Service
public class OrderOperateRecordService {
private final Logger logger = LoggerFactory.getLogger(getClass());
private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000),new PubThreadFactory("order-operate-record"));
@Autowired
private OrderOperateRecordMapper orderOperateRecordMapper;
public void addRecord(Long orderCode,String userName, OperateTypeEnum operateType){
try {
logger.info("OrderOperateRecordService add enter , operateType {}, orderCode {} ,userName {}",
operateType, orderCode ,userName);
executorService.execute(() -> {
OrderOperateRecord optRecord = new OrderOperateRecord();
optRecord.setOrderCode(String.valueOf(orderCode));
optRecord.setType(operateType.getCode());
optRecord.setUid(0);
optRecord.setUserName(userName);
optRecord.setUpdateTime(DateUtil.getCurrentTimeSecond());
optRecord.setOldInfo("");
logger.info("OrderOperateRecordService add execute , OrderOperateRecord {} ",optRecord );
orderOperateRecordMapper.insert(optRecord);
});
} catch (Exception e) {
logger.warn("OrderOperateRecordService add error , operateType {}, orderCode {} ",
operateType, orderCode, e);
}
}
}
... ...
package com.yohoufo.order.utils;
import com.yohobuy.ufo.model.order.common.CommonEnterStageLevel;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohoufo.order.constants.SellerConfig;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Objects;
/**
* Created by chao.chen on 2019/1/16.
*/
public class SellerHelper {
public static Integer getType2Level(EntrySellerType targetEst, Map<EntrySellerType,EntryThreshold> estMap,
BigDecimal left){
Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL;
switch (targetEst){
case COMMON:
EntryThreshold et = estMap.get(targetEst);
if (et.getPrepaymentAmount().compareTo(left) <= 0) {
level = CommonEnterStageLevel.ALL.getCode();
}
break;
case SUPER_ENTRY:
et = estMap.get(targetEst);
if (et.getPrepaymentAmount().compareTo(left) <= 0) {
level = SuperEnterStageLevel.FULL.getCode();
}else if (et.getGoodsOnOffShelveAmount().compareTo(left) <= 0){
level = SuperEnterStageLevel.PARTITION.getCode();
}else if (et.getHiddenGoodsAmount().compareTo(left) <=0){
level = SuperEnterStageLevel.PARTITION.getCode();
}
break;
}
return level;
}
public static boolean isNormalSuper(EntrySellerType est){
return Objects.equals(est, EntrySellerType.SUPER_ENTRY);
}
public static boolean isSuper(EntrySellerType est){
boolean result = Objects.equals(est, EntrySellerType.SPECIAL_SUPER)
|| isNormalSuper(est);
return result;
}
}
... ...
package com.yohoufo.order.service;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.service.impl.processor.SellerAuthCheckService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by chao.chen on 2019/1/16.
*/
public class SellerAuthCheckServiceTest extends BaseWebTest {
@Autowired
private SellerAuthCheckService sellerAuthCheckService;
@Test
public void testCheckAuth(){
Integer uid = 500031424;
SellerFuncEnum sellerFunc = SellerFuncEnum.BATCH_CHANGEPRICE;
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, sellerFunc);
System.out.println("testCheckAuth BATCH_CHANGEPRICE "+ JSONObject.toJSONString(sellerBo));
}
}
... ...
package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.service.impl.SellerEnterApplyService;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.impl.SellerWrapper;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -39,4 +41,12 @@ public class SellerEnterApplyServiceTest extends BaseWebTest {
long order = 6666666666L;
sellerEnterApplyService.audit(uid, order, new BigDecimal(100));
}
@Test
public void testChangeLevel4Super(){
int uid = 500031424;
SellerWrapper sellerWrapper =sellerService.getBaseSellerWrapper(uid);
BigDecimal left = new BigDecimal(100);
sellerEnterApplyService.changeLevel4Super(sellerWrapper, left);
}
}
... ...
... ... @@ -73,6 +73,7 @@ datasources:
- com.yohoufo.dal.order.OrdersPrePayMapper
- com.yohoufo.dal.order.MetaConfigMapper
- com.yohoufo.dal.order.BuyerOrderStatusFlowMapper
- com.yohoufo.dal.order.OrderOperateRecordMapper
- com.yohoufo.dal.order.QualityCheckMapper
- com.yohoufo.dal.order.BusinessLicenseMapper
- com.yohoufo.dal.order.SellerEnterApplyMapper
... ...
... ... @@ -57,7 +57,7 @@ public class ProductSearchController {
@RequestParam(value = "query", required = false)String query,
@RequestParam(value = "limit", required = false)Integer limit,
@RequestParam(value = "page", required = false)Integer page,
@RequestParam(value = "app_version", required = true)String appVersion
@RequestParam(value = "app_version", required = false)String appVersion
) {
if (type != null) {
Map<Integer,Integer> poolConfig = ufoServiceCaller.call("ufo.resource.goodsPool", Map.class);
... ... @@ -114,7 +114,8 @@ public class ProductSearchController {
@RequestParam(value = "gender", required = false) String gender,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value = "isSoonSale", required = false) String isSoonSale,
@RequestParam(value = "query", required = false)String query
@RequestParam(value = "query", required = false)String query,
@RequestParam(value = "app_version", required = false)String appVersion
) {
... ... @@ -122,6 +123,7 @@ public class ProductSearchController {
ProductSearchReq req = new ProductSearchReq().setPool(productPool).setBrand(brand).setMidSort(sortIdLevel.getMidSortId()).setMaxSort(sortIdLevel.getMaxSortId())
.setSeries(series).setGender(gender).setSize(size).setIsSoonSale(isSoonSale);
searchHelpService.setQuery(query, req);
searchHelpService.setContainYoho(appVersion, req);
LOG.info("in method=ufo.product.search.list req={}", req.toString());
SearchProductListFilterResp resp = productSearchService.searchProductListFilter(req);
... ...
... ... @@ -64,7 +64,8 @@ public class SearchParam {
.setProductPool(req.getPool()).setBrandSeries(req.getSeries()).setGender(req.getGender()).setNotId(req.getNot_id())
.setFilterYearMonth(req.getFilterYearMonth())
.setStartTime(req.getStartTime())
.setEndTime(req.getEndTime());
.setEndTime(req.getEndTime())
.setContainYoho(req.getContainYoho());
return this;
}
... ...
... ... @@ -73,6 +73,7 @@ datasources:
- com.yohoufo.dal.order.OrdersPrePayMapper
- com.yohoufo.dal.order.MetaConfigMapper
- com.yohoufo.dal.order.BuyerOrderStatusFlowMapper
- com.yohoufo.dal.order.OrderOperateRecordMapper
- com.yohoufo.dal.order.QualityCheckMapper
- com.yohoufo.dal.order.BusinessLicenseMapper
- com.yohoufo.dal.order.SellerEnterApplyMapper
... ...
... ... @@ -73,6 +73,7 @@ datasources:
- com.yohoufo.dal.order.OrdersPrePayMapper
- com.yohoufo.dal.order.MetaConfigMapper
- com.yohoufo.dal.order.BuyerOrderStatusFlowMapper
- com.yohoufo.dal.order.OrderOperateRecordMapper
- com.yohoufo.dal.order.QualityCheckMapper
- com.yohoufo.dal.order.BusinessLicenseMapper
- com.yohoufo.dal.order.SellerEnterApplyMapper
... ...