| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| @@ -52,6 +53,29 @@ public class WxCouponOrderReservationController extends BaseController { | |||
| return new ResultData(reservation); | |||
| } | |||
| @ApiOperation(value = "") | |||
| @PostMapping("update") | |||
| @ApiImplicitParams({ | |||
| }) | |||
| public ResultData update(@RequestBody WxCouponOrderReservation reservation) { | |||
| if(reservation.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| reservation.updateTenantInfo(getTenantInfo()); | |||
| WxCouponOrderReservation sortReservation = wxCouponOrderReservationService.getSortById(reservation.getId(), reservation.getTenantId()); | |||
| if(sortReservation == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"id is error"); | |||
| } | |||
| if(EnumCouponOrderReservationStatus.getReservationIng().contains(sortReservation.getStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单进行中"); | |||
| } | |||
| if(EnumCouponOrderReservationStatus.getReservationFinish().contains(sortReservation.getStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单已完成"); | |||
| } | |||
| reservation.setRemark("A用户"+getUser().getUsername()+"修改信息"); | |||
| return wxCouponOrderReservationService.saveOrUpdate(reservation); | |||
| } | |||
| @ApiOperation(value = "修改状态") | |||
| @PostMapping("updateStatus") | |||
| @ApiImplicitParams({ | |||
| @@ -81,6 +105,7 @@ public class WxCouponOrderReservationController extends BaseController { | |||
| updReservation.setId(reservation.getId()); | |||
| updReservation.setStatus(reservation.getStatus()); | |||
| updReservation.setRemark(reservation.getRemark()); | |||
| updReservation.setRemark("A用户"+getUser().getUsername()+"修改状态"); | |||
| wxCouponOrderReservationService.saveOrUpdate(updReservation); | |||
| return new ResultData(); | |||
| } | |||
| @@ -52,6 +52,29 @@ public class WxCouponOrderReservationController extends BaseController { | |||
| return new ResultData(reservation); | |||
| } | |||
| @ApiOperation(value = "") | |||
| @PostMapping("update") | |||
| @ApiImplicitParams({ | |||
| }) | |||
| public ResultData update(@RequestBody WxCouponOrderReservation reservation) { | |||
| if(reservation.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| reservation.updateTenantInfo(getTenantInfo()); | |||
| WxCouponOrderReservation sortReservation = wxCouponOrderReservationService.getSortById(reservation.getId(), reservation.getTenantId()); | |||
| if(sortReservation == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"id is error"); | |||
| } | |||
| if(EnumCouponOrderReservationStatus.getReservationIng().contains(sortReservation.getStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单进行中"); | |||
| } | |||
| if(EnumCouponOrderReservationStatus.getReservationFinish().contains(sortReservation.getStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单已完成"); | |||
| } | |||
| return wxCouponOrderReservationService.saveOrUpdate(reservation); | |||
| } | |||
| @ApiOperation(value = "修改状态") | |||
| @PostMapping("updateStatus") | |||
| @ApiImplicitParams({ | |||
| @@ -200,8 +200,8 @@ public class WxOrderController extends BaseController { | |||
| return map; | |||
| } | |||
| Map<String,String> couponMap = JSONObject.parseObject(cp_extra, Map.class); | |||
| String idstr = couponMap.get("composeOrderId"); | |||
| composeOrderId = Long.parseLong(idstr); | |||
| String composeOrderIdStr = couponMap.get("composeOrderId"); | |||
| composeOrderId = Long.parseLong(composeOrderIdStr); | |||
| tenantId = couponMap.get("tenantId"); | |||
| }catch(Exception e){ | |||
| } | |||
| @@ -25,4 +25,6 @@ public class OrderComposeSaveDto implements Serializable { | |||
| WxCouponChannel wxCouponChannel; | |||
| String extParam; | |||
| } | |||
| @@ -19,6 +19,8 @@ public class OrderSaveDto implements Serializable { | |||
| private String formId; | |||
| private Long fixMerchantId; | |||
| //被操作人的ID 供A端使用 | |||
| private Long userId; | |||
| @@ -166,11 +166,17 @@ public class WxMerchant extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "联系方式", name = "phone") | |||
| private String phone; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "券名ID", name = "couponId") | |||
| private Long couponId; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "券名称", name = "couponName") | |||
| private String couponName; | |||
| public String getShopsStr() { | |||
| if (shopVos != null && shopVos.size() > 0) { | |||
| return String.join("\n", | |||
| @@ -138,16 +138,21 @@ public class WxOrder extends TenantEntity { | |||
| private String fromId; | |||
| public Object getExpParamValue(String key) { | |||
| if (StringUtils.isBlank(extParam)) { | |||
| JSONObject extParamJson = getExtParamJson(); | |||
| if (extParamJson == null) { | |||
| return null; | |||
| } | |||
| JSONObject o = JSON.parseObject(extParam); | |||
| if (null == o ) { | |||
| return extParamJson.get(key); | |||
| } | |||
| public JSONObject getExtParamJson() { | |||
| if (StringUtils.isBlank(extParam)) { | |||
| return null; | |||
| } | |||
| return o.get(key); | |||
| return JSON.parseObject(extParam); | |||
| } | |||
| @TableField(exist = false) | |||
| protected List<Long> couponIds; | |||
| @@ -9,6 +9,7 @@ import java.util.List; | |||
| public enum EnumCouponOrderReservationStatus { | |||
| // | |||
| reservation_create_order(-1, "下单"), | |||
| reservation(0, "预约"), | |||
| reservation_user_cancellation(1, "用户取消"), | |||
| reservation_expire_cancellation(2, "过期取消"), | |||
| @@ -269,6 +269,7 @@ public interface WxOrderService { | |||
| int updateCpsStatus(WxOrder order); | |||
| ResultData handlerPushOrder(TenantEntity tenantEntity, Long composeOrderId, String batchExtParam, List<CreateOrderCallback.Good> goods); | |||
| ResultData handlerPushOrder(TenantEntity tenantEntity, Long composeOrderId, String batchExtParam, | |||
| List<CreateOrderCallback.Good> goods); | |||
| } | |||
| @@ -1142,6 +1142,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| } | |||
| private void initQueryParam(WxMerchant record,boolean hasRentContractInfo,Map<Long,WxRentContract> merchantRentMap) { | |||
| if (hasRentContractInfo) { | |||
| WxRentContract wxRentContractQ = new WxRentContract(); | |||
| wxRentContractQ.updateTenantInfo(record); | |||
| @@ -1173,31 +1174,43 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| // } | |||
| List<Long> merchantIds = new ArrayList<Long>(); | |||
| if (record.getCouponId() != null){ | |||
| List<Long> couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(record.getCouponId(), record.getTenantId()); | |||
| if (null == couponMerchantIds || couponMerchantIds.size() <=0 ) { | |||
| record.setId(-999L); | |||
| return; | |||
| }else { | |||
| merchantIds.addAll(couponMerchantIds); | |||
| } | |||
| } | |||
| String phone = StringUtils.trimToNull(record.getPhone()); | |||
| if (null != phone) { | |||
| WxMerchantBUser buserQ = new WxMerchantBUser(); | |||
| buserQ.setPhoneLike(phone); | |||
| buserQ.setStatus(0); | |||
| List<Long> userMerchantIds = wxMerchantBUserMapper.findMerchantIdList(buserQ); | |||
| if (null == userMerchantIds || userMerchantIds.size() <=0 ) { | |||
| record.setId(-999L); | |||
| return; | |||
| }else { | |||
| merchantIds.addAll(userMerchantIds); | |||
| } | |||
| if (null == userMerchantIds || userMerchantIds.size() <=0 ) { | |||
| record.setId(-999L); | |||
| return; | |||
| } | |||
| if(merchantIds.size() > 0){ | |||
| merchantIds.retainAll(userMerchantIds); | |||
| } | |||
| } | |||
| String floorRule = StringUtils.trimToNull(record.getFloorForRule()); | |||
| Long building = record.getBuilding(); | |||
| Long floor = record.getFloor(); | |||
| List<Long> floorMerchantIds = getFloorBuildMerchantIds(record, floorRule, building, floor, 0, 0); | |||
| if (null != floorMerchantIds) { | |||
| if(merchantIds.size() > 0){ | |||
| merchantIds.retainAll(floorMerchantIds); | |||
| }else{ | |||
| merchantIds.addAll(floorMerchantIds); | |||
| } | |||
| } | |||
| if (null == floorMerchantIds || floorMerchantIds.size() <=0 ) { | |||
| record.setId(-999L); | |||
| return; | |||
| } | |||
| if(merchantIds.size() > 0){ | |||
| merchantIds.retainAll(floorMerchantIds); | |||
| } | |||
| // if(EnumProfitSharingUse.YES.getCode().equals(record.getIsUse())){ | |||
| // if(merchantIds.size() > 0){ | |||
| @@ -245,6 +245,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Lazy | |||
| @Autowired | |||
| private WxOrderServiceHelper wxOrderServiceHelper; | |||
| @Autowired | |||
| private WxCouponOrderReservationMapper wxCouponOrderReservationMapper; | |||
| @Override | |||
| @@ -1495,6 +1498,34 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| wxCouponOrderMapper.insert(couponOrder); | |||
| } | |||
| // | |||
| try{ | |||
| if(EnumCouponType.COUPON_DOUYIN_GO_HOME.getCode().equals(coupon.getType())){ | |||
| Long fixMerchantId = (Long) order.getExpParamValue("fixMerchantId"); | |||
| String fixMerchantName = (String) order.getExpParamValue("fixMerchantName"); | |||
| if(fixMerchantId != null){ | |||
| WxCouponOrderReservation record = new WxCouponOrderReservation(); | |||
| record.setId(couponOrder.getId()); | |||
| record.updateTenantInfo(couponOrder); | |||
| record.setCouponOrderId(couponOrder.getId()); | |||
| record.setCouponId(coupon.getId()); | |||
| record.setCouponTitle(coupon.getTitle()); | |||
| record.setReservationMerchantId(fixMerchantId); | |||
| record.setReservationMerchantName(fixMerchantName); | |||
| record.setcUserId(user.getId()); | |||
| record.setUserName(user.getName()); | |||
| record.setUserPhone(user.getPhone()); | |||
| record.setStatus(EnumCouponOrderReservationStatus.reservation_create_order.getCode()); | |||
| record.setCreateDate(curr); | |||
| record.setUpdateDate(curr); | |||
| wxCouponOrderReservationMapper.insert(record); | |||
| } | |||
| } | |||
| }catch(Exception e){ | |||
| logger.info("添加预约信息error"+e.getMessage()); | |||
| } | |||
| /// 储值卡信息添加 | |||
| if (isCard) { | |||
| Integer fee = 0; | |||
| @@ -3007,19 +3038,19 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| WxOrder lastOrder = null; | |||
| for (int i = 0 ; i < orderSave.size(); i ++) { | |||
| OrderComposeSaveDto orderdto = orderSave.get(i); | |||
| //券一个数量创建一个订单 | |||
| //券一个数量创建一个订单 | |||
| boolean isOneNumberOneOrder = orderAdapterService.isOneNumberOneOrder(); | |||
| if (isOneNumberOneOrder) { | |||
| for (int j = 0; j < orderdto.getCount(); j++) { | |||
| lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), 1, | |||
| orderdto.getSignleOrder().isPressOrder(),orderdto.getSignleOrder().getOrderGroupId(),orderdto.getSignleOrder().getFormId(), | |||
| orderdto.getShippingType(),orderdto.getAddress(),null,orderdto.getWxCouponChannel(), payWay,payVersion); | |||
| orderdto.getShippingType(),orderdto.getAddress(),orderdto.getExtParam(),orderdto.getWxCouponChannel(), payWay,payVersion); | |||
| } | |||
| }else { | |||
| lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), orderdto.getCount(), | |||
| orderdto.getSignleOrder().isPressOrder(),orderdto.getSignleOrder().getOrderGroupId(),orderdto.getSignleOrder().getFormId(), | |||
| orderdto.getShippingType(),orderdto.getAddress(),null,orderdto.getWxCouponChannel(), payWay,payVersion); | |||
| orderdto.getShippingType(),orderdto.getAddress(),orderdto.getExtParam(),orderdto.getWxCouponChannel(), payWay,payVersion); | |||
| } | |||
| } | |||
| //如果没有orderId,则用lastOrder的信息 | |||
| @@ -3233,7 +3264,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| //} | |||
| record.setCouponNumber(couponNumber); | |||
| record.setExtParam(extParam);; | |||
| record.setExtParam(extParam); | |||
| try { | |||
| orderNumber = proxy.saveNoFreeOrder(orderDate,record, user, coupon, isPressOrder); | |||
| } catch (Exception e) { | |||
| @@ -3731,7 +3762,8 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| @Override | |||
| public ResultData handlerPushOrder(TenantEntity tenantEntity, Long composeOrderId, String batchExtParam, List<CreateOrderCallback.Good> goods) { | |||
| public ResultData handlerPushOrder(TenantEntity tenantEntity, Long composeOrderId, String batchExtParam, | |||
| List<CreateOrderCallback.Good> goods) { | |||
| WxBatchOrder wxBatchOrder = this.getWxBatchOrder(tenantEntity, composeOrderId); | |||
| if (wxBatchOrder == null) { | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| @@ -3751,34 +3783,41 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| WxComposeOrder composeOrder = orderAdapterService.getComposeOrder(wxBatchOrder.getId(), tenantEntity.getTenantId()); | |||
| List<Map<String, String>> order_goods_info = new ArrayList<>(); | |||
| if (goods.size() == 1) { | |||
| WxOrder singleOrder = composeOrder.getSingleOrder(); | |||
| CreateOrderCallback.Good good = goods.get(0); | |||
| WxOrder updOrder = new WxOrder(); | |||
| updOrder.updateTenantInfo(tenantEntity); | |||
| updOrder.setId(singleOrder.getId()); | |||
| updOrder.setFromId(good.getPoiId()); | |||
| if (good.getItemOrderInfoList().size() == 1) { | |||
| updOrder.setExtParam(JSON.toJSONString(good.getItemOrderInfoList().get(0))); | |||
| } else { | |||
| updOrder.setExtParam(JSON.toJSONString(good.getItemOrderInfoList())); | |||
| } | |||
| wxOrderMapper.updateById(updOrder); | |||
| if (EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())) { | |||
| Map<String, String> map_info = new HashMap<>(); | |||
| map_info.put("goods_id", good.getGoodsId()); | |||
| WxComposeChildOrderShare childOrderShare = payOrder.getChildOrderShare(singleOrder.getId()); | |||
| map_info.put("merchant_uid", childOrderShare.getMerchantUid()); | |||
| order_goods_info.add(map_info); | |||
| composeOrder.setExtParam(order_goods_info); | |||
| } | |||
| return new ResultData(composeOrder); | |||
| } else { | |||
| if(goods.size() > 1){ | |||
| //todo 暂无多订单模式 | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "商品数据异常"); | |||
| } | |||
| CreateOrderCallback.Good good = goods.get(0); | |||
| if(good.getQuantity() > 1){ | |||
| //todo 暂无多订单模式 | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "数据异常"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "商品数据异常"); | |||
| } | |||
| CreateOrderCallback.ItemOrderInfo itemOrderInfo = good.getItemOrderInfoList().get(0); | |||
| WxOrder singleOrder = composeOrder.getSingleOrder(); | |||
| JSONObject extParamJson = singleOrder.getExtParamJson(); | |||
| if(extParamJson == null){ | |||
| extParamJson = new JSONObject(); | |||
| } | |||
| extParamJson.put("itemOrderId",itemOrderInfo.getItemOrderId()); | |||
| extParamJson.put("price",itemOrderInfo.getPrice()); | |||
| WxOrder updOrder = new WxOrder(); | |||
| updOrder.updateTenantInfo(tenantEntity); | |||
| updOrder.setId(singleOrder.getId()); | |||
| updOrder.setFromId(good.getPoiId()); | |||
| updOrder.setExtParam(extParamJson.toJSONString()); | |||
| wxOrderMapper.updateById(updOrder); | |||
| if (EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())) { | |||
| Map<String, String> map_info = new HashMap<>(); | |||
| map_info.put("goods_id", good.getGoodsId()); | |||
| WxComposeChildOrderShare childOrderShare = payOrder.getChildOrderShare(singleOrder.getId()); | |||
| map_info.put("merchant_uid", childOrderShare.getMerchantUid()); | |||
| order_goods_info.add(map_info); | |||
| composeOrder.setExtParam(order_goods_info); | |||
| } | |||
| return new ResultData(composeOrder); | |||
| // List<WxOrder> childOrders = orderAdapterService.getChildOrders(composeOrder, tenantEntity.getTenantId()); | |||
| // Map<Long, List<WxOrder>> collect = childOrders.stream().collect(groupingBy(WxOrder::getCouponChannelId)); | |||
| @@ -3875,6 +3914,23 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| orderComposeSaveDto.getSignleOrder().setCouponId(coupon.getId()); | |||
| orderComposeSaveDto.setWxCoupon(coupon); | |||
| //判断预约商户 | |||
| Long fixMerchantId = orderComposeSaveDto.getSignleOrder().getFixMerchantId(); | |||
| if(fixMerchantId != null){ | |||
| List<Long> couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), coupon.getTenantId()); | |||
| if(!couponMerchantIds.contains(fixMerchantId)){ | |||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_EQUAL.getCode(),premsg+"预约商户不匹配"); | |||
| } | |||
| WxMerchant merchant = wxMerchantMapper.selectById(fixMerchantId); | |||
| if(merchant == null){ | |||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),premsg+"预约商户未找到"); | |||
| } | |||
| JSONObject extJson = new JSONObject(); | |||
| extJson.put("fixMerchantId",fixMerchantId); | |||
| extJson.put("fixMerchantName",merchant.getName()); | |||
| orderComposeSaveDto.setExtParam(extJson.toJSONString()); | |||
| } | |||
| //判断是否是拼团订单,如果是拼团订单,判断现在进行中的,和已完成的数量是否超出券的限制 | |||
| if (coupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode())) { | |||
| @@ -71,111 +71,109 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName,WxAppinfo appInfo,Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| //抖音支付1.0,已经不再支持 | |||
| if(true){ | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_ERROR.getCode(),"请升级抖音版本"); | |||
| } | |||
| //todo 去掉抖音低版本兼容 | |||
| if(!record.isCreatPay()){ | |||
| if(StringUtils.isBlank(record.getPayParam())){ | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_ERROR.getCode(),"请升级抖音版本"); | |||
| } | |||
| record.setUpdateTime(new Date()); | |||
| PayAdapterResult par = new PayAdapterResult(); | |||
| par.setSuccess(true); | |||
| par.setTransactionId(record.getTransactionId()); | |||
| par.setData(JSONObject.parseObject(record.getPayParam())); | |||
| return par; | |||
| } | |||
| if (null == params ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| String openId = (String) params.getValue("openId"); | |||
| if (StringUtils.isBlank(openId) ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| // throw new Exception("请升级抖音版本"); | |||
| // 新下单接口 | |||
| TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | |||
| TtPayUnifiedOrderV2Request request = new TtPayUnifiedOrderV2Request(); | |||
| List<TtPayUnifiedOrderV2Request.Good> goods = new ArrayList<>(); | |||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(record.getComposeOrder()); | |||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | |||
| if(orderList.size() > 1){ | |||
| //todo 暂无多订单 | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"数据异常"); | |||
| } | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_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); | |||
| request.setOutOrderNo(record.getPayOrderNo()); | |||
| request.setPayExpireSeconds(14*60); | |||
| TtPayUnifiedOrderV2Request.PageEntry pageEntry = new TtPayUnifiedOrderV2Request.PageEntry(); | |||
| pageEntry.setPath(Constant.mainPageUrl); | |||
| Map<String,String> paramMap = new HashMap<>(); | |||
| paramMap.put("type","dt"); | |||
| paramMap.put("tenantId",composeOrder.getTenantId()); | |||
| paramMap.put("orderId",composeOrder.getMainOrderId().toString()); | |||
| pageEntry.setParams(JSON.toJSONString(paramMap)); | |||
| request.setOrderEntrySchema(pageEntry); | |||
| request.setCpExtra(getCallbackData(record)); | |||
| 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()); | |||
| allExtParam.put("open_id",openId); | |||
| WxBatchOrder batchOrder = new WxBatchOrder(); | |||
| batchOrder.updateTenantInfo(appInfo); | |||
| batchOrder.setId(composeOrder.getMainOrderId()); | |||
| batchOrder.setExtParam(JSON.toJSONString(allExtParam)); | |||
| wxBatchOrderMapper.updateById(batchOrder); | |||
| 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)); | |||
| record.setTransactionId(orderV2.getOrderId()); | |||
| record.setUpdateTime(new Date()); | |||
| PayAdapterResult par = new PayAdapterResult(); | |||
| par.setSuccess(true); | |||
| par.setTransactionId(orderV2.getOrderId()); | |||
| par.setData(orderV2); | |||
| return par; | |||
| // //todo 去掉抖音低版本兼容 | |||
| // if(!record.isCreatPay()){ | |||
| // if(StringUtils.isBlank(record.getPayParam())){ | |||
| // throw new MallinkException(ErrorCode.SYS_AUTH_ERROR.getCode(),"请升级抖音版本"); | |||
| // } | |||
| // record.setUpdateTime(new Date()); | |||
| // PayAdapterResult par = new PayAdapterResult(); | |||
| // par.setSuccess(true); | |||
| // par.setTransactionId(record.getTransactionId()); | |||
| // par.setData(JSONObject.parseObject(record.getPayParam())); | |||
| // return par; | |||
| // } | |||
| // if (null == params ) { | |||
| // throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| // } | |||
| // String openId = (String) params.getValue("openId"); | |||
| // if (StringUtils.isBlank(openId) ) { | |||
| // throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| // } | |||
| // | |||
| //// throw new Exception("请升级抖音版本"); | |||
| // | |||
| // // 新下单接口 | |||
| // TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | |||
| // TtPayUnifiedOrderV2Request request = new TtPayUnifiedOrderV2Request(); | |||
| // List<TtPayUnifiedOrderV2Request.Good> goods = new ArrayList<>(); | |||
| // | |||
| // OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(record.getComposeOrder()); | |||
| // List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | |||
| // | |||
| // 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); | |||
| // request.setOutOrderNo(record.getPayOrderNo()); | |||
| // request.setPayExpireSeconds(14*60); | |||
| // TtPayUnifiedOrderV2Request.PageEntry pageEntry = new TtPayUnifiedOrderV2Request.PageEntry(); | |||
| // pageEntry.setPath(Constant.mainPageUrl); | |||
| // Map<String,String> paramMap = new HashMap<>(); | |||
| // paramMap.put("type","dt"); | |||
| // paramMap.put("tenantId",composeOrder.getTenantId()); | |||
| // paramMap.put("orderId",composeOrder.getMainOrderId().toString()); | |||
| // pageEntry.setParams(JSON.toJSONString(paramMap)); | |||
| // request.setOrderEntrySchema(pageEntry); | |||
| // | |||
| // request.setCpExtra(getCallbackData(record)); | |||
| // | |||
| // 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()); | |||
| // allExtParam.put("open_id",openId); | |||
| // WxBatchOrder batchOrder = new WxBatchOrder(); | |||
| // batchOrder.updateTenantInfo(appInfo); | |||
| // batchOrder.setId(composeOrder.getMainOrderId()); | |||
| // batchOrder.setExtParam(JSON.toJSONString(allExtParam)); | |||
| // wxBatchOrderMapper.updateById(batchOrder); | |||
| // | |||
| // 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)); | |||
| // record.setTransactionId(orderV2.getOrderId()); | |||
| // record.setUpdateTime(new Date()); | |||
| // | |||
| // PayAdapterResult par = new PayAdapterResult(); | |||
| // par.setSuccess(true); | |||
| // par.setTransactionId(orderV2.getOrderId()); | |||
| // par.setData(orderV2); | |||
| // return par; | |||
| // | |||
| // | |||