|
|
|
|
@@ -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;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|