Authored by chenchao

fix bugs

... ... @@ -96,7 +96,7 @@ public interface SellerOrderGoodsMapper {
* @param statusList
* @return
*/
List<SellerOrderGoods> selectByPayment(@Param("payment") int payment,
List<SellerOrderGoods> selectByPayment(@Param("payment") Integer payment,
@Param("condition") SellerOrderGoods record,
@Param("statusList") Collection<Integer> statusList,
@Param("num") int num);
... ...
... ... @@ -457,7 +457,9 @@
and sog.uid = #{condition.uid,jdbcType=INTEGER}
and sog.product_id = #{condition.productId,jdbcType=INTEGER}
and sog.storage_id = #{condition.storageId,jdbcType=INTEGER}
<if test="payment != null">
and so.payment = #{payment,jdbcType=INTEGER}
</if>
and sog.goods_price = #{condition.goodsPrice,jdbcType=DECIMAL}
<if test="condition.attributes != null">
and sog.attributes = #{condition.attributes,jdbcType=INTEGER}
... ...
... ... @@ -27,6 +27,7 @@ import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.impl.AppraiseService;
import com.yohoufo.order.service.impl.MetaConfigService;
import com.yohoufo.order.service.impl.OrderOverTimeService;
import com.yohoufo.order.service.impl.TradeBillsService;
... ... @@ -93,22 +94,27 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
private DepositService depositService;
@Autowired
private AppraiseService appraiseService;
/**
* 更新订单状态
* @param orderInfo
*/
public int updateOrderStatusPaid(OrderInfo orderInfo){
Integer uid = orderInfo.getUid();
Long orderCode;
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setOrderCode(orderInfo.getOrderCode());
buyerOrder.setOrderCode(orderCode = orderInfo.getOrderCode());
buyerOrder.setUid(uid);
int orderStatusCode = OrderStatus.HAS_PAYED.getCode();
OrderStatus targetOrderStatus = OrderStatus.HAS_PAYED;
boolean isQuickDeliver = false;
//门店订单支付后直接完成
if(BuyerOrderUtils.isOffline(orderInfo)) {
orderStatusCode = OrderStatus.DONE.getCode();
if(BuyerOrderUtils.isOffline(orderInfo) ) {
targetOrderStatus = OrderStatus.DONE;
}else if(isQuickDeliver=BuyerOrderUtils.isQuickDeliver(orderInfo.getAttributes())){
targetOrderStatus = OrderStatus.WAITING_RECEIVE;
}
int orderStatusCode = targetOrderStatus.getCode();
buyerOrder.setStatus(orderStatusCode);
// 用于控制并发更新的
... ... @@ -120,8 +126,11 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
if(result>0){
//记录状态信息
logger.info("in updateOrderStatusPaid record status change, orderCode {}, status: {}",
orderInfo.getOrderCode(), orderStatusCode);
orderStatusFlowService.addAsy(orderInfo.getOrderCode(), orderStatusCode);
orderCode, orderStatusCode);
orderStatusFlowService.addAsy(orderCode, orderStatusCode);
if (isQuickDeliver){
appraiseService.processQuickDeliverOrderAfterPaid(orderCode, uid);
}
}
orderInfo.setStatus(orderStatusCode);
return result;
... ...
... ... @@ -410,6 +410,8 @@ public class AppraiseService {
inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods, orderCode, wayBillCode, type);
}
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode, int uid, int sellerUid) {
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
... ... @@ -770,8 +772,12 @@ public class AppraiseService {
}
//更新卖家订单的状态,并清缓存
private SellerOrderGoods updateSellerOrderStatusAndCleanCache(int sellerUid, long sellerOrderCode, SellerOrderStatus expectSOStatus, SellerOrderStatus targetSoStatus,
int skup, Long orderCode, int buyerUid) {
private SellerOrderGoods updateSellerOrderStatusAndCleanCache(int sellerUid,
long sellerOrderCode,
SellerOrderStatus expectSOStatus,
SellerOrderStatus targetSoStatus,
int skup,
Long orderCode, int buyerUid) {
SellerOrder tso = new SellerOrder();
tso.setUid(sellerUid);
tso.setOrderCode(sellerOrderCode);
... ... @@ -780,19 +786,12 @@ public class AppraiseService {
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
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);
cleanCacheAfterUpdateStatus(orderCode, buyerUid, sellerUid);
return sellerOrderGoods;
}
/**
* 更新发到卖家的物流信息
* 将卖家的保证金分账给平台和买家
... ... @@ -1035,6 +1034,7 @@ public class AppraiseService {
return model;
}
/**
* 手机质检端的鉴定不通过
* <p>
... ... @@ -1287,12 +1287,8 @@ public class AppraiseService {
return apiResponse;
}
private void transferGoodsMoneyWhenPass(Integer sellerUid, Integer skup, Long orderCode){
/**
* 通过时 ,操作钱
*/
private PaymentRequest operateMoneyWhenOk(Integer buyerUid, Long orderCode, int skup, SellerOrder sellerOrder, SellerOrderStatus targetSoStatus) {
final Integer sellerUid = sellerOrder.getUid();
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
... ... @@ -1315,6 +1311,21 @@ public class AppraiseService {
LOGGER.info("in appraiseSuccess,begin transfer async");
transferService.transfer(tmReq);
});
}
/**
* 通过时 ,操作钱
*/
private PaymentRequest operateMoneyWhenOk(Integer buyerUid, Long orderCode, int skup, SellerOrder sellerOrder, SellerOrderStatus targetSoStatus) {
final Integer sellerUid = sellerOrder.getUid();
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
TranseferCellNode transeferCellNode = new TranseferCellNode();
transeferCellNode.setUid(sellerUid);
transeferCellNode.setAmount(saleIncome);
transferGoodsMoneyWhenPass(sellerUid, skup, orderCode);
//退保证金给卖家
//refund earnestMoney
... ... @@ -1539,4 +1550,16 @@ public class AppraiseService {
}
}
}
public void processQuickDeliverOrderAfterPaid(long orderCode,int uid){
BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
try {
transferGoodsMoneyWhenPass(pbo.getSellerUid(), pbog.getSkup(), orderCode);
}catch (Exception ex){
LOGGER.warn("in processQuickDeliverOrderAfterPaid transferGoodsMoneyWhenPass fail orderCode {} uid {}",
orderCode, uid, ex);
}
}
}
... ...
package com.yohoufo.order.service.seller.processor;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
... ... @@ -31,7 +33,12 @@ public class AdjustPricePrepareProcessor extends AbsEntryChangePricePrepareProce
condition.setStorageId(req.getStorageId());
condition.setGoodsPrice(req.getOldPrice());
condition.setAttributes(req.getSkupType());
return sellerOrderGoodsMapper.selectByPayment(Payment.WALLET.getCode(), condition, Arrays.asList(SkupStatus.CAN_SELL.getCode()), req.getNum());
SkupType skupType = SkupType.getSkupType(req.getSkupType());
Integer payment = Payment.WALLET.getCode();
if (SellerGoodsHelper.isQuickDeliver(skupType)){
payment = null;
}
return sellerOrderGoodsMapper.selectByPayment(payment, condition, Arrays.asList(SkupStatus.CAN_SELL.getCode()), req.getNum());
}
@Override
... ...
... ... @@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.model.dto.SkupDownShelfPrepareDto;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -66,8 +67,9 @@ public class SellerDownShelfPrepareProcessor {
logger.warn("batch off shelve checkAndAcquire uid illegal , req {}", req);
throw new UfoServiceException(400, "参数[oldPrice]不合法");
}
//检查
Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(req);
Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(req, skupType);
SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder()
.idSkupMap(skupMap)
... ... @@ -76,14 +78,19 @@ public class SellerDownShelfPrepareProcessor {
return sdspDto;
}
private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req) {
private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req, SkupType skupType) {
SellerOrderGoods condition = new SellerOrderGoods();
condition.setUid(req.getUid());
condition.setProductId(req.getProductId());
condition.setStorageId(req.getStorageId());
condition.setGoodsPrice(req.getOldPrice());
condition.setAttributes(req.getSkupType());
List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByPayment(Payment.WALLET.getCode(), condition, CAN_OFF_STATUS, req.getNum());
Integer payment = Payment.WALLET.getCode();
if (SellerGoodsHelper.isQuickDeliver(skupType)){
payment = null;
}
List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByPayment(payment, condition, CAN_OFF_STATUS, req.getNum());
if (CollectionUtils.isEmpty(sellerOrderGoodList)) {
logger.warn("batch off shelve checkAndAcquire not find skups by batchNo, req {}", req);
throw new UfoServiceException(501, "商品已被下单购买");
... ...
... ... @@ -248,4 +248,5 @@ public class QuickDeliverGoodsService {
return respBuilder.build();
}
}
... ...
... ... @@ -5,6 +5,8 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.dal.order.model.BuyerOrder;
import java.util.Objects;
public class BuyerOrderUtils {
/**
... ... @@ -57,4 +59,9 @@ public class BuyerOrderUtils {
public static boolean isDeposit(BuyerOrder buyerOrder) {
return isDeposit(buyerOrder.getAttributes());
}
public static boolean isQuickDeliver(Integer orderAttrCode){
return Objects.nonNull(orderAttrCode) && Objects.equals(OrderAttributes.QUICK_DELIVER.getCode(), orderAttrCode);
}
}
... ...
package com.yohoufo.product.service.listener;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.ServiceCaller;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.request.nfc.ProductIdentifyVo;
import com.yohoufo.product.event.ProductIdentifyEvent;
import com.yohoufo.product.service.ProductIdentifyService;
... ... @@ -12,8 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
/**
* Created by li.ma on 2019/7/11.
*/
... ...