| @@ -104,3 +104,11 @@ CREATE TABLE tt_buser LIKE wx_buser; | |||
| update wx_buser set expire_time = now(); | |||
| ALTER TABLE `wx_buser` | |||
| MODIFY COLUMN `open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信openId' AFTER `parent_tenant_id`, | |||
| MODIFY COLUMN `union_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信unionId' AFTER `open_id`; | |||
| ALTER TABLE `tt_buser` | |||
| MODIFY COLUMN `open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信openId' AFTER `parent_tenant_id`, | |||
| MODIFY COLUMN `union_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信unionId' AFTER `open_id`; | |||
| @@ -0,0 +1,14 @@ | |||
| wx_order | |||
| type = 10 pay_vendor = 11 | |||
| type = 1 pay_vendor = 12 | |||
| type = 3 pay_vendor = 13 | |||
| type = 4 pay_vendor = 1 | |||
| type = 0 pay_vendor = 1??? | |||
| ALTER TABLE `mallink`.`wx_order_0` | |||
| ADD COLUMN `pay_vendor` smallint(3) COMMENT '订单渠道,EnumPayWay.class' AFTER `type`; | |||
| @@ -8,6 +8,7 @@ import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCUser; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| @@ -159,6 +160,16 @@ public class BaseController { | |||
| } | |||
| return user; | |||
| } | |||
| public EnumPayWay getPayWay(){ | |||
| EnumAppPlat appPlat = getCUser().getAppPlat(); | |||
| if(EnumAppPlat.WX.equals(appPlat)){ | |||
| return EnumPayWay.PAY_WAY_WECHAT; | |||
| }else if (EnumAppPlat.TOUTIAO.equals(appPlat)){ | |||
| return EnumPayWay.PAY_WAY_TT; | |||
| } | |||
| return null; | |||
| } | |||
| public void removeCacheCUser() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| @@ -62,6 +62,7 @@ public class WxOrderController extends BaseController { | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| //券包下单的逻辑和组合下单的逻辑差不错,但是库存走的是券包的库存,子订单的分账需要调用多次分账 | |||
| @ApiOperation(value = "券包下单,", notes = "[{\"signleOrder\":{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"},\"count\":8},]") | |||
| @PostMapping("couponPackageSave") | |||
| @@ -115,7 +116,7 @@ public class WxOrderController extends BaseController { | |||
| dto.setSignleOrder(orderSaveDto); | |||
| dto.setCount(1); | |||
| list.add(dto); | |||
| return wxOrderService.composeSaveOrder(false,EnumComposeOrder.SINGLE,list,memberId,EnumPayWay.PAY_WAY_WECHAT,getTenantInfo()); | |||
| return wxOrderService.composeSaveOrder(false,EnumComposeOrder.SINGLE,list,memberId,getPayWay(),getTenantInfo()); | |||
| } | |||
| @ApiOperation(value = "取消订单", notes = "{\"orderId\":\"string\"}") | |||
| @@ -100,7 +100,7 @@ public class WxPayOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.USER_IS_NOT_MEMBER.getCode(), "暂未成为会员,请授权手机号"); | |||
| } | |||
| return _create(orderIdStr,composeOrderType,user.getUserId(),EnumPayWay.PAY_WAY_WECHAT,user.getAppId(),new PayExtraParam("openId",user.getOpenId()),request); | |||
| return _create(orderIdStr,composeOrderType,user.getUserId(),getPayWay(),user.getAppId(),new PayExtraParam("openId",user.getOpenId()),request); | |||
| } | |||
| private ResultData _create(String orderIdStr,String composeOrderType,Long userId, EnumPayWay payWay,String appId,PayExtraParam parm,HttpServletRequest request) { | |||
| @@ -2485,6 +2485,7 @@ public class PosServiceImpl implements PosService { | |||
| order.updateTenantInfo(merchantBUser); | |||
| order.setOrderNumber(orderId); | |||
| order.setType(EnumOrderType.POSPAY.getCode()); | |||
| order.setPayVendor(EnumPayWay.PAY_WAY_POS_NEU.getCode()); | |||
| order.setProductId(merchantBUser.getId()); | |||
| order.setCUserId(memId); | |||
| order.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| @@ -2567,6 +2568,7 @@ public class PosServiceImpl implements PosService { | |||
| order.setId(orderId); | |||
| order.updateTenantInfo(buUser); | |||
| order.setType(EnumOrderType.POSPAY.getCode()); | |||
| order.setPayVendor(EnumPayWay.PAY_WAY_POS_NEU.getCode()); | |||
| order.setProductId(buUser.getId()); | |||
| order.setCUserId(memId); | |||
| order.setPaymentType(EnumPayType.PAY_POS_REFUND.getCode()); | |||
| @@ -52,6 +52,8 @@ public class WxOrder extends TenantEntity { | |||
| private Long productId; | |||
| @io.swagger.annotations.ApiModelProperty(value="类型(0:券,1:B刷卡支付,2:C扫码支付,3:储值卡, 10:POS支付)",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付渠道EnumPayWay", name = "payVendor") | |||
| private Integer payVendor; | |||
| @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") | |||
| private Integer paymentType; | |||
| @@ -13,6 +13,8 @@ public enum EnumPayWay { | |||
| PAY_WAY_TT(5, "抖音担保支付",EnumPayWayType.TT_PAY,EnumAppPlat.TOUTIAO,null), | |||
| PAY_WAY_POS_B(10, "POS B端",EnumPayWayType.POS,null,null), | |||
| PAY_WAY_POS_NEU(11, "POS 东软",EnumPayWayType.NEU_POS,null,EnumCardSpendFrom.POS), | |||
| PAY_WAY_PREPAIDCARD(13, "储值卡支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_OUTER(90, "外部注卷",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_MERCHANT(91, "商户注券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_VERRIFY(92, "核销发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_B_MA(93, "支付发券,无需支付",null,null,null), | |||
| @@ -222,7 +222,7 @@ public interface WxOrderService { | |||
| Integer shippingType, UserBasicInfoAddress address); | |||
| // 3. 创建有价订单 | |||
| WxOrder saveNoFreeOrderForCoupon(boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,OrderComposeSaveDto orderdto); | |||
| WxOrder saveNoFreeOrderForCoupon(boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,OrderComposeSaveDto orderdto,EnumPayWay payWay); | |||
| /** | |||
| * 下订单成功后处理 | |||
| @@ -860,6 +860,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.updateTenantInfo(user); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setType(EnumOrderType.MICROPAY.getCode()); | |||
| record.setPayVendor(EnumPayWay.PAY_WAY_WECHAT_MA.getCode()); | |||
| record.setProductId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| @@ -917,6 +918,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.updateTenantInfo(user); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setType(EnumOrderType.MICROPAY.getCode()); | |||
| record.setPayVendor(EnumPayWay.PAY_WAY_WECHAT_MA.getCode()); | |||
| record.setProductId(user.getId()); | |||
| if (cUser != null) { | |||
| record.setCUserId(cUser.getId()); | |||
| @@ -959,6 +961,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.updateTenantInfo(merchant); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setType(EnumOrderType.PREPAIDCARD.getCode()); | |||
| record.setPayVendor(EnumPayWay.PAY_WAY_PREPAIDCARD.getCode()); | |||
| record.setProductId(merchant.getId()); | |||
| record.setCUserId(cUserId); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| @@ -1212,6 +1215,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| couponOrder.setAutoRefund(coupon.getAutoRefund()); | |||
| couponOrder.setOrderId(order.getId()); | |||
| couponOrder.setExpiredTime(valid_date); | |||
| couponOrder.setPayVendor(EnumPayWay.PAY_WAY_NOT_UNPAY_OUTER.getCode()); | |||
| if (!isCard) { | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } else { | |||
| @@ -1336,6 +1340,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setOrderNumber(orderNumber); | |||
| record.setProductId(couponId); | |||
| record.setType(EnumOrderType.COUPON.getCode()); | |||
| record.setPayVendor(payWay.getCode()); | |||
| record.setCUserId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| @@ -1410,6 +1415,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setOrderNumber(orderNumber); | |||
| record.setProductId(couponId); | |||
| record.setType(EnumOrderType.COUPON.getCode()); | |||
| record.setPayVendor(EnumPayWay.PAY_WAY_NOT_UNPAY_GIFTLIST.getCode()); | |||
| record.setCUserId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(coupon.getSalePrice()); | |||
| @@ -2179,7 +2185,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| } else { | |||
| // 有价券 | |||
| order = proxy.saveNoFreeOrderForCoupon(allowUnPayOrder,composeOrder,user, orderdto.getWxCoupon(),perCouponNumber, orderdto); | |||
| order = proxy.saveNoFreeOrderForCoupon(allowUnPayOrder,composeOrder,user, orderdto.getWxCoupon(),perCouponNumber, orderdto,payWay); | |||
| } | |||
| // couponActionLog | |||
| // try { | |||
| @@ -2225,6 +2231,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| WxOrder record = new WxOrder(); | |||
| record.setCouponChannelId(couponChannelId); | |||
| record.setType(orderType); | |||
| record.setPayVendor(payWay.getCode()); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(0); | |||
| @@ -2265,7 +2272,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public WxOrder saveNoFreeOrderForCoupon(boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,OrderComposeSaveDto orderdto) { | |||
| public WxOrder saveNoFreeOrderForCoupon(boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,OrderComposeSaveDto orderdto,EnumPayWay payWay) { | |||
| WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy(); | |||
| String couponIdStr = String.valueOf(coupon.getId()); | |||
| // 3. 减库存操作 | |||
| @@ -2291,6 +2298,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| // 4.2 保存订单 | |||
| WxOrder record = new WxOrder(); | |||
| record.setType(orderType); | |||
| record.setPayVendor(payWay.getCode()); | |||
| record.setCouponChannelId(orderdto.getSignleOrder().getCouponChannelId()); | |||
| record.setOrderGroupId(orderdto.getSignleOrder().getOrderGroupId()); | |||
| record.setFormId(orderdto.getSignleOrder().getFormId()); | |||
| @@ -2358,6 +2366,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| WxOrder record = new WxOrder(); | |||
| record.setCouponChannelId(couponChannelId); | |||
| record.setType(orderType); | |||
| record.setPayVendor(EnumPayWay.PAY_WAY_NOT_UNPAY_OUTER.getCode()); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(0); | |||
| @@ -3,6 +3,7 @@ package com.iformall.service.pay; | |||
| import java.util.Map; | |||
| import java.util.concurrent.ConcurrentHashMap; | |||
| import com.iformall.service.pay.service.pay.douyin.miniApp.TtMiniAppPayAdapterService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.ErrorCode; | |||
| @@ -39,8 +40,10 @@ public class PayServiceFactory { | |||
| WxMiniMaPayAdapterService wxMiniAppMaPayService; | |||
| @Autowired | |||
| WxH5PayService wxH5PayService; | |||
| @Autowired | |||
| TtMiniAppPayAdapterService ttMiniAppPayService; | |||
| @Autowired | |||
| WxPayShareService wxShareService; | |||
| @@ -59,6 +62,7 @@ public class PayServiceFactory { | |||
| serviceMap.put(EnumPayWay.PAY_WAY_WECHAT.getCode(), wxMiniAppPayService); | |||
| serviceMap.put(EnumPayWay.PAY_WAY_WECHAT_MA.getCode(), wxMiniAppMaPayService); | |||
| serviceMap.put(EnumPayWay.PAY_WAY_WECHAT_WAP.getCode(), wxH5PayService); | |||
| serviceMap.put(EnumPayWay.PAY_WAY_TT.getCode(),ttMiniAppPayService); | |||
| } | |||
| return serviceMap; | |||
| } | |||
| @@ -0,0 +1,248 @@ | |||
| package com.iformall.service.pay.service.pay.douyin; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.enums.EnumPayMode; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.pay.WxPay; | |||
| import com.iformall.pay.WxPayOrderQ; | |||
| import com.iformall.pay.WxPayOrderSQ; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.helper.WxPayOrderServiceHelper; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | |||
| import com.iformall.utils.BeanUtils; | |||
| import com.iformall.utils.MaUtil; | |||
| import com.iformall.utils.QRCodeUtils; | |||
| import com.iformall.utils.Utility; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.open.api.WxOpenService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import java.io.File; | |||
| import java.util.Map; | |||
| @Slf4j | |||
| public class BaseTtPayAdapterService { | |||
| protected PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) | |||
| throws Exception { | |||
| Map<String, String> retMap = WxPayOrderServiceHelper.wxOrderPayStatusMap(oldRecord, appInfo, payAccount); | |||
| int code = WxPayOrderServiceHelper.getPayStatusFromMap(retMap,oldRecord.getPayOrderNo()); | |||
| String msg = WxPayOrderServiceHelper.getPayStatusMsg(retMap, oldRecord.getPayOrderNo()); | |||
| PayQueryAdapterResult result = new PayQueryAdapterResult(code, msg, retMap,retMap.get("transaction_id"),retMap.get("time_end")); | |||
| return result; | |||
| } | |||
| protected int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | |||
| return WxPayOrderServiceHelper.getPayStatusFromMap((Map<String, String>) statusObject.getData(),orderOutNo); | |||
| } | |||
| protected int queryPayStatusCode(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) | |||
| throws Exception { | |||
| return WxPayOrderServiceHelper.wxOrderPayStatus(oldRecord, appInfo, payAccount); | |||
| } | |||
| JSONObject errorMapClose = JSON.parseObject("{" + | |||
| "\"ORDERPAID\":{\"detail\":\"订单已支付\",\"reason\":\"订单已支付,不能发起关单\",\"resolution\":\"订单已支付,不能发起关单,请当作已支付的正常交易\"}," + | |||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\",\"reason\":\"系统错误\",\"resolution\":\"系统异常,请重新调用该API\"}," + | |||
| "\"ORDERCLOSED\":{\"detail\":\"订单已关闭\",\"reason\":\"订单已关闭,无法重复关闭\",\"resolution\":\"订单已关闭,无需继续调用\"}," + | |||
| "\"SIGNERROR\":{\"detail\":\"签名错误\",\"reason\":\"参数签名结果不正确\",\"resolution\":\"请检查签名参数和方法是否都符合签名算法要求\"}," + | |||
| "\"REQUIRE_POST_METHOD\":{\"detail\":\"请使用post方法\",\"reason\":\"未使用post传递参数\",\"resolution\":\"请检查请求参数是否通过post方法提交\"}," + | |||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"reason\":\"请检查XML参数格式是否正确\"}}"); | |||
| protected PayAdapterResult closeOrder(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) { | |||
| String response = closeOrderWx(appInfo, record,payAccount); | |||
| log.info("pay order close, " + record.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||
| if ("SUCCESS".equals(result_code)) { | |||
| return new PayAdapterResult(true, "success", returnMap, null); | |||
| } else { | |||
| String errMsg = ""; | |||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||
| if (errObj != null) { | |||
| errMsg = errObj.toJSONString(); | |||
| } else { | |||
| errMsg = returnMap.get("return_msg"); | |||
| } | |||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||
| } | |||
| } else { | |||
| String errMsg = returnMap.get("return_msg"); | |||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||
| } | |||
| } | |||
| private String closeOrderWx(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) { | |||
| // get payAccount | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 普通商户号模式 | |||
| WxPayOrderQ payOrderC = new WxPayOrderQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderC.setAppid(appInfo.getAppId()); | |||
| payOrderC.setMch_id(payAccount.getMchId()); | |||
| payOrderC.setNonce_str(noncestr); | |||
| payOrderC.setOut_trade_no(record.getPayOrderNo()); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderC); | |||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderC); | |||
| String response = WxPay.closeOrder(map); | |||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } else { | |||
| // 服务商模式 | |||
| WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderSC.setAppid(appInfo.getParentAppId()); | |||
| payOrderSC.setSub_appid(appInfo.getAppId()); | |||
| payOrderSC.setMch_id(payAccount.getMchId()); | |||
| payOrderSC.setSub_mch_id(payAccount.getSubMchId()); | |||
| payOrderSC.setNonce_str(noncestr); | |||
| payOrderSC.setOut_trade_no(record.getPayOrderNo()); | |||
| payOrderSC.setSign_type("HMAC-SHA256"); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||
| payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderSC); | |||
| String response = WxPay.closeOrder(map); | |||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| protected PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception { | |||
| String response = payOrderReverseWx(appInfo, record,payAccount); | |||
| log.info("pay order reverse, " + record.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||
| if ("SUCCESS".equals(result_code)) { | |||
| return new PayAdapterResult(true, "订单撤销成功", returnMap, null); | |||
| } else { | |||
| String errMsg = ""; | |||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||
| if (errObj != null) { | |||
| errMsg = errObj.toJSONString(); | |||
| } else { | |||
| errMsg = returnMap.get("return_msg"); | |||
| } | |||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||
| } | |||
| } else { | |||
| String errMsg = returnMap.get("return_msg"); | |||
| return new PayAdapterResult(false, errMsg, returnMap, null); | |||
| } | |||
| } | |||
| private String payOrderReverseWx(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) { | |||
| // get payAccount | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 普通商户号模式 | |||
| WxPayOrderQ payOrderC = new WxPayOrderQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderC.setAppid(appInfo.getAppId()); | |||
| payOrderC.setMch_id(payAccount.getMchId()); | |||
| payOrderC.setNonce_str(noncestr); | |||
| payOrderC.setOut_trade_no(record.getPayOrderNo()); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderC); | |||
| payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderC); | |||
| String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); | |||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } else { | |||
| // 服务商模式 | |||
| WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payOrderSC.setAppid(appInfo.getParentAppId()); | |||
| payOrderSC.setSub_appid(appInfo.getAppId()); | |||
| payOrderSC.setMch_id(payAccount.getMchId()); | |||
| payOrderSC.setSub_mch_id(payAccount.getSubMchId()); | |||
| payOrderSC.setNonce_str(noncestr); | |||
| payOrderSC.setOut_trade_no(record.getPayOrderNo()); | |||
| payOrderSC.setSign_type("HMAC-SHA256"); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payOrderSC); | |||
| payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payOrderSC); | |||
| String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); | |||
| log.info("request:" + map.toString() + "\nresponse:" + response); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @Autowired | |||
| WxOpenService openService; | |||
| @Autowired | |||
| MaUtil maUtil; | |||
| protected File getQrCode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws WxErrorException { | |||
| boolean isFmOpen = false; | |||
| WxMaService wxMaService; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||
| } else { | |||
| wxMaService = maUtil.getWeappService(appinfo); | |||
| } | |||
| boolean autoColor = false; | |||
| boolean isHyaline = true; | |||
| WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | |||
| String pathStr = ""; | |||
| if (StringUtils.isNotBlank(sceneParam)) { | |||
| pathStr = pageUrl + "?scene="+sceneParam; | |||
| } else { | |||
| pathStr = pageUrl; | |||
| } | |||
| if(type == 0) { | |||
| final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); | |||
| return codeFile; | |||
| }else { | |||
| final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); | |||
| return codeFile; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,269 @@ | |||
| package com.iformall.service.pay.service.pay.douyin.miniApp; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.enums.EnumPayMode; | |||
| import com.iformall.enums.EnumPayShare; | |||
| import com.iformall.enums.EnumPayStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.pay.WxPay; | |||
| import com.iformall.pay.WxPayOrderP; | |||
| import com.iformall.pay.WxPayOrderSP; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.order.entity.WxComposeOrder; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.CDrivingPayService; | |||
| import com.iformall.service.pay.service.pay.douyin.BaseTtPayAdapterService; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | |||
| import com.iformall.utils.BeanUtils; | |||
| import com.iformall.utils.MapUtil; | |||
| import com.iformall.utils.Utility; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.stereotype.Service; | |||
| import java.io.File; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| @Slf4j | |||
| @Service | |||
| public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implements CDrivingPayService{ | |||
| JSONObject errorMap = JSON.parseObject("{" + | |||
| "\"NOAUTH\":{\"detail\":\"商户无此接口权限\",\"reason\":\"商户未开通此接口权限\",\"resolution\":\"请商户前往申请此接口权限\"}," + | |||
| "\"NOTENOUGH\":{\"detail\":\"余额不足\",\"reason\":\"用户帐号余额不足\",\"resolution\":\"用户帐号余额不足,请用户充值或更换支付卡后再支付\"}," + | |||
| "\"ORDERPAID\":{\"detail\":\"商户订单已支付\",\"reason\":\"商户订单已支付,无需重复操作\",\"resolution\":\"商户订单已支付,无需更多操作\"}," + | |||
| "\"ORDERCLOSED\":{\"detail\":\"订单已关闭\",\"reason\":\"当前订单已关闭,无法支付\",\"resolution\":\"当前订单已关闭,请重新下单\"}," + | |||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\t\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," + | |||
| "\"APPID_NOT_EXIST\":{\"detail\":\"APPID不存在\",\"reason\":\"参数中缺少APPID\",\"resolution\":\"请检查APPID是否正确\"}," + | |||
| "\"MCHID_NOT_EXIST\":{\"detail\":\"MCHID不存在\",\"reason\":\"参数中缺少MCHID\",\"resolution\":\"请检查MCHID是否正确\"}," + | |||
| "\"APPID_MCHID_NOT_MATCH\":{\"detail\":\"appid和mch_id不匹配\",\"reason\":\"appid和mch_id不匹配\",\"resolution\":\"请确认appid和mch_id是否匹配\"}," + | |||
| "\"LACK_PARAMS\":{\"detail\":\"缺少参数\t\",\"reason\":\"缺少必要的请求参数\",\"resolution\":\"请检查参数是否齐全\"}," + | |||
| "\"OUT_TRADE_NO_USED\":{\"detail\":\"商户订单号重复\",\"reason\":\"同一笔交易不能多次提交\",\"resolution\":\"请核实商户订单号是否重复提交\"}," + | |||
| "\"SIGNERROR\":{\"detail\":\"签名错误\",\"reason\":\"参数签名结果不正确\",\"resolution\":\"请检查签名参数和方法是否都符合签名算法要求\"}," + | |||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"resolution\":\"请检查XML参数格式是否正确\"}," + | |||
| "\"REQUIRE_POST_METHOD\":{\"detail\":\"请使用post方法\",\"reason\":\"未使用post传递参数\",\"resolution\":\"请检查请求参数是否通过post方法提交\"}," + | |||
| "\"POST_DATA_EMPTY\":{\"detail\":\"post数据为空\",\"reason\":\"post数据不能为空\",\"resolution\":\"请检查post数据是否为空\"}," + | |||
| "\"NOT_UTF8\":{\"detail\":\"编码格式错误\",\"reason\":\"未使用指定编码格式\",\"resolution\":\"请使用UTF-8编码格式\"}}"); | |||
| private WxPayOrderP generateWxPayOrderP(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record,String openId,String appId,Date currentDate) throws Exception { | |||
| // 统一下单 普通商户模式 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| wxPayOrderP.setOpenid(openId); | |||
| wxPayOrderP.setAppid(appId); | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody(productName); | |||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderP.setTotal_fee(composeOrder.getPayment()); | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderP.setGoods_tag(productName); | |||
| wxPayOrderP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderP.setProduct_id(String.valueOf(composeOrder.getMainOrderId())); // 订单ID | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| wxPayOrderP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderP); | |||
| wxPayOrderP.setSign(WxPayment.createSign(payOrderMap, payAccount.getApiKey())); | |||
| return wxPayOrderP; | |||
| } | |||
| private PayAdapterResult getOrderPResult(Map<String, String> returnMap,WxPayOrder record,WxPayAccount payAccount,String noncestr) { | |||
| PayAdapterResult par = new PayAdapterResult(); | |||
| returnMap.put("payOrderId", String.valueOf(record.getId())); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| par.setSuccess(true); | |||
| par.setMsg("success."); | |||
| par.setData(returnMap); | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| // update payOrder with prepay_id | |||
| record.setPrepayId(prepay_id); | |||
| record.setUpdateTime(new Date()); | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", returnMap.get("appid")); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + prepay_id); | |||
| sighMap.put("signType", "MD5"); | |||
| String signAgent = WxPayment.createSign(sighMap, payAccount.getApiKey()); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + prepay_id); | |||
| returnMap.put("paySign", signAgent); | |||
| log.info("back to UI: " + returnMap.toString()); | |||
| } else { | |||
| String errMsg = ""; | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| if (errObj != null) { | |||
| errMsg = errObj.toJSONString(); | |||
| record.setFailReason(errMsg); | |||
| } else { | |||
| errMsg = returnMap.get("return_msg"); | |||
| record.setFailReason(errMsg); | |||
| } | |||
| record.setUpdateTime(new Date()); | |||
| par.setSuccess(false); | |||
| par.setMsg(errMsg); | |||
| par.setData(returnMap); | |||
| } | |||
| return par; | |||
| } | |||
| private WxPayOrderSP generateWxPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder,String productName,WxPayOrder record,WxAppinfo appInfo,String openId,String appId,Date currentDate,EnumPayShare isShare) throws Exception { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderSP wxPayOrderSP = new WxPayOrderSP(); | |||
| wxPayOrderSP.setSub_openid(openId); | |||
| wxPayOrderSP.setAppid(appInfo.getParentAppId()); | |||
| wxPayOrderSP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderSP.setSub_appid(appId); | |||
| wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxPayOrderSP.setNonce_str(noncestr); | |||
| wxPayOrderSP.setBody(productName); | |||
| wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderSP.setTotal_fee(composeOrder.getPayment().toString()); | |||
| wxPayOrderSP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderSP.setGoods_tag(productName); // 券ID | |||
| wxPayOrderSP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderSP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderSP.setProduct_id(String.valueOf(composeOrder.getMainOrderId())); // | |||
| wxPayOrderSP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| wxPayOrderSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| wxPayOrderSP.setSign_type("HMAC-SHA256"); | |||
| wxPayOrderSP.setProfit_sharing(null); | |||
| if (isShare == EnumPayShare.YES) { | |||
| wxPayOrderSP.setProfit_sharing("Y"); | |||
| } | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderSP); | |||
| wxPayOrderSP.setSign(WxPayment.createSignHMAC(payOrderMap, payAccount.getApiKey())); | |||
| return wxPayOrderSP; | |||
| } | |||
| private PayAdapterResult getOrderSPResult(Map<String, String> returnMap,WxPayOrder record,WxPayAccount payAccount,WxAppinfo appInfo,String noncestr) { | |||
| PayAdapterResult par = new PayAdapterResult(); | |||
| returnMap.put("payOrderId", String.valueOf(record.getId())); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| par.setSuccess(true); | |||
| par.setMsg("success."); | |||
| par.setData(returnMap); | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| // update payOrder with prepay_id | |||
| record.setPrepayId(prepay_id); | |||
| record.setUpdateTime(new Date()); | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", appInfo.getAppId()); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + prepay_id); | |||
| sighMap.put("signType", "HMAC-SHA256"); | |||
| String signAgent = WxPayment.createSignHMAC(sighMap, payAccount.getApiKey()); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + prepay_id); | |||
| returnMap.put("paySign", signAgent); | |||
| returnMap.put("signType", "HMAC-SHA256"); | |||
| log.info("back to UI: " + returnMap.toString()); | |||
| } else { | |||
| String errMsg = ""; | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| if (errObj != null) { | |||
| errMsg = errObj.toJSONString(); | |||
| record.setFailReason(errMsg); | |||
| } else { | |||
| errMsg = returnMap.get("return_msg"); | |||
| record.setFailReason(errMsg); | |||
| } | |||
| record.setUpdateTime(new Date()); | |||
| par.setSuccess(false); | |||
| par.setMsg(errMsg); | |||
| par.setData(returnMap); | |||
| } | |||
| return par; | |||
| } | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| 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为空"); | |||
| } | |||
| //普通商户模式 | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(payAccount,composeOrder,productName,record,openId,appInfo.getAppId(),currentDate); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderP)); | |||
| log.info("pay order, wechat pushOrder, " + wxPayOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| return getOrderPResult(returnMap,record,payAccount,wxPayOrderP.getNonce_str()); | |||
| } else { | |||
| // 统一下单 // 服务商模式 | |||
| WxPayOrderSP wxPayOrderSP = generateWxPayOrderSP(payAccount,composeOrder,productName,record,appInfo,openId,appInfo.getAppId(),currentDate,isShare); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderSP)); | |||
| log.info("pay order, wechat pushOrder, " + wxPayOrderSP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| return getOrderSPResult(returnMap,record,payAccount,appInfo,wxPayOrderSP.getNonce_str()); | |||
| } | |||
| } | |||
| @Override | |||
| public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | |||
| WxPayAccount payAccount) throws Exception { | |||
| return super.queryPayStatus(oldRecord,appInfo, payAccount); | |||
| } | |||
| @Override | |||
| public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | |||
| return super.queryPayStatus(statusObject, orderOutNo); | |||
| } | |||
| @Override | |||
| public int queryPayStatusCode(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) | |||
| throws Exception { | |||
| return super.queryPayStatusCode(oldRecord, appInfo, payAccount); | |||
| } | |||
| @Override | |||
| public PayAdapterResult payOrderClose(WxAppinfo appInfo, WxPayOrder record,WxPayAccount payAccount) throws Exception { | |||
| return super.closeOrder(appInfo, record, payAccount); | |||
| } | |||
| @Override | |||
| public PayAdapterResult payOrderReverse(WxAppinfo appInfo, WxPayOrder record, WxPayAccount payAccount) | |||
| throws Exception { | |||
| return super.payOrderReverse(appInfo, record, payAccount); | |||
| } | |||
| @Override | |||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception{ | |||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||
| } | |||
| } | |||
| @@ -10,6 +10,7 @@ | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||
| <result column="pay_vendor" jdbcType="TINYINT" property="payVendor" /> | |||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||
| @@ -33,7 +34,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`order_number`,`tenant_id`,`parent_tenant_id`,`c_user_id`,`coupon_channel_id`,`product_id`,`type`,`payment_type`,`payment`,`payment_time`,`freight_price`,`order_status`,`create_date`,`update_date`,`detail`, | |||
| `id`,`order_number`,`tenant_id`,`parent_tenant_id`,`c_user_id`,`coupon_channel_id`,`product_id`,`type`,`pay_vendor`,`payment_type`,`payment`,`payment_time`,`freight_price`,`order_status`,`create_date`,`update_date`,`detail`, | |||
| `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id`,`form_id`,`total_payment`,`compose_order_id`,`coupon_number`,`compose_order_type`,`shipping_type`,`shipping_address`,`parent_order_id` | |||
| </sql> | |||
| @@ -70,6 +71,9 @@ | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and `pay_vendor` = #{payVendor} | |||
| </if> | |||
| <if test=" null != paymentType "> | |||
| and `payment_type` = #{paymentType} | |||
| @@ -191,6 +195,9 @@ | |||
| <if test=" null != type "> | |||
| and o.type = #{type} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != statusS "> | |||
| and o.order_status in | |||
| @@ -210,6 +217,9 @@ | |||
| <if test="type != null"> | |||
| AND type = #{type,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="payVendor != null"> | |||
| AND pay_vendor = #{payVendor,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="startDate != null"> | |||
| AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP}) | |||
| </if> | |||
| @@ -226,6 +236,9 @@ | |||
| <if test="type != null"> | |||
| AND type = #{type,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="payVendor != null"> | |||
| AND pay_vendor = #{payVendor,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="startDate != null"> | |||
| AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP}) | |||
| </if> | |||
| @@ -242,6 +255,9 @@ | |||
| <if test="type != null"> | |||
| AND type = #{type,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="payVendor != null"> | |||
| AND pay_vendor = #{payVendor,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="startDate != null"> | |||
| AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP}) | |||
| </if> | |||
| @@ -258,6 +274,9 @@ | |||
| <if test="type != null"> | |||
| AND type = #{type,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="payVendor != null"> | |||
| AND pay_vendor = #{payVendor,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="startDate != null"> | |||
| AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP}) | |||
| </if> | |||
| @@ -269,7 +288,7 @@ | |||
| <sql id="allCUserOrderDetailColumns"> | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.gift_list, | |||
| c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.gift_list, | |||
| co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num,o.compose_order_type,o.compose_order_id,o.parent_order_id, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,co.`shipping_status`,co.`delivery_info` | |||
| </sql> | |||
| @@ -330,6 +349,7 @@ | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/> | |||
| @@ -383,6 +403,7 @@ | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/> | |||
| @@ -433,7 +454,7 @@ | |||
| <sql id="allCUserOrderListColumns"> | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| o.compose_order_type,o.compose_order_id, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,o.parent_order_id | |||
| </sql> | |||
| @@ -463,6 +484,9 @@ | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| @@ -471,7 +495,7 @@ | |||
| select 0 level,o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date, | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment_time,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address` | |||
| from wx_coupon c,wx_order o | |||
| where o.product_id = c.id and o.order_status in (0,2) | |||
| @@ -490,12 +514,15 @@ | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| union all | |||
| select 0 level, o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date, | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment_time,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address` | |||
| from wx_coupon c,wx_order o | |||
| where o.product_id = c.id and o.order_status in (1,3,4,5) | |||
| @@ -513,12 +540,15 @@ | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| union all | |||
| select 1 level,o.compose_order_type,o.compose_order_id,sum(o.payment) payment,o.order_status,min(create_date) create_date, | |||
| null ,null ,null ,null ,null ,null ,null ,null ,null ,null , | |||
| null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null , | |||
| null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null , | |||
| null ,null ,null ,null | |||
| from wx_order o | |||
| where o.order_status in (0,2) | |||
| @@ -537,6 +567,9 @@ | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| group by o.compose_order_type,o.compose_order_id | |||
| ) a | |||
| @@ -587,6 +620,10 @@ | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and bu.`merchant_id` = #{merchantId} | |||
| </if> | |||
| @@ -625,6 +662,7 @@ | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||
| <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/> | |||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||
| @@ -644,7 +682,7 @@ | |||
| </resultMap> | |||
| <sql id="allPayOrderColumns"> | |||
| o.`id`,o.`order_number`,o.`tenant_id`,o.`parent_tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`, | |||
| o.`id`,o.`order_number`,o.`tenant_id`,o.`parent_tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`,o.`pay_vendor`, | |||
| o.`payment_type`,o.`payment`,o.`payment_time`,o.`freight_price`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`, | |||
| m.name as merchant_name, bu.name, bu.phone as bphone, | |||
| cubi.phone, cubi.nick_name, cubi.name c_user_name | |||
| @@ -664,6 +702,9 @@ | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and bu.`merchant_id` = #{merchantId} | |||
| </if> | |||
| @@ -687,6 +728,7 @@ | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||
| <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/> | |||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||
| @@ -708,7 +750,7 @@ | |||
| </resultMap> | |||
| <sql id="allExpPayOrderColumns"> | |||
| o.`id`,o.`order_number`,o.`tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`, | |||
| o.`id`,o.`order_number`,o.`tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`,o.`pay_vendor`, | |||
| o.`payment_type`,o.`payment`,o.`payment_time`,o.`freight_price`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`, | |||
| m.name as merchant_name, bu.name, bu.phone as bphone, | |||
| cubi.phone, cubi.nick_name, cubi.name c_user_name, | |||
| @@ -730,6 +772,9 @@ | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and bu.`merchant_id` = #{merchantId} | |||
| </if> | |||
| @@ -751,6 +796,9 @@ | |||
| SELECT * from wx_order${tenantEntity.shardTableSuffix} | |||
| </foreach>) o | |||
| where o.`type` = #{type} | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and o.`tenant_id` = #{tenantId} | |||
| </if> | |||
| @@ -782,6 +830,9 @@ | |||
| <if test=" null != type"> | |||
| and o.`type` = #{type} | |||
| </if> | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != orderStatus"> | |||
| and o.`order_status` = #{orderStatus} | |||
| </if> | |||
| @@ -797,6 +848,9 @@ | |||
| inner join wx_merchant_b_user bu on bu.id = o.product_id | |||
| inner join wx_merchant m on m.id = bu.merchant_id | |||
| where m.`id` = #{merchantId} and o.tenant_id = #{tenantId} and o.`type` = 1 and o.`order_status` = 1 | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test=" null != startTime and null != endTime"> | |||
| and o.`create_date` BETWEEN #{startTime} and #{endTime} | |||
| </if> | |||
| @@ -838,6 +892,9 @@ | |||
| and m.id = bu.merchant_id | |||
| and o.order_status = '1' | |||
| and o.type = 1 | |||
| <if test=" null != payVendor "> | |||
| and o.pay_vendor = #{payVendor} | |||
| </if> | |||
| <if test="wxOrderReportDto.startTime != null"> | |||
| AND o.create_date > #{wxOrderReportDto.startTime} | |||
| </if> | |||
| @@ -865,6 +922,7 @@ | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||
| <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/> | |||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||