Merge branch 'refs/heads/dev' into test

This commit is contained in:
2024-10-30 11:17:34 +08:00
5 changed files with 33 additions and 14 deletions

View File

@@ -748,8 +748,6 @@ public class MemberService {
baObj.put("time", flow.get().getCreateTime());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS);
}

View File

@@ -22,5 +22,12 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
* @return 是否成功
*/
boolean updateStateByIds(Integer shopId, List<Integer> cartIds, TableConstant.Status status);
/**
* 根据订单id更改购物车状态
* @param status 状态
* @param orderId 订单id
*/
boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId);
}

View File

@@ -584,8 +584,11 @@ public class OrderService {
if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
masterId = cashierCart.getMasterId();
}
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
if (cashierCart.getIsPack().equals("true")) {
boolean isReturn = TableConstant.CashierCart.Status.RETURN.equalsVals(cashierCart.getStatus());
if (!isReturn) {
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
}
if (cashierCart.getIsPack().equals("true") && !isReturn) {
packAmount = packAmount.add(cashierCart.getPackFee());
}
TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));

View File

@@ -11,11 +11,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.bean.OrderUseTypeEnum;
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
import com.chaozhanggui.system.cashierservice.entity.po.OrderDetailPo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.exception.NotPrintException;
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
@@ -134,10 +136,13 @@ public class PayService {
@Autowired
private PlatformTransactionManager transactionManager;
private final MpCashierCartService mpCashierCartService;
private final Utils utils;
public PayService(RedisTemplate<String, Object> redisTemplate, Utils utils) {
public PayService(RedisTemplate<String, Object> redisTemplate, MpCashierCartService mpCashierCartService, Utils utils) {
this.redisTemplate = redisTemplate;
this.mpCashierCartService = mpCashierCartService;
this.utils = utils;
}
@@ -398,7 +403,10 @@ public class PayService {
reqbody = body.toString();
}
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody,
payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(),
payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode,
DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData();
@@ -664,14 +672,13 @@ public class PayService {
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId());
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", orderInfo.getDiscountRatio());
} else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", null);
}
log.info("更新购物车:{}", cartCount);
return null;
});
@@ -917,7 +924,7 @@ public class PayService {
orderInfo.setMemberId(vipUserId.toString());
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(String.valueOf(orderId), "final");
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId());
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
@@ -925,8 +932,6 @@ public class PayService {
} else {
tbOrderDetailMapper.updateStatusByOrderId(orderId, "closed", null);
}
log.info("更新购物车:{}", cartCount);
return null;
});
@@ -961,6 +966,7 @@ public class PayService {
return Result.success(CodeEnum.SUCCESS);
}
public Result cashPay(String orderId, String token, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM);
@@ -1013,15 +1019,13 @@ public class PayService {
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, Integer.valueOf(orderId));
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", orderInfo.getDiscountRatio());
} else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", null);
}
log.info("更新购物车:{}", cartCount);
return orderInfo;
});

View File

@@ -29,5 +29,12 @@ public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, T
.in(TbCashierCart::getId, cartIds)
.set(TbCashierCart::getStatus, status.getValue()));
}
@Override
public boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId) {
return update(new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getOrderId, orderId)
.set(TbCashierCart::getStatus, status.getValue()));
}
}