| @@ -21,7 +21,7 @@ public class WxMallConfigController extends BaseController { | |||||
| private WxMallConfigService wxMallConfigService; | private WxMallConfigService wxMallConfigService; | ||||
| @ApiOperation("获取停车劵开关") | @ApiOperation("获取停车劵开关") | ||||
| @GetMapping("getStopCarConpon") | |||||
| @GetMapping("getStopCarCoupon") | |||||
| public ResultData getStopCarConpon() { | public ResultData getStopCarConpon() { | ||||
| WxMallConfig wxMallConfig = new WxMallConfig(); | WxMallConfig wxMallConfig = new WxMallConfig(); | ||||
| wxMallConfig.setKey("stopCarCouponSwitch"); | wxMallConfig.setKey("stopCarCouponSwitch"); | ||||
| @@ -35,10 +35,10 @@ public class WxMallConfigController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("获取核销劵开关") | @ApiOperation("获取核销劵开关") | ||||
| @GetMapping("getVerifyConpon") | |||||
| @GetMapping("getVerifyCoupon") | |||||
| public ResultData getVerifyConpon() { | public ResultData getVerifyConpon() { | ||||
| WxMallConfig wxMallConfig = new WxMallConfig(); | WxMallConfig wxMallConfig = new WxMallConfig(); | ||||
| wxMallConfig.setKey("verifyConponSwitch"); | |||||
| wxMallConfig.setKey("verifyCouponSwitch"); | |||||
| wxMallConfig.setTenantId(getTenantId()); | wxMallConfig.setTenantId(getTenantId()); | ||||
| PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); | PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); | ||||
| if (page.getSize() > 0) { | if (page.getSize() > 0) { | ||||
| @@ -48,8 +48,22 @@ public class WxMallConfigController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @PostMapping("updateStopCarConpon") | |||||
| @ApiOperation("修改停车开关") | |||||
| @ApiOperation("获取B端刷卡支付发劵开关") | |||||
| @GetMapping("getMicroPayCouponSwitch") | |||||
| public ResultData getMicroPayConpon() { | |||||
| WxMallConfig wxMallConfig = new WxMallConfig(); | |||||
| wxMallConfig.setKey("microPayCouponSwitch"); | |||||
| wxMallConfig.setTenantId(getTenantId()); | |||||
| PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); | |||||
| if (page.getSize() > 0) { | |||||
| WxMallConfig config = page.getList().get(0); | |||||
| return new ResultData(config); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("updateStopCarCoupon") | |||||
| @ApiOperation("修改停车发券开关") | |||||
| public ResultData updateStopCarConpon(@RequestBody WxMallConfig wxMallConfig) { | public ResultData updateStopCarConpon(@RequestBody WxMallConfig wxMallConfig) { | ||||
| WxMallConfig temp = new WxMallConfig(); | WxMallConfig temp = new WxMallConfig(); | ||||
| // temp.setKey("stopCarCouponSwitch"); | // temp.setKey("stopCarCouponSwitch"); | ||||
| @@ -59,11 +73,23 @@ public class WxMallConfigController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @PostMapping("updateVerifyConpon") | |||||
| @ApiOperation("修改核销开关") | |||||
| @PostMapping("updateVerifyCoupon") | |||||
| @ApiOperation("修改核销发券开关") | |||||
| public ResultData updateVerifyConpon(@RequestBody WxMallConfig wxMallConfig) { | public ResultData updateVerifyConpon(@RequestBody WxMallConfig wxMallConfig) { | ||||
| WxMallConfig temp = new WxMallConfig(); | WxMallConfig temp = new WxMallConfig(); | ||||
| // temp.setKey("verifyConponSwitch"); | |||||
| // temp.setKey("verifyCouponSwitch"); | |||||
| temp.setValue(wxMallConfig.getValue()); | |||||
| temp.setId(wxMallConfig.getId()); | |||||
| wxMallConfigService.saveOrUpdate(temp); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("updateMicroPayCouponSwitch") | |||||
| @ApiOperation("修改刷卡支付发券开关") | |||||
| public ResultData updateMicroPayCoupon(@RequestBody WxMallConfig wxMallConfig) { | |||||
| WxMallConfig temp = new WxMallConfig(); | |||||
| // temp.setKey("verifyCouponSwitch"); | |||||
| temp.setValue(wxMallConfig.getValue()); | temp.setValue(wxMallConfig.getValue()); | ||||
| temp.setId(wxMallConfig.getId()); | temp.setId(wxMallConfig.getId()); | ||||
| wxMallConfigService.saveOrUpdate(temp); | wxMallConfigService.saveOrUpdate(temp); | ||||
| @@ -5,6 +5,7 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.config.PayProperty; | import com.iformall.config.PayProperty; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.enums.EnumOrderType; | import com.iformall.enums.EnumOrderType; | ||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.enums.EnumRefundWay; | import com.iformall.enums.EnumRefundWay; | ||||
| @@ -51,6 +52,9 @@ public class WxMicroPayController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxRefundOrderService wxRefundOrderService; | WxRefundOrderService wxRefundOrderService; | ||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @ApiOperation(value = "刷卡支付订单", notes = "params:{\"authCode\":\"String\",\"totalFee\":\"String\"},\n" + | @ApiOperation(value = "刷卡支付订单", notes = "params:{\"authCode\":\"String\",\"totalFee\":\"String\"},\n" + | ||||
| "注意:\n" + | "注意:\n" + | ||||
| "提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);\n" + | "提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);\n" + | ||||
| @@ -64,9 +68,11 @@ public class WxMicroPayController extends BaseController { | |||||
| String totalFeeStr = paramMap.get("totalFee"); | String totalFeeStr = paramMap.get("totalFee"); | ||||
| if (StringUtils.isBlank(authCode)) { | if (StringUtils.isBlank(authCode)) { | ||||
| logger.error("authCode不能为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "authCode不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "authCode不能为空"); | ||||
| } | } | ||||
| if (StringUtils.isBlank(totalFeeStr)) { | if (StringUtils.isBlank(totalFeeStr)) { | ||||
| logger.error("totalFee不能为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "totalFee不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "totalFee不能为空"); | ||||
| } | } | ||||
| @@ -78,23 +84,22 @@ public class WxMicroPayController extends BaseController { | |||||
| try { | try { | ||||
| order = wxOrderService.saveMicroOrder(user, totalFeeStr); | order = wxOrderService.saveMicroOrder(user, totalFeeStr); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("saveMicopayOrder 1" + e.getMessage()); | |||||
| 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("saveMicopayOrder 2" + e.getMessage()); | |||||
| return new ResultData(ErrorCode.ORDER_IS_FAIL, e.getMessage()); | return new ResultData(ErrorCode.ORDER_IS_FAIL, e.getMessage()); | ||||
| } | } | ||||
| WxAppinfo appInfo = getAppInfo(user.getAppId()); | |||||
| WxPayOrder record = new WxPayOrder(); | WxPayOrder record = new WxPayOrder(); | ||||
| record.setTenantId(user.getTenantId()); | |||||
| record.setOrderId(order.getId()); | record.setOrderId(order.getId()); | ||||
| record.setAuthCode(authCode); | record.setAuthCode(authCode); | ||||
| record.setPayAmount(order.getPayment()); | record.setPayAmount(order.getPayment()); | ||||
| record.setIp(ipStr); | record.setIp(ipStr); | ||||
| try { | try { | ||||
| return wxPayOrderService.createMicroPayOrder(payProperty.isReal(), appInfo, user, record, EnumPayWay.PAY_WAY_WECHAT); | |||||
| return wxPayOrderService.createMicroPayOrder(payProperty.isReal(), user, record, EnumPayWay.PAY_WAY_WECHAT); | |||||
| } 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()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| @@ -112,13 +117,14 @@ public class WxMicroPayController extends BaseController { | |||||
| String orderIdStr = paramMap.get("orderId"); | String orderIdStr = paramMap.get("orderId"); | ||||
| if (StringUtils.isBlank(payOrderIdStr)) { | if (StringUtils.isBlank(payOrderIdStr)) { | ||||
| logger.error("payOrderId不能为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId不能为空"); | ||||
| } | } | ||||
| if (StringUtils.isBlank(orderIdStr)) { | if (StringUtils.isBlank(orderIdStr)) { | ||||
| logger.error("orderId不能为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | ||||
| } | } | ||||
| WxMerchantBUser user = getUser(); | WxMerchantBUser user = getUser(); | ||||
| WxAppinfo appInfo = getAppInfo(user.getAppId()); | |||||
| Long payOrderId = 0L; | Long payOrderId = 0L; | ||||
| Long orderId = 0L; | Long orderId = 0L; | ||||
| @@ -138,12 +144,13 @@ public class WxMicroPayController extends BaseController { | |||||
| } | } | ||||
| WxPayOrder record = new WxPayOrder(); | WxPayOrder record = new WxPayOrder(); | ||||
| record.setTenantId(user.getTenantId()); | |||||
| record.setId(payOrderId); | record.setId(payOrderId); | ||||
| record.setbUserId(user.getId()); | record.setbUserId(user.getId()); | ||||
| record.setOrderId(orderId); | record.setOrderId(orderId); | ||||
| try { | try { | ||||
| ResultData resultData = wxPayOrderService.payOrderQuery(appInfo, record); | |||||
| ResultData resultData = wxPayOrderService.payOrderQuery(record); | |||||
| return resultData; | return resultData; | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("payment wechat, order query error, req 2: " + record.toString() + ", e:" + e.getMessage()); | logger.error("payment wechat, order query error, req 2: " + record.toString() + ", e:" + e.getMessage()); | ||||
| @@ -162,13 +169,14 @@ public class WxMicroPayController extends BaseController { | |||||
| String orderIdStr = paramMap.get("orderId"); | String orderIdStr = paramMap.get("orderId"); | ||||
| if (StringUtils.isBlank(payOrderIdStr)) { | if (StringUtils.isBlank(payOrderIdStr)) { | ||||
| logger.error("payOrderId不能为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId不能为空"); | ||||
| } | } | ||||
| if (StringUtils.isBlank(orderIdStr)) { | if (StringUtils.isBlank(orderIdStr)) { | ||||
| logger.error("orderId不能为空"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | ||||
| } | } | ||||
| WxMerchantBUser user = getUser(); | WxMerchantBUser user = getUser(); | ||||
| WxAppinfo appInfo = getAppInfo(user.getAppId()); | |||||
| Long payOrderId = 0L; | Long payOrderId = 0L; | ||||
| Long orderId = 0L; | Long orderId = 0L; | ||||
| @@ -188,13 +196,14 @@ public class WxMicroPayController extends BaseController { | |||||
| } | } | ||||
| WxPayOrder record = new WxPayOrder(); | WxPayOrder record = new WxPayOrder(); | ||||
| record.setTenantId(user.getTenantId()); | |||||
| record.setId(payOrderId); | record.setId(payOrderId); | ||||
| record.setPayOrderNo(payOrderIdStr); | record.setPayOrderNo(payOrderIdStr); | ||||
| record.setbUserId(user.getId()); | record.setbUserId(user.getId()); | ||||
| record.setOrderId(orderId); | record.setOrderId(orderId); | ||||
| try { | try { | ||||
| return wxPayOrderService.payOrderReverse(appInfo, record); | |||||
| return wxPayOrderService.payOrderReverse(record); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("payment wechat, order query error, req 2: " + record.toString() + ", e:" + e.getMessage()); | logger.error("payment wechat, order query error, req 2: " + record.toString() + ", e:" + e.getMessage()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| @@ -248,10 +257,10 @@ public class WxMicroPayController extends BaseController { | |||||
| ResultData rd = wxRefundOrderService.createRefundOrderFromMicroPay(payProperty.isReal(), appinfo, orderId, EnumRefundWay.B, bUser.getId()); | ResultData rd = wxRefundOrderService.createRefundOrderFromMicroPay(payProperty.isReal(), appinfo, orderId, EnumRefundWay.B, bUser.getId()); | ||||
| return rd; | return rd; | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("退款 1:" + e.getMessage()); | |||||
| 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("退款 2:" + e.getMessage()); | |||||
| return new ResultData(ErrorCode.REFUND_ORDER_ERROR); | return new ResultData(ErrorCode.REFUND_ORDER_ERROR); | ||||
| } | } | ||||
| } | } | ||||
| @@ -15,13 +15,13 @@ public class TenantInfoImpl implements TenantInfo { | |||||
| @Override | @Override | ||||
| public String getTenantId() { | public String getTenantId() { | ||||
| String tenantId = ""; | |||||
| String tenantId = null; | |||||
| try { | try { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| tenantId = (String) request.getAttribute(AuthorizationInterceptor.TENANT_ID); | tenantId = (String) request.getAttribute(AuthorizationInterceptor.TENANT_ID); | ||||
| return tenantId; | return tenantId; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("getTenantId: " + e.getMessage()); | |||||
| } | } | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -129,14 +129,9 @@ public class WxCUser implements Serializable { | |||||
| /*附加信息**/ | /*附加信息**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="附加信息",name="extraInfo") | @io.swagger.annotations.ApiModelProperty(value="附加信息",name="extraInfo") | ||||
| private String extraInfo; | private String extraInfo; | ||||
| public String getExtraInfo() { | |||||
| return extraInfo; | |||||
| } | |||||
| public void setExtraInfo(String extraInfo) { | |||||
| this.extraInfo = extraInfo; | |||||
| } | |||||
| /**是否关注公众号**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否关注公众号",name="isSubscribe") | |||||
| private Integer isSubscribe; | |||||
| //渠道名称 | //渠道名称 | ||||
| @Transient | @Transient | ||||
| @@ -331,6 +326,22 @@ public class WxCUser implements Serializable { | |||||
| this.sceneDescription = sceneDescription; | this.sceneDescription = sceneDescription; | ||||
| } | } | ||||
| public String getExtraInfo() { | |||||
| return extraInfo; | |||||
| } | |||||
| public void setExtraInfo(String extraInfo) { | |||||
| this.extraInfo = extraInfo; | |||||
| } | |||||
| public Integer getIsSubscribe() { | |||||
| return isSubscribe; | |||||
| } | |||||
| public void setIsSubscribe(Integer isSubscribe) { | |||||
| this.isSubscribe = isSubscribe; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -362,6 +373,7 @@ public class WxCUser implements Serializable { | |||||
| ,Latitude_ASC("`latitude` ASC"),Latitude_DESC("`latitude` DESC") | ,Latitude_ASC("`latitude` ASC"),Latitude_DESC("`latitude` DESC") | ||||
| ,LoginCount_ASC("`login_count` ASC"),LoginCount_DESC("`login_count` DESC") | ,LoginCount_ASC("`login_count` ASC"),LoginCount_DESC("`login_count` DESC") | ||||
| ,ExtraInfo_ASC("`extra_info` ASC"),ExtraInfo_DESC("`extra_info` DESC") | ,ExtraInfo_ASC("`extra_info` ASC"),ExtraInfo_DESC("`extra_info` DESC") | ||||
| ,IsSubscribe_ASC("`is_subscribe` ASC"),IsSubscribe_DESC("`is_subscribe` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -5,13 +5,13 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumCouponSendSendType { | public enum EnumCouponSendSendType { | ||||
| // 2:停车发券 3:核销发券 | |||||
| // 2:停车发券 3:核销发券 4: B端刷卡发券 | |||||
| UNKNOWN(-1, "未知"), | UNKNOWN(-1, "未知"), | ||||
| INJECT(0, "精准发券"), | INJECT(0, "精准发券"), | ||||
| ACTIVE(1, "主动(保留)"), | ACTIVE(1, "主动(保留)"), | ||||
| CAR_STOP(2, "停车发券"), | CAR_STOP(2, "停车发券"), | ||||
| COUPON_VERIFY(3, "核销发券"), | COUPON_VERIFY(3, "核销发券"), | ||||
| B_MICROPAY(4, "B端刷卡发券") | |||||
| ; | ; | ||||
| public static EnumCouponSendSendType getEnum(Integer code) { | public static EnumCouponSendSendType getEnum(Integer code) { | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumUserIsSubscribe { | |||||
| // 0-否 1-是 | |||||
| NO(0, "N"), | |||||
| YES(1, "Y") | |||||
| ; | |||||
| public static EnumUserIsSubscribe getEnum(Integer code) { | |||||
| for (EnumUserIsSubscribe value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumUserIsSubscribe(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCouponOrder; | import com.iformall.domain.po.WxCouponOrder; | ||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.domain.po.WxOrder; | |||||
| import com.iformall.domain.vo.CUserDateAmountVo; | import com.iformall.domain.vo.CUserDateAmountVo; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -70,6 +71,13 @@ public interface WxCouponOrderService { | |||||
| */ | */ | ||||
| boolean sendCouponAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser); | boolean sendCouponAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser); | ||||
| /** | |||||
| * B端刷卡支付发券 | |||||
| * @param order | |||||
| * @param bUser | |||||
| */ | |||||
| boolean sendCouponAfterMicroPay(String tenantId, Long orderId, Long cUserId); | |||||
| /** | /** | ||||
| * 核销分账 | * 核销分账 | ||||
| * @param couponOrder | * @param couponOrder | ||||
| @@ -133,6 +133,6 @@ public interface WxOrderService { | |||||
| * @param orderId | * @param orderId | ||||
| * @param payOrderId | * @param payOrderId | ||||
| */ | */ | ||||
| void shareForMicroPay(Long orderId, Long payOrderId); | |||||
| void shareForMicroPay(String tenantId, Long orderId, Long payOrderId); | |||||
| } | } | ||||
| @@ -28,14 +28,13 @@ public interface WxPayOrderService { | |||||
| * @param payWay | * @param payWay | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| ResultData createMicroPayOrder(boolean isReal, WxAppinfo appInfo, WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay); | |||||
| ResultData createMicroPayOrder(boolean isReal, WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay); | |||||
| /** | /** | ||||
| * 微信支付订单查询 | * 微信支付订单查询 | ||||
| * @param appInfo 支付订单Appinfo | |||||
| * @param record 支付订单 | * @param record 支付订单 | ||||
| */ | */ | ||||
| ResultData payOrderQuery(WxAppinfo appInfo, WxPayOrder record); | |||||
| ResultData payOrderQuery(WxPayOrder record); | |||||
| /** | /** | ||||
| * 微信支付关闭订单 | * 微信支付关闭订单 | ||||
| @@ -46,10 +45,9 @@ public interface WxPayOrderService { | |||||
| /** | /** | ||||
| * 微信支付刷卡支付撤销订单 | * 微信支付刷卡支付撤销订单 | ||||
| * @param appInfo 支付订单Appinfo | |||||
| * @param record 支付订单 | * @param record 支付订单 | ||||
| */ | */ | ||||
| ResultData payOrderReverse(WxAppinfo appInfo, WxPayOrder record); | |||||
| ResultData payOrderReverse(WxPayOrder record); | |||||
| /** | /** | ||||
| * 异步通知 | * 异步通知 | ||||
| @@ -368,6 +368,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| // 微信分账 | // 微信分账 | ||||
| try { | try { | ||||
| WxPayOrder wxPayOrder = new WxPayOrder(); | WxPayOrder wxPayOrder = new WxPayOrder(); | ||||
| wxPayOrder.setTenantId(couponOrder.getTenantId()); | |||||
| wxPayOrder.setOrderId(couponOrder.getOrderId()); | wxPayOrder.setOrderId(couponOrder.getOrderId()); | ||||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | ||||
| wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder); | wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder); | ||||
| @@ -392,6 +393,20 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| return false; | return false; | ||||
| } | } | ||||
| @Override | |||||
| public boolean sendCouponAfterMicroPay(String tenantId, Long orderId, Long cUserId) { | |||||
| // B端刷卡支付发券 | |||||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(orderId); | |||||
| if (wxOrder != null) { | |||||
| try { | |||||
| return wxCouponSendService.sendCouponToUser(tenantId, cUserId, EnumCouponSendSendType.B_MICROPAY); | |||||
| } catch (Exception e) { | |||||
| logger.error("核销发券: " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | /** | ||||
| * 微信模板消息 | * 微信模板消息 | ||||
| * | * | ||||
| @@ -73,7 +73,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| @Transactional | @Transactional | ||||
| public boolean sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendSendType type) { | public boolean sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendSendType type) { | ||||
| //查询开关是否打开 | //查询开关是否打开 | ||||
| //查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch | |||||
| //查询停车或者核销的券 stopCarCouponSwitch, verifyCouponSwitch, microPayCouponSwitch | |||||
| WxCouponSend wxCouponSendQuery = new WxCouponSend(); | WxCouponSend wxCouponSendQuery = new WxCouponSend(); | ||||
| wxCouponSendQuery.setTenantId(tenantId); | wxCouponSendQuery.setTenantId(tenantId); | ||||
| wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode()); | wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode()); | ||||
| @@ -84,13 +84,17 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| actionType = EnumCouponSendSendType.CAR_STOP.getCode(); | actionType = EnumCouponSendSendType.CAR_STOP.getCode(); | ||||
| wxCouponSendQuery.setSendType(actionType); | wxCouponSendQuery.setSendType(actionType); | ||||
| configKey = "stopCarCouponSwitch"; | configKey = "stopCarCouponSwitch"; | ||||
| } | |||||
| else if (type == EnumCouponSendSendType.COUPON_VERIFY) { | |||||
| } else if (type == EnumCouponSendSendType.COUPON_VERIFY) { | |||||
| //核销 | //核销 | ||||
| actionType = EnumCouponSendSendType.COUPON_VERIFY.getCode(); | actionType = EnumCouponSendSendType.COUPON_VERIFY.getCode(); | ||||
| wxCouponSendQuery.setSendType(actionType); | wxCouponSendQuery.setSendType(actionType); | ||||
| configKey = "verifyConponSwitch"; | |||||
| } else { | |||||
| configKey = "verifyCouponSwitch"; | |||||
| } else if (type == EnumCouponSendSendType.B_MICROPAY) { | |||||
| //B端刷卡发券 | |||||
| actionType = EnumCouponSendSendType.B_MICROPAY.getCode(); | |||||
| wxCouponSendQuery.setSendType(actionType); | |||||
| configKey = "microPayCouponSwitch"; | |||||
| }else { | |||||
| return false; | return false; | ||||
| } | } | ||||
| WxMallConfig wxMallConfigQuery = new WxMallConfig(); | WxMallConfig wxMallConfigQuery = new WxMallConfig(); | ||||
| @@ -108,7 +112,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| try { | try { | ||||
| checkTime = pushLimitService.checkSendTime(tenantId); | checkTime = pushLimitService.checkSendTime(tenantId); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("push limit check time :" + e.getMessage()); | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -122,7 +126,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| try { | try { | ||||
| checkLimit = pushLimitService.checkCoupon(tenantId, cUserId, send.getCouponId()); | checkLimit = pushLimitService.checkCoupon(tenantId, cUserId, send.getCouponId()); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("券达到limit: " + e.getMessage()); | |||||
| } | } | ||||
| if (!checkLimit) { | if (!checkLimit) { | ||||
| continue; | continue; | ||||
| @@ -820,10 +820,11 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void shareForMicroPay(Long orderId, Long payOrderId) { | |||||
| public void shareForMicroPay(String tenantId, Long orderId, Long payOrderId) { | |||||
| // 微信分账 | // 微信分账 | ||||
| try { | try { | ||||
| WxPayOrder wxPayOrder = new WxPayOrder(); | WxPayOrder wxPayOrder = new WxPayOrder(); | ||||
| wxPayOrder.setTenantId(tenantId); | |||||
| wxPayOrder.setId(payOrderId); | wxPayOrder.setId(payOrderId); | ||||
| wxPayOrder.setOrderId(orderId); | wxPayOrder.setOrderId(orderId); | ||||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | ||||
| @@ -13,6 +13,7 @@ import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.pay.*; | import com.iformall.pay.*; | ||||
| import com.iformall.service.WxCouponOrderService; | |||||
| import com.iformall.service.WxOrderService; | import com.iformall.service.WxOrderService; | ||||
| import com.iformall.service.WxPayOrderService; | import com.iformall.service.WxPayOrderService; | ||||
| import com.iformall.utils.BeanUtils; | import com.iformall.utils.BeanUtils; | ||||
| @@ -26,7 +27,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Propagation; | import org.springframework.transaction.annotation.Propagation; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.util.*; | import java.util.*; | ||||
| @@ -61,9 +61,15 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantMapper wxMerchantMapper; | WxMerchantMapper wxMerchantMapper; | ||||
| @Autowired | |||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||||
| @Autowired | @Autowired | ||||
| WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | ||||
| @Autowired | |||||
| WxCouponOrderService wxCouponOrderService; | |||||
| JSONObject errorMap = JSON.parseObject("{" + | JSONObject errorMap = JSON.parseObject("{" + | ||||
| "\"NOAUTH\":{\"detail\":\"商户无此接口权限\",\"reason\":\"商户未开通此接口权限\",\"resolution\":\"请商户前往申请此接口权限\"}," + | "\"NOAUTH\":{\"detail\":\"商户无此接口权限\",\"reason\":\"商户未开通此接口权限\",\"resolution\":\"请商户前往申请此接口权限\"}," + | ||||
| "\"NOTENOUGH\":{\"detail\":\"余额不足\",\"reason\":\"用户帐号余额不足\",\"resolution\":\"用户帐号余额不足,请用户充值或更换支付卡后再支付\"}," + | "\"NOTENOUGH\":{\"detail\":\"余额不足\",\"reason\":\"用户帐号余额不足\",\"resolution\":\"用户帐号余额不足,请用户充值或更换支付卡后再支付\"}," + | ||||
| @@ -352,9 +358,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData createMicroPayOrder(boolean isReal, WxAppinfo appInfo, WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay) { | |||||
| public ResultData createMicroPayOrder(boolean isReal, WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay) { | |||||
| final IdWorker idworker = IdWorker.get(); | final IdWorker idworker = IdWorker.get(); | ||||
| WxAppinfo appInfo = getWxAppinfo(EnumOrderType.MICROPAY.getCode(), user.getTenantId()); | |||||
| EnumPayShare isShare = EnumPayShare.NO; | EnumPayShare isShare = EnumPayShare.NO; | ||||
| try { | try { | ||||
| @@ -414,6 +422,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Double dChargeFee = Math.ceil(record.getPayAmount() * 1.0D * payAccount.getRate() / 1000); | Double dChargeFee = Math.ceil(record.getPayAmount() * 1.0D * payAccount.getRate() / 1000); | ||||
| Integer share_amount = record.getPayAmount() - dChargeFee.intValue(); | Integer share_amount = record.getPayAmount() - dChargeFee.intValue(); | ||||
| record.setShareAmount(share_amount); | record.setShareAmount(share_amount); | ||||
| if (share_amount <= 0) { | |||||
| isShare = EnumPayShare.NO; | |||||
| record.setShare(isShare.getCode()); | |||||
| } | |||||
| } | } | ||||
| int sqlRow = wxPayOrderMapper.insertSelective(record); | int sqlRow = wxPayOrderMapper.insertSelective(record); | ||||
| @@ -456,7 +468,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| returnMap.put("orderId", orderNo); | returnMap.put("orderId", orderNo); | ||||
| String return_code = returnMap.get("return_code"); | String return_code = returnMap.get("return_code"); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| String openId = returnMap.get("openid"); | String openId = returnMap.get("openid"); | ||||
| String isSubscribe = returnMap.get("is_subscribe"); | String isSubscribe = returnMap.get("is_subscribe"); | ||||
| @@ -468,7 +480,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } else { | } else { | ||||
| String err_code = returnMap.get("err_code"); | String err_code = returnMap.get("err_code"); | ||||
| String errMsg = returnMap.get("err_code_des"); | String errMsg = returnMap.get("err_code_des"); | ||||
| if(errMsg.length() <= 0) { | |||||
| if (errMsg.length() <= 0) { | |||||
| errMsg = returnMap.get("return_msg"); | errMsg = returnMap.get("return_msg"); | ||||
| } | } | ||||
| record.setFailReason(errMsg); | record.setFailReason(errMsg); | ||||
| @@ -499,7 +511,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| WxMicroPayOrderSP wxPayOrderSP = new WxMicroPayOrderSP(); | WxMicroPayOrderSP wxPayOrderSP = new WxMicroPayOrderSP(); | ||||
| wxPayOrderSP.setAppid(appInfo.getParentAppId()); | wxPayOrderSP.setAppid(appInfo.getParentAppId()); | ||||
| wxPayOrderSP.setMch_id(payAccount.getMchId()); | wxPayOrderSP.setMch_id(payAccount.getMchId()); | ||||
| wxPayOrderSP.setSub_appid(user.getAppId()); | |||||
| wxPayOrderSP.setSub_appid(appInfo.getAppId()); | |||||
| wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | ||||
| wxPayOrderSP.setDevice_info(user.getPhone()); | wxPayOrderSP.setDevice_info(user.getPhone()); | ||||
| wxPayOrderSP.setNonce_str(noncestr); | wxPayOrderSP.setNonce_str(noncestr); | ||||
| @@ -527,10 +539,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| returnMap.put("orderId", orderNo); | returnMap.put("orderId", orderNo); | ||||
| String return_code = returnMap.get("return_code"); | String return_code = returnMap.get("return_code"); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| String openId = returnMap.get("openid"); | |||||
| String isSubscribe = returnMap.get("is_subscribe"); | |||||
| String openId = returnMap.get("sub_openid"); | |||||
| String isSubscribe = returnMap.get("sub_is_subscribe"); | |||||
| String transactionId = returnMap.get("transaction_id"); | String transactionId = returnMap.get("transaction_id"); | ||||
| record.setTransactionId(transactionId); | record.setTransactionId(transactionId); | ||||
| record.setUpdateTime(new Date()); | record.setUpdateTime(new Date()); | ||||
| @@ -539,7 +551,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } else { | } else { | ||||
| String err_code = returnMap.get("err_code"); | String err_code = returnMap.get("err_code"); | ||||
| String errMsg = returnMap.get("err_code_des"); | String errMsg = returnMap.get("err_code_des"); | ||||
| if(errMsg.length() <= 0) { | |||||
| if (errMsg.length() <= 0) { | |||||
| errMsg = returnMap.get("return_msg"); | errMsg = returnMap.get("return_msg"); | ||||
| } | } | ||||
| record.setFailReason(errMsg); | record.setFailReason(errMsg); | ||||
| @@ -646,23 +658,33 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| * 微信订单查询 | * 微信订单查询 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public ResultData payOrderQuery(WxAppinfo appInfo, WxPayOrder record) { | |||||
| public ResultData payOrderQuery(WxPayOrder record) { | |||||
| try { | try { | ||||
| if (StringUtils.isBlank(record.getPayOrderNo())) | if (StringUtils.isBlank(record.getPayOrderNo())) | ||||
| record.setPayOrderNo(String.valueOf(record.getId())); | record.setPayOrderNo(String.valueOf(record.getId())); | ||||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(record.getId()); | WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(record.getId()); | ||||
| if(payOrder != null) { | |||||
| if (payOrder != null) { | |||||
| record.setPayOrderStatus(payOrder.getPayOrderStatus()); | record.setPayOrderStatus(payOrder.getPayOrderStatus()); | ||||
| } else { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), "payOrder not found"); | |||||
| } | } | ||||
| WxOrder order = wxOrderMapper.selectByPrimaryKey(record.getOrderId()); | |||||
| if (order == null) { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), "Order not found"); | |||||
| } | |||||
| WxAppinfo appInfo = getWxAppinfo(order.getType(), record.getTenantId()); | |||||
| String response = wechatPayOrderQuery(appInfo, record); | String response = wechatPayOrderQuery(appInfo, record); | ||||
| logger.info("pay order query, " + record.toString() + ", response: " + response); | logger.info("pay order query, " + record.toString() + ", response: " + response); | ||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | Map<String, String> returnMap = WxPayment.xmlToMap(response); | ||||
| String return_code = returnMap.get("return_code"); | String return_code = returnMap.get("return_code"); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| String trade_state = returnMap.get("trade_state"); | String trade_state = returnMap.get("trade_state"); | ||||
| //SUCCESS—支付成功 | //SUCCESS—支付成功 | ||||
| @@ -812,7 +834,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | Map<String, String> returnMap = WxPayment.xmlToMap(response); | ||||
| String return_code = returnMap.get("return_code"); | String return_code = returnMap.get("return_code"); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); | record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); | ||||
| handlePayOrderStatusUpdate(record); | handlePayOrderStatusUpdate(record); | ||||
| @@ -906,10 +928,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| /** | /** | ||||
| * 微信刷卡支付撤销订单 | |||||
| * 撤销订单 - 刷卡支付 | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public ResultData payOrderReverse(WxAppinfo appInfo, WxPayOrder record) { | |||||
| public ResultData payOrderReverse(WxPayOrder record) { | |||||
| WxAppinfo appInfo = getWxAppinfo(EnumOrderType.MICROPAY.getCode(), record.getTenantId()); | |||||
| try { | try { | ||||
| String response = wechatPayOrderReverse(appInfo, record); | String response = wechatPayOrderReverse(appInfo, record); | ||||
| @@ -918,7 +942,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | Map<String, String> returnMap = WxPayment.xmlToMap(response); | ||||
| String return_code = returnMap.get("return_code"); | String return_code = returnMap.get("return_code"); | ||||
| String result_code = returnMap.get("result_code"); | String result_code = returnMap.get("result_code"); | ||||
| if("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equalsIgnoreCase(return_code)) { | |||||
| if ("SUCCESS".equals(result_code)) { | if ("SUCCESS".equals(result_code)) { | ||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); | record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); | ||||
| record.setUpdateTime(new Date()); | record.setUpdateTime(new Date()); | ||||
| @@ -999,6 +1023,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| // 普通商户号 | // 普通商户号 | ||||
| appinfo = wxAppinfoMapper.findByAppId(appId); | appinfo = wxAppinfoMapper.findByAppId(appId); | ||||
| if (appinfo == null) { | if (appinfo == null) { | ||||
| logger.error("appid not found: " + appId); | |||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| isNormal = true; | isNormal = true; | ||||
| @@ -1006,6 +1031,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| // 服务号 现在用hmac-sha256 | // 服务号 现在用hmac-sha256 | ||||
| appinfo = wxAppinfoMapper.findByAppId(subAppId); | appinfo = wxAppinfoMapper.findByAppId(subAppId); | ||||
| if (appinfo == null) { | if (appinfo == null) { | ||||
| logger.error("subappid not found: " + subAppId); | |||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| isNormal = false; | isNormal = false; | ||||
| @@ -1181,7 +1207,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| record.setFailReason(""); | record.setFailReason(""); | ||||
| wxPayOrderMapper.updateByPrimaryKeySelective(record); | wxPayOrderMapper.updateByPrimaryKeySelective(record); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("更新transactionId: " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | throw new MallinkException(ErrorCode.DB_FAIL); | ||||
| } | } | ||||
| return; | return; | ||||
| @@ -1198,22 +1224,34 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | ||||
| } | } | ||||
| WxAppinfo appinfo = getWxAppinfo(order.getType(), order.getTenantId()); | |||||
| WxAppinfo appinfo = getWxAppinfo(EnumOrderType.MICROPAY.getCode(), order.getTenantId()); | |||||
| // add c_user | // add c_user | ||||
| Date curDate = new Date(); | Date curDate = new Date(); | ||||
| WxCUser userQ = new WxCUser(); | WxCUser userQ = new WxCUser(); | ||||
| userQ.setOpenId(openId); | userQ.setOpenId(openId); | ||||
| userQ.setCreateDate(curDate); | |||||
| userQ.setUpdateDate(curDate); | |||||
| userQ.setAppId(appinfo.getAppId()); | userQ.setAppId(appinfo.getAppId()); | ||||
| WxCUser user1 = wxCUserMapper.findByOpenId(userQ); | WxCUser user1 = wxCUserMapper.findByOpenId(userQ); | ||||
| if(user1 == null) { | |||||
| if (user1 == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| userQ.setId(idWorker.nextId()); | userQ.setId(idWorker.nextId()); | ||||
| userQ.setCreateDate(curDate); | |||||
| userQ.setUpdateDate(curDate); | |||||
| if ("N".equalsIgnoreCase(isSubscribe)) { | |||||
| userQ.setIsSubscribe(EnumUserIsSubscribe.NO.getCode()); | |||||
| } else { | |||||
| userQ.setIsSubscribe(EnumUserIsSubscribe.NO.getCode()); | |||||
| } | |||||
| wxCUserMapper.insertSelective(userQ); | wxCUserMapper.insertSelective(userQ); | ||||
| } else { | } else { | ||||
| userQ.setId(user1.getId()); | userQ.setId(user1.getId()); | ||||
| userQ.setUpdateDate(curDate); | |||||
| if ("N".equalsIgnoreCase(isSubscribe)) { | |||||
| userQ.setIsSubscribe(EnumUserIsSubscribe.NO.getCode()); | |||||
| } else { | |||||
| userQ.setIsSubscribe(EnumUserIsSubscribe.NO.getCode()); | |||||
| } | |||||
| wxCUserMapper.updateByPrimaryKeySelective(userQ); | |||||
| } | } | ||||
| // 修改支付订单状态 | // 修改支付订单状态 | ||||
| @@ -1237,38 +1275,43 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| try { | try { | ||||
| int _count = wxOrderService.microPayOrderSuccess(order); | int _count = wxOrderService.microPayOrderSuccess(order); | ||||
| if (_count > 1) { | if (_count > 1) { | ||||
| logger.error("order micro pay count > 1"); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL); | throw new MallinkException(ErrorCode.ORDER_IS_FAIL); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("order status : " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单更新"); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单更新"); | ||||
| } | } | ||||
| // 支付分账 | |||||
| try { | |||||
| wxOrderService.shareForMicroPay(record.getOrderId(), record.getId()); | |||||
| logger.info("订单分账: orderId: {}, payOrderId: {}", record.getOrderId(), record.getId()); | |||||
| } catch (Exception e) { | |||||
| logger.error("订单分账失败: orderId: {}, payOrderId: {}", record.getOrderId(), record.getId()); | |||||
| logger.error(e.getMessage()); | |||||
| // throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND.getCode(), "分账更新"); | |||||
| } | |||||
| // 延迟3秒后分账 | |||||
| new Thread(() -> { | |||||
| String tenantId = record.getTenantId(); | |||||
| Long orderId = record.getOrderId(); | |||||
| Long payOrderId = record.getId(); | |||||
| try { | |||||
| Thread.currentThread().sleep(3000); | |||||
| } catch (Exception e) { | |||||
| logger.error("sleep error: " + e.getMessage()); | |||||
| } | |||||
| // TODO 支付发券 | |||||
| // 支付分账 | |||||
| try { | |||||
| wxOrderService.shareForMicroPay(tenantId, orderId, payOrderId); | |||||
| logger.info("订单分账: orderId: {}, payOrderId: {}", orderId, payOrderId); | |||||
| } catch (Exception e) { | |||||
| logger.error("订单分账失败: orderId: {}, payOrderId: {}", orderId, payOrderId); | |||||
| logger.error("订单分账失败: " +e.getMessage()); | |||||
| } | |||||
| }).start(); | |||||
| /* | |||||
| Map<String, String> msgMap = new HashMap<>(); | |||||
| // B端刷卡支付发券 | |||||
| try { | try { | ||||
| msgMap.put("name", String.valueOf(order.getCouponId())); | |||||
| msgMap.put("orderNo", String.valueOf(order.getId())); | |||||
| msgMap.put("createTime", Utility.getDataFormatString3(order.getCreateDate())); | |||||
| msgMap.put("standingTime", order.getCreateDate() + "-" + currentDate ); | |||||
| // 短信 通知 商户 | |||||
| //smsSenderHandler.sendSms("SMS_18195394", order.getMobile(), msgMap); | |||||
| wxCouponOrderService.sendCouponAfterMicroPay(record.getTenantId(), record.getOrderId(), record.getcUserId()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("pay success handle, sms send exception, payOrderi: " + updatePayOrder+ ", msgMap: " + msgMap.toString() + ", e: " + e.getMessage()); | |||||
| logger.error("订单刷卡失败: orderId: {}, payOrderId: {}", record.getOrderId(), record.getId()); | |||||
| logger.error("订单刷卡失败: " +e.getMessage()); | |||||
| } | } | ||||
| */ | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -1285,7 +1328,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| logger.error("pay handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | logger.error("pay handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | ||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | ||||
| } | } | ||||
| if(order.getType().equals(EnumOrderType.COUPON.getCode())) { | |||||
| if (order.getType().equals(EnumOrderType.COUPON.getCode())) { | |||||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | ||||
| if (user == null) { | if (user == null) { | ||||
| logger.error("pay handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | logger.error("pay handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | ||||
| @@ -1295,7 +1338,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| if (order.getPayment() > 0) { | if (order.getPayment() > 0) { | ||||
| // 订单金额不为0时, 支付订单未创建, 返回异常 | // 订单金额不为0时, 支付订单未创建, 返回异常 | ||||
| if (!(record.getId() >0)) { | |||||
| if (!(record.getId() > 0)) { | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); | throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1421,14 +1464,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| WxAppinfo appInfo = null; | WxAppinfo appInfo = null; | ||||
| WxAppinfo appinfoQ = new WxAppinfo(); | WxAppinfo appinfoQ = new WxAppinfo(); | ||||
| appinfoQ.setTenantId(tenentId); | appinfoQ.setTenantId(tenentId); | ||||
| if(orderType.equals(EnumOrderType.COUPON.getCode())) { | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| } else if(orderType.equals(EnumOrderType.MICROPAY.getCode())) { | |||||
| appinfoQ.setType(EnumAppType.B.getCode()); | |||||
| } else { | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| } | |||||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||||
| List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); | List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); | ||||
| if (appList.size() > 0) { | if (appList.size() > 0) { | ||||
| appInfo = appList.get(0); | appInfo = appList.get(0); | ||||
| @@ -31,10 +31,15 @@ | |||||
| <result column="longitude" jdbcType="DECIMAL" property="longitude"/> | <result column="longitude" jdbcType="DECIMAL" property="longitude"/> | ||||
| <result column="login_count" jdbcType="INTEGER" property="loginCount"/> | <result column="login_count" jdbcType="INTEGER" property="loginCount"/> | ||||
| <result column="extra_info" jdbcType="VARCHAR" property="extraInfo"/> | <result column="extra_info" jdbcType="VARCHAR" property="extraInfo"/> | ||||
| <result column="is_ubscribe" jdbcType="TINYINT" property="isSubscribe"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,`city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,`qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,`update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, `login_count`, `extra_info` | |||||
| `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, | |||||
| `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`, | |||||
| `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`, | |||||
| `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, | |||||
| `login_count`, `extra_info`, `is_subscribe` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -156,6 +161,10 @@ | |||||
| and `extra_info` = #{extraInfo} | and `extra_info` = #{extraInfo} | ||||
| </if> | </if> | ||||
| <if test=" null != isSubscribe "> | |||||
| and `is_subscribe` = #{isSubscribe} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -286,6 +286,7 @@ | |||||
| <if test="endDate != null"> | <if test="endDate != null"> | ||||
| AND create_date < #{endDate,jdbcType=TIMESTAMP} | AND create_date < #{endDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| order by create_date desc | |||||
| </select> | </select> | ||||