|
|
@@ -3716,7 +3716,90 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
|
|
|
if(order==null){
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
- return R.error("不允许修改支付方式");
|
|
|
+ if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
|
|
|
+ return R.error("订单状态不正确");
|
|
|
+ }
|
|
|
+
|
|
|
+ Object isPaying =redisCache.getCacheObject("isPaying:"+order.getId());
|
|
|
+ if(ObjectUtil.isNotNull(isPaying)){
|
|
|
+ return R.error("正在支付中...");
|
|
|
+ }
|
|
|
+ List<FsStorePayment> payments=fsStorePaymentMapper.selectFsStorePaymentByOrder(order.getId());
|
|
|
+ if(payments.size()>0){
|
|
|
+ for(FsStorePayment payment : payments){
|
|
|
+ if(StringUtils.isEmpty(payment.getTradeNo())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
|
|
|
+ orderQueryDTO.setLowOrderId("store-"+payment.getPayCode());
|
|
|
+ RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
|
|
|
+
|
|
|
+ QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
|
|
|
+
|
|
|
+ queryOrderRestDTO.setOrderFlowNo(payment.getTradeNo());
|
|
|
+ TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
|
|
|
+
|
|
|
+ queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
+
|
|
|
+ requestDTO.setReqBody(queryOrderRestDTO);
|
|
|
+ requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(payment.getPayCode()));
|
|
|
+ try {
|
|
|
+ TzReqResultDTO<QueryOrderInfoDTO> resultDTO = tzBankService.payQueryOrder(requestDTO);
|
|
|
+ if(ObjectUtil.isNotNull(resultDTO)){
|
|
|
+ QueryOrderInfoDTO body = resultDTO.getBody();
|
|
|
+ if(ObjectUtil.isNotNull(body)){
|
|
|
+ if("80".equals(body.getStatus()) || "90".equals(body.getStatus())){
|
|
|
+ // 更新订单状态和支付状态
|
|
|
+// payment.setStatus(1);
|
|
|
+// fsStorePaymentMapper.updateFsStorePayment(payment);
|
|
|
+ orderService.payConfirm(1, order.getId(), payment.getPayCode(),
|
|
|
+ payment.getTradeNo(),
|
|
|
+ body.getChlTrxId(),
|
|
|
+ payment.getTradeNo());
|
|
|
+ return R.error("订单已支付,请刷新页面");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsUser user=userService.selectFsUserById(order.getUserId());
|
|
|
+ if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
|
|
|
+ //已改价处理
|
|
|
+ if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
|
|
|
+ //改过价不做处理
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ String config=configService.selectConfigByKey("store.config");
|
|
|
+ StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
|
|
|
+ if(param.getPayType().equals(1)){
|
|
|
+ order.setPayType("1");
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
+ order.setPayDelivery(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ else if(param.getPayType().equals(2)){
|
|
|
+
|
|
|
+ order.setPayType("2");
|
|
|
+ BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ }
|
|
|
+ else if(param.getPayType().equals(3)){
|
|
|
+ //货到付款
|
|
|
+ order.setPayType("3");
|
|
|
+ order.setPayDelivery(order.getPayPrice() );
|
|
|
+ order.setPayMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ orderService.updateFsStoreOrder(order);
|
|
|
+ }
|
|
|
+ return R.ok().put("order",order);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return R.error("用户OPENID不存在");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -3848,13 +3931,13 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
|
|
|
*/
|
|
|
private R validatePayTypeNotModified(FsStoreOrder order, Integer requestPayType) {
|
|
|
if (requestPayType == null) {
|
|
|
- return R.error("支付方式不能为空");
|
|
|
+ return R.error("支付类型不能为空");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(order.getPayType())) {
|
|
|
- return R.error("订单支付方式异常");
|
|
|
+ return R.error("订单支付类型异常");
|
|
|
}
|
|
|
if (!Objects.equals(String.valueOf(requestPayType), order.getPayType())) {
|
|
|
- return R.error("不允许修改支付方式");
|
|
|
+ return R.error("不允许修改支付类型");
|
|
|
}
|
|
|
return null;
|
|
|
}
|