Authored by chenchao

fix bug

... ... @@ -95,20 +95,22 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
SellerOrderGoods tsog = new SellerOrderGoods();
tsog.setId(skup);
productProxyService.syncSkup(tsog, soTargetStatus.getSkupStatus());
//
notEntrySellerChangePriceService.processAfterChangePriceOrderPaid(uid, orderCode);
}
return updateCnt;
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
logger.info("method com.yohoufo.order.service.SellerOrderPaymentService.processAfterPay in, orderInfo is {}", orderInfo);
logger.info("SellerOrderPaymentService.processAfterPay in, orderInfo is {}", orderInfo);
//
int sellerUid = orderInfo.getUid();
Long orderCode = orderInfo.getOrderCode();
notEntrySellerChangePriceService.processAfterChangePriceOrderPaid(sellerUid, orderCode);
String prdName = null;
String sizeName = null;
Integer productId = null;
int sellerUid;
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(orderInfo.getOrderCode());
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(orderCode);
SellerOrderGoods sellerOrderGoods = null;
if (Objects.nonNull(sellerOrder)){
sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
... ... @@ -116,7 +118,7 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
sizeName = sellerOrderGoods.getSizeName();
productId = sellerOrderGoods.getProductId();
}
inBoxFacade.sellerPaidEarnestMoney(sellerUid=orderInfo.getUid(), prdName,sizeName,productId);
inBoxFacade.sellerPaidEarnestMoney(sellerUid, prdName,sizeName,productId);
//
int skup = sellerOrder.getSkup();
SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder()
... ...
... ... @@ -51,7 +51,7 @@ public class SellerOrderComputeHandler extends AbsSellerOrderComputeHandler impl
@Override
protected ServiceFeeRate buildServiceFeeRate(ServiceFeeRate psfr) {
//
ServiceFeeRate serviceFeeRate = orderDynamicConfig.getServiceFeeRate();
ServiceFeeRate serviceFeeRate = orderDynamicConfig.cloneServiceFeeRate();
BigDecimal pgpr;
if (psfr !=null
&& (pgpr = psfr.getGoodsPaymentRate()) !=null){
... ...
... ... @@ -99,9 +99,17 @@ public class OrderDynamicConfig {
*/
private BuyerCancelCompensateNode beforeDepotReceiveBCCN;
@Getter
private ServiceFeeRate serviceFeeRate;
public ServiceFeeRate cloneServiceFeeRate(){
ServiceFeeRate serviceFeeRate = new ServiceFeeRate();
serviceFeeRate.setGoodsPaymentRate(new BigDecimal(goodsPaymentRate).setScale(2, BigDecimal.ROUND_HALF_UP));
serviceFeeRate.setEarnestMoneyRate(new BigDecimal(earnestMoneyRate).setScale(2, BigDecimal.ROUND_HALF_UP));
serviceFeeRate.setPayChannelRate(new BigDecimal(payChannelRate).setScale(4, BigDecimal.ROUND_HALF_UP));
return serviceFeeRate;
}
@PostConstruct
private void init() {
EARNEST_MONEY_RANGE[0] = new BigDecimal(earnestmoney_min);
... ...
... ... @@ -440,22 +440,6 @@ public class SellerOrderCancelService {
if(result > 0 ){
refundEarnestMoney(sellerOrder, targetSOStatus,sellerOrder.getEarnestMoney());
/*
try {
payRefundService.refund(refundReq, bleb);
logger.info("in cancelAfterPayButNotBuyAction, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, orderCode, skup, earnestMoney);
}catch (Exception ex){
logger.warn("in appraiseSuccess, refund fail, req {}", refundReq, ex);
if (!isSuper) {
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
}
String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}*/
}
return result;
... ...
... ... @@ -346,6 +346,8 @@ public class ProductProxyService {
private final static String hideSellerAllSkup = "ufo.product.hideSellerAllSkup",
showSellerAllSkup = "ufo.product.showSellerAllSkup";
final static String hideSellerSkup = "ufo.product.hideSellerSkup",
showSellerSkup = "ufo.product.showSellerSkup";
public boolean hiddenGoods(Integer uid){
logger.info("begin in {} uid {}", hideSellerAllSkup, uid);
ApiResponse resp = null;
... ... @@ -375,4 +377,31 @@ public class ProductProxyService {
return ufoServiceCaller.call(BATCH_ADD, prds);
}
public boolean hiddenSkup(Integer skup){
final String method = hideSellerSkup;
logger.info("begin in {} uid {}", method, skup);
ApiResponse resp = null;
try {
resp = ufoServiceCaller.call(method, skup);
}catch (Exception ex){
logger.warn("in {} call fail uid {}", method, skup, ex);
}
logger.info("finish {} -> uid {}", method, skup);
return (null == resp || null == resp.getData())? false : (boolean)resp.getData();
}
public boolean cancelHiddenSkup(Integer skup){
final String method = showSellerSkup;
logger.info("begin in {} uid {}", method, skup);
ApiResponse resp = null;
try {
resp = ufoServiceCaller.call(method, skup);
}catch (Exception ex){
logger.warn("in {} call fail uid {}", method, skup, ex);
}
logger.info("finish {} -> uid {}", method, skup);
return (null == resp || null == resp.getData())? false : (boolean)resp.getData();
}
}
... ...
... ... @@ -50,7 +50,7 @@ public class SellerAdvanceOrderComputeHandler extends AbsSellerOrderComputeHandl
@Override
protected ServiceFeeRate buildServiceFeeRate(ServiceFeeRate psfr) {
//add lost
ServiceFeeRate serviceFeeRate = orderDynamicConfig.getServiceFeeRate();
ServiceFeeRate serviceFeeRate = orderDynamicConfig.cloneServiceFeeRate();
BigDecimal pgpr;
if (psfr!=null
&& (pgpr = psfr.getGoodsPaymentRate()) !=null){
... ...
... ... @@ -24,6 +24,7 @@ import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.seller.SellerChangePriceRecordService;
import com.yohoufo.order.service.seller.processor.NESChangePricePrepareProcessor;
import com.yohoufo.order.service.seller.processor.NESChangePricePublishPrepareProcessor;
... ... @@ -82,10 +83,8 @@ public class NotEntrySellerChangePriceService {
@Autowired
private SellerChangePriceRecordService sellerChangePriceRecordService;
public boolean isChangePriceOrder(int skup){
return false;
}
@Autowired
private ProductProxyService productProxyService;
public boolean isChangePriceOrder(long orderCode){
... ... @@ -135,10 +134,10 @@ public class NotEntrySellerChangePriceService {
if (CollectionUtils.isEmpty(scprList)){
logger.info("NotEntrySellerChangePriceService.changePrice there are not WAITING_DEAL or SUCCESS records, req {}", req);
//首次 或 全部失败
//todo 屏蔽商品
OrderSubmitResp osResp = nesChangePricePublishExcutor.publish(ctx);
sellerChangePriceRecordService.add(preOrderCode, preSkup,osResp.getOrderCode(), osResp.getSkup() );
//屏蔽商品
productProxyService.hiddenSkup(preSkup);
return osResp;
}
ChangePriceRecords cpr = splitChangePriceRecords(scprList);
... ... @@ -155,6 +154,8 @@ public class NotEntrySellerChangePriceService {
batchCancel(req.getUid(), cpr.waitingDealList);
OrderSubmitResp osResp = nesChangePricePublishExcutor.publish(ctx);
sellerChangePriceRecordService.add(preOrderCode, preSkup,osResp.getOrderCode(), osResp.getSkup() );
//屏蔽商品
productProxyService.hiddenSkup(preSkup);
return osResp;
}
return OrderSubmitResp.builder().tips("变价失败").build();
... ... @@ -222,7 +223,22 @@ public class NotEntrySellerChangePriceService {
}
long preOrderCode = scpr.getPreOrderCode();
sellerOrderCancelService.cancelSellerOrder(uid, preOrderCode);
Integer preSkup = scpr.getPreSkup();
try {
logger.info("in processAfterChangePriceOrderPaid cancel pre-SellerOrder , uid {} orderCode {} preOrderCode {}",
uid, orderCode, preOrderCode);
sellerOrderCancelService.cancelSellerOrder(uid, preOrderCode);
}catch (Exception ex){
logger.warn("in processAfterChangePriceOrderPaid cancelSellerOrder fail so need roll back, uid {} orderCode {} preOrderCode {}",
uid, orderCode, preOrderCode, ex);
rollBackWherPaidCallBackFail(uid, orderCode);
}finally {
productProxyService.cancelHiddenSkup(preSkup);
}
}
private void rollBackWherPaidCallBackFail(int uid, long orderCode){
sellerOrderCancelService.cancelSellerOrder(uid, orderCode);
}
public void batchCancel(int uid, List<SellerChangePriceRecord> scprList){
... ... @@ -280,25 +296,33 @@ public class NotEntrySellerChangePriceService {
public int recordAutoCancelIfPresent(int uid, long orderCode){
ChangePriceStatus tcps = ChangePriceStatus.TIME_OUT,
scps = ChangePriceStatus.WAITING_DEAL;
return recordFailIfPresent(uid, orderCode, tcps, scps);
int num = recordFailIfPresent(uid, orderCode, tcps, scps);
return num;
}
private int recordFailIfPresent(int uid, long orderCode, ChangePriceStatus tcps, ChangePriceStatus sourceStatus){
logger.info("record Fail If Present SellerChangePriceRecord,uid {} orderCode {} target status {}",
uid, orderCode, tcps);
if (!isChangePriceOrder(orderCode)){
SellerChangePriceRecord scpr = sellerChangePriceRecordMapper.selectByOrderCode(orderCode);
if (Objects.isNull(scpr)){
logger.warn("record Fail If Present SellerChangePriceRecord find no record,uid {} orderCode {} target status {}",
uid, orderCode, tcps);
return 0;
}
Integer preskup = scpr.getPreSkup();
SellerChangePriceRecord scprc = new SellerChangePriceRecord();
scprc.setOrderCode(orderCode);
scprc.setStatus(tcps.getCode());
scprc.setUpdateTime(DateUtil.getCurrentTimeSecond());
scprc.setRemark(tcps.getDesc());
scprc.setSourceStatus(sourceStatus.getCode());
return sellerChangePriceRecordMapper.updateByOrderCodeNStatus(scprc);
int num = sellerChangePriceRecordMapper.updateByOrderCodeNStatus(scprc);
if (num>0){
productProxyService.cancelHiddenSkup(preskup);
}
return num;
}
public int recordFail(long orderCode, ChangePriceStatus cps,ChangePriceStatus sourceStatus){
... ...
... ... @@ -42,7 +42,13 @@ public class NESChangePricePrepareProcessor extends AbsChangePricePrepareProcess
public void checkGoodsStatus(SellerOrderGoods psog){
if (SkupStatus.CAN_SELL.getCode() != psog.getStatus().intValue()){
logger.warn("in NESChangePricePrepareProcessor.checkGoodsStatus not can sale, SellerOrderGoods {}", psog);
throw new UfoServiceException(400, "商品不是可售状态");
SkupStatus skupStatus = SkupStatus.getSkupStatus(psog.getStatus().intValue());
String msg = skupStatus.getDesc() + ",不能调价";
switch (skupStatus) {
case SELL_OUT:
msg = "您的商品已经被购买,不能调价";
}
throw new UfoServiceException(400, msg);
}
}
... ... @@ -146,7 +152,7 @@ public class NESChangePricePrepareProcessor extends AbsChangePricePrepareProcess
.map(BuyerOrder::getOrderCode).collect(Collectors.toList());
logger.warn("ChangePrice checkAndAcquire exist waiting pay buy order , SellerOrderGoods {} waitingPayOrderCodes {}",
psog, waitingPayOrderCodes);
throw new UfoServiceException(400, "商品正在等待买家支付");
throw new UfoServiceException(400, "您的商品已经被下单,不能调价");
}
return SkupDto.builder().skup(psog.getId()).sellerOrderGoods(psog).build();
... ...