| @@ -71,7 +71,7 @@ public class WxMallController extends BaseController { | |||
| @GetMapping("/childMall") | |||
| @SystemControllerLog(description = "商城-当前查询") | |||
| public ResultData childMall() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::childMall"); | |||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||
| if(mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| @@ -204,6 +204,16 @@ public class TtPayUnifiedOrderV2Request implements Serializable { | |||
| @SerializedName(value = "discount_amount") | |||
| private Integer discountAmount; | |||
| /** | |||
| * 否 | |||
| * 折扣金额,单位(分) | |||
| */ | |||
| @SerializedName(value = "merchant_uid") | |||
| private String merchantUid; | |||
| } | |||
| @@ -18,5 +18,4 @@ public interface TtCouponChannelPoiMapper extends CommonMapper<TtCouponChannelPo | |||
| TtCouponChannelPoi selectById(@Param("tenantId")String tenantId,@Param("id")Long id); | |||
| TtCouponChannelPoi selectByChannelId(@Param("tenantId")String tenantId,@Param("couponChannelId")Long couponChannelId); | |||
| } | |||
| @@ -849,7 +849,12 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| @Override | |||
| public ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id) { | |||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectByChannelId(tenantInfo.getTenantId(),id); | |||
| WxCouponChannel couponChannel = this.getById(id, tenantInfo.getTenantId()); | |||
| if(couponChannel == null){ | |||
| return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到可用的数据"); | |||
| } | |||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(), couponChannel.getCouponId()); | |||
| if(ttCouponChannelPoi != null && ttCouponChannelPoi.getLastStatus() != null && ttCouponChannelPoi.getLastStatus().intValue() > 0){ | |||
| return new ResultData(ttCouponChannelPoi); | |||
| } | |||
| @@ -877,9 +882,15 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| @Override | |||
| public ResultData updateOnline(WxCouponChannel wxCouponChannel) { | |||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectByChannelId(wxCouponChannel.getTenantId(),wxCouponChannel.getId()); | |||
| WxCouponChannel couponChannel = this.getById(wxCouponChannel.getId(), wxCouponChannel.getTenantId()); | |||
| if(couponChannel == null){ | |||
| return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到可用的数据"); | |||
| } | |||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(couponChannel.getTenantId(), couponChannel.getCouponId()); | |||
| if(ttCouponChannelPoi == null || EnumSpuSyncStatus.sync_auditing.getCode().equals(ttCouponChannelPoi.getLastStatus()) | |||
| || EnumSpuSyncStatus.sync_audit_rejection.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | |||
| || EnumSpuSyncStatus.sync_audit_rejection.getCode().equals(ttCouponChannelPoi.getLastStatus()) | |||
| || EnumSpuSyncStatus.sync_audit_disable.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); | |||
| } | |||
| Date date = new Date(); | |||
| @@ -3379,6 +3379,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| WxOrder order = new WxOrder(); | |||
| order.updateTenantInfo(coupon); | |||
| order.setOrderGroupId(group.getId()); | |||
| order.setCUserId(user.getId()); | |||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | |||
| @@ -3659,9 +3660,8 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| return new ResultData(composeOrder); | |||
| } else { | |||
| //todo 暂无多订单模式 | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "数据异常"); | |||
| } | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "数据异常"); | |||
| // List<WxOrder> childOrders = orderAdapterService.getChildOrders(composeOrder, tenantEntity.getTenantId()); | |||
| // Map<Long, List<WxOrder>> collect = childOrders.stream().collect(groupingBy(WxOrder::getCouponChannelId)); | |||
| @@ -419,16 +419,22 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| //设置子订单分账金额 | |||
| Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | |||
| for (WxOrder o : childOrders) { | |||
| Long merchant_id = 0L; | |||
| Long merchant_id = 0l; | |||
| String merchant_uid = ""; | |||
| if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 | |||
| merchant_id = o.getMakeMerchantId(); | |||
| if(merchant_id == null || merchant_id.equals(0l)){ | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); | |||
| } | |||
| PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); | |||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); | |||
| if(receiver == null){ | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); | |||
| } | |||
| merchant_uid = receiver.getReceiverAccount(); | |||
| if(StringUtils.isBlank(merchant_uid)){ | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); | |||
| } | |||
| } | |||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(o.getId(),o.getPayment(),merchant_id,merchant_uid)); | |||
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| @@ -20,6 +21,7 @@ import com.iformall.mapper.*; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.service.order.OrderAdapterService; | |||
| import com.iformall.service.order.OrderFactory; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.service.order.entity.WxComposeOrder; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.CDrivingPayService; | |||
| @@ -112,19 +114,25 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(record.getComposeOrder()); | |||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | |||
| Map<Long, List<WxOrder>> collect = orderList.stream().collect(groupingBy(WxOrder::getCouponChannelId)); | |||
| Map<String, List<WxOrder>> goodsCollect = new HashMap<>(); | |||
| for (Long key: collect.keySet()) { | |||
| TtPayUnifiedOrderV2Request.Good good = new TtPayUnifiedOrderV2Request.Good(); | |||
| good.setQuantity(collect.get(key).size()); | |||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectByChannelId(appInfo.getTenantId(), key); | |||
| good.setGoodsId(ttCouponChannelPoi.getSpuId()); | |||
| good.setGoodsIdType(1);//poi商品固定传1 | |||
| goods.add(good); | |||
| goodsCollect.put(good.getGoodsId(),collect.get(key)); | |||
| if(orderList.size() > 1){ | |||
| //todo 暂无多订单 | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"数据异常"); | |||
| } | |||
| WxOrder order = orderList.get(0); | |||
| TtPayUnifiedOrderV2Request.Good good = new TtPayUnifiedOrderV2Request.Good(); | |||
| good.setQuantity(order.getCouponNumber()); | |||
| WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(order.getCouponChannelId(), order.getTenantId()); | |||
| good.setGoodsId(couponChannel.getTtSpuId()); | |||
| good.setGoodsIdType(1);//poi商品固定传1 | |||
| if (EnumPayMchType.DIRECT.getCode().equals(record.getMchType())) { | |||
| WxComposeChildOrderShare childOrderShare = record.getChildOrderShare(order.getId()); | |||
| good.setMerchantUid(childOrderShare.getMerchantUid()); | |||
| } | |||
| goods.add(good); | |||
| request.setGoodsList(goods); | |||
| request.setTotalAmount(composeOrder.getPayment()); | |||
| request.setOpenId(openId); | |||
| @@ -143,6 +151,14 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| TtPayUnifiedOrderV2Result orderV2 = ttPayService.createOrderV2(request); | |||
| if(orderV2.getItemOrderInfoList().size() > 1){ | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"数据异常"); | |||
| } | |||
| TtPayUnifiedOrderV2Result.ItemOrderInfo itemOrderInfo = orderV2.getItemOrderInfoList().get(0); | |||
| if(itemOrderInfo.getItemOrderDetail().size() > 1){ | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"数据异常"); | |||
| } | |||
| JSONObject allExtParam = new JSONObject(); | |||
| allExtParam.put("order_id",orderV2.getOrderId()); | |||
| allExtParam.put("total_amount",composeOrder.getPayment()); | |||
| @@ -153,26 +169,12 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| batchOrder.setExtParam(JSON.toJSONString(allExtParam)); | |||
| wxBatchOrderMapper.updateById(batchOrder); | |||
| for (TtPayUnifiedOrderV2Result.ItemOrderInfo itemOrderInfo:orderV2.getItemOrderInfoList()) { | |||
| List<WxOrder> wxOrders = goodsCollect.get(itemOrderInfo.getGoodsId()); | |||
| if(itemOrderInfo.getItemOrderDetail().size() == wxOrders.size()){ | |||
| for(int i=0;i<wxOrders.size();i++){ | |||
| WxOrder updOrder = new WxOrder(); | |||
| updOrder.updateTenantInfo(appInfo); | |||
| updOrder.setId(wxOrders.get(i).getId()); | |||
| updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail().get(i))); | |||
| wxOrderMapper.updateById(updOrder); | |||
| } | |||
| // }else if(wxOrders.size() == 1){ | |||
| // WxOrder updOrder = new WxOrder(); | |||
| // updOrder.updateTenantInfo(appInfo); | |||
| // updOrder.setId(wxOrders.get(0).getId()); | |||
| // updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail())); | |||
| // wxOrderMapper.updateById(updOrder); | |||
| }else{ | |||
| throw new Exception("下单数据异常"); | |||
| } | |||
| } | |||
| WxOrder updOrder = new WxOrder(); | |||
| updOrder.updateTenantInfo(order); | |||
| updOrder.setId(order.getId()); | |||
| updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail().get(0))); | |||
| wxOrderMapper.updateById(updOrder); | |||
| orderV2.setItemOrderInfoList(null); | |||
| // record.setPrepayId(orderV2.getPayOrderId()); | |||
| record.setPayParam(JSON.toJSONString(orderV2)); | |||