| @@ -113,10 +113,10 @@ public class WxCouponOrderController extends BaseController { | |||||
| wxRefundOrderService.createRefundOrder(appinfo, couponOrderId, EnumPayType.PAY_ADMIN_REFUND, null); | wxRefundOrderService.createRefundOrder(appinfo, couponOrderId, EnumPayType.PAY_ADMIN_REFUND, null); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR); | return new ResultData(ErrorCode.REFUND_ORDER_ERROR); | ||||
| } | } | ||||
| } | } | ||||
| @@ -136,10 +136,10 @@ public class WxPayOrderController extends BaseController { | |||||
| record.setComposeOrder(Integer.parseInt(composeOrderType)); | record.setComposeOrder(Integer.parseInt(composeOrderType)); | ||||
| return wxPayOrderService.createPayOrder(appInfo, wxCUserBasicInfo, record, payWay,parm); | return wxPayOrderService.createPayOrder(appInfo, wxCUserBasicInfo, record, payWay,parm); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage()); | |||||
| logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage(),e); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("payment wechat, order create error, req 3: " + record.toString() + ", e:" + e.getMessage()); | |||||
| logger.error("payment wechat, order create error, req 3: " + record.toString() + ", e:" + e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, e.getMessage()); | return new ResultData(ErrorCode.PAY_ORDER_ERROR, e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -229,10 +229,10 @@ public class WxPayOrderController extends BaseController { | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "支付状态更新成功"); | return new ResultData(Result.SUCCESS, "支付状态更新成功"); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("支付状态更新失败2: " + payOrder.toString() + ", e:" + e.getMessage()); | |||||
| logger.error("支付状态更新失败2: " + payOrder.toString() + ", e:" + e.getMessage(),e); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | |||||
| logger.error("支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | return new ResultData(ErrorCode.PAY_ORDER_ERROR, "支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -12,6 +12,8 @@ import lombok.ToString; | |||||
| import java.util.*; | import java.util.*; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| @TableName(value = "wx_pay_order") | @TableName(value = "wx_pay_order") | ||||
| @Data | @Data | ||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| @@ -60,6 +62,9 @@ public class WxPayOrder extends TenantEntity { | |||||
| private String childOrderShare; | private String childOrderShare; | ||||
| public WxComposeChildOrderShare getChildOrderShare(Long wxOrderId) { | public WxComposeChildOrderShare getChildOrderShare(Long wxOrderId) { | ||||
| if (StringUtils.isBlank(this.childOrderShare)) { | |||||
| return new WxComposeChildOrderShare(this.payAmount, this.shareAmount, this.rateAmount); | |||||
| } | |||||
| Map childs = JSON.parseObject(this.childOrderShare, Map.class); | Map childs = JSON.parseObject(this.childOrderShare, Map.class); | ||||
| JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId)); | JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId)); | ||||
| if (null != childOrderShare) { | if (null != childOrderShare) { | ||||
| @@ -1530,15 +1530,17 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | ||||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); | OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); | ||||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | ||||
| for (WxOrder o : orderList) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| WxComposeChildOrderPrice price = orderAdapterService.getChildOrderPrice(coupon, false, o.getOrderGroupId(), o.getCouponNumber()); | |||||
| int orderMallCharge = OrderHelper.getMallCharge(price.getRealPayMent(), payAccount); | |||||
| Integer orderShareAmount = price.getRealPayMent() - orderMallCharge; | |||||
| Integer orderRateAmount = PayUtils.getPayRate(price.getRealPayMent(), payAccount.getRealRate(), true); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(price.getRealPayMent(), orderShareAmount, orderRateAmount)); | |||||
| if (null != orderList && orderList.size() > 0) { | |||||
| for (WxOrder o : orderList) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| WxComposeChildOrderPrice price = orderAdapterService.getChildOrderPrice(coupon, false, o.getOrderGroupId(), o.getCouponNumber()); | |||||
| int orderMallCharge = OrderHelper.getMallCharge(price.getRealPayMent(), payAccount); | |||||
| Integer orderShareAmount = price.getRealPayMent() - orderMallCharge; | |||||
| Integer orderRateAmount = PayUtils.getPayRate(price.getRealPayMent(), payAccount.getRealRate(), true); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(price.getRealPayMent(), orderShareAmount, orderRateAmount)); | |||||
| } | |||||
| payOrder.setChildOrderShare(JSON.toJSONString(childShares)); | |||||
| } | } | ||||
| payOrder.setChildOrderShare(JSON.toJSONString(childShares)); | |||||
| } | } | ||||
| payOrder.setPayFrom(EnumPayFrom.INSIDE_B.getCode()); | payOrder.setPayFrom(EnumPayFrom.INSIDE_B.getCode()); | ||||
| payOrder.setPosPayOrderId(couponOrder.getId()); | payOrder.setPosPayOrderId(couponOrder.getId()); | ||||
| @@ -388,15 +388,17 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | ||||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); | OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); | ||||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | ||||
| for (WxOrder o : orderList) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| WxComposeChildOrderPrice price = orderAdapterService.getChildOrderPrice(coupon, false, o.getOrderGroupId(), o.getCouponNumber()); | |||||
| int orderMallCharge = OrderHelper.getMallCharge(price.getRealPayMent(), payAccount); | |||||
| Integer orderShareAmount = price.getRealPayMent() - orderMallCharge; | |||||
| Integer orderRateAmount = OrderHelper.getRateAmount(price.getRealPayMent(),orderMallCharge, payAccount); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(price.getRealPayMent(), orderShareAmount, orderRateAmount)); | |||||
| if(null != orderList && orderList.size() > 0) { | |||||
| for (WxOrder o : orderList) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| WxComposeChildOrderPrice price = orderAdapterService.getChildOrderPrice(coupon, false, o.getOrderGroupId(), o.getCouponNumber()); | |||||
| int orderMallCharge = OrderHelper.getMallCharge(price.getRealPayMent(), payAccount); | |||||
| Integer orderShareAmount = price.getRealPayMent() - orderMallCharge; | |||||
| Integer orderRateAmount = OrderHelper.getRateAmount(price.getRealPayMent(),orderMallCharge, payAccount); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(price.getRealPayMent(), orderShareAmount, orderRateAmount)); | |||||
| } | |||||
| record.setChildOrderShare(JSON.toJSONString(childShares)); | |||||
| } | } | ||||
| record.setChildOrderShare(JSON.toJSONString(childShares)); | |||||
| } | } | ||||
| int sqlRow = wxPayOrderMapper.insert(record); | int sqlRow = wxPayOrderMapper.insert(record); | ||||
| @@ -508,15 +510,17 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | ||||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); | OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); | ||||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | ||||
| for (WxOrder o : orderList) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| WxComposeChildOrderPrice price = orderAdapterService.getChildOrderPrice(coupon, false, o.getOrderGroupId(), o.getCouponNumber()); | |||||
| int orderMallCharge = OrderHelper.getMallCharge(price.getRealPayMent(), payAccount); | |||||
| Integer orderShareAmount = price.getRealPayMent() - orderMallCharge; | |||||
| Integer orderRateAmount = PayUtils.getPayRate(price.getRealPayMent(), payAccount.getRealRate(), true); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(price.getRealPayMent(), orderShareAmount, orderRateAmount)); | |||||
| if (null != orderList && orderList.size() > 0 ) { | |||||
| for (WxOrder o : orderList) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| WxComposeChildOrderPrice price = orderAdapterService.getChildOrderPrice(coupon, false, o.getOrderGroupId(), o.getCouponNumber()); | |||||
| int orderMallCharge = OrderHelper.getMallCharge(price.getRealPayMent(), payAccount); | |||||
| Integer orderShareAmount = price.getRealPayMent() - orderMallCharge; | |||||
| Integer orderRateAmount = PayUtils.getPayRate(price.getRealPayMent(), payAccount.getRealRate(), true); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(price.getRealPayMent(), orderShareAmount, orderRateAmount)); | |||||
| } | |||||
| record.setChildOrderShare(JSON.toJSONString(childShares)); | |||||
| } | } | ||||
| record.setChildOrderShare(JSON.toJSONString(childShares)); | |||||
| } | } | ||||
| int sqlRow = wxPayOrderMapper.insert(record); | int sqlRow = wxPayOrderMapper.insert(record); | ||||
| @@ -222,6 +222,9 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| rOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | rOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | ||||
| rOrder.setCreateDate(currentDate); | rOrder.setCreateDate(currentDate); | ||||
| rOrder.setUpdateDate(currentDate); | rOrder.setUpdateDate(currentDate); | ||||
| rOrder.setComposeOrderId(wxOrder.getComposeOrderId()); | |||||
| rOrder.setComposeOrderType(wxOrder.getComposeOrderType()); | |||||
| rOrder.setCouponNumber(wxOrder.getCouponNumber()); | |||||
| try { | try { | ||||
| wxOrderMapper.insert(rOrder); | wxOrderMapper.insert(rOrder); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -278,7 +281,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| record.setTransactionId(payOrder.getTransactionId()); | record.setTransactionId(payOrder.getTransactionId()); | ||||
| record.setCUserId(payOrder.getCUserId()); | record.setCUserId(payOrder.getCUserId()); | ||||
| record.setTotalFee(payOrder.getPayAmount()); | record.setTotalFee(payOrder.getPayAmount()); | ||||
| record.setRefundFee(payOrder.getChildOrderShare(rOrder.getId()).getRealPayMent()); | |||||
| record.setRefundFee(payOrder.getChildOrderShare(wxOrder.getId()).getRealPayMent()); | |||||
| record.setRefundTimeStart(currentDate); | record.setRefundTimeStart(currentDate); | ||||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_WAIT.getCode()); | record.setRefundOrderStatus(EnumRefundStatus.REFUND_WAIT.getCode()); | ||||
| record.setRefundVendor(payOrder.getPayVendor()); | record.setRefundVendor(payOrder.getPayVendor()); | ||||
| @@ -52,9 +52,9 @@ public class SingleOrderAdapterService implements OrderAdapterService { | |||||
| @Override | @Override | ||||
| public List<WxOrder> getChildOrders(WxComposeOrder composeOrder, String tenantId) { | public List<WxOrder> getChildOrders(WxComposeOrder composeOrder, String tenantId) { | ||||
| List<WxOrder> list = new ArrayList<WxOrder>(); | |||||
| list.add(composeOrder.getSingleOrder()); | |||||
| return list; | |||||
| List<WxOrder> childOrders = new ArrayList<WxOrder>(); | |||||
| childOrders.add(composeOrder.getSingleOrder()); | |||||
| return childOrders; | |||||
| } | } | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||