diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022101100001__add_pay_account.sql b/mallinkAdmin/src/main/resources/db/migration/V2022101100001__add_pay_account.sql index aa40f353b..1dd3d4d0f 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2022101100001__add_pay_account.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2022101100001__add_pay_account.sql @@ -1,4 +1,7 @@ ALTER TABLE `mallink`.`wx_pay_account` ADD COLUMN `business_type` smallint(2) COMMENT '商圈版本' AFTER `merchant_cert_pem_path`, ADD COLUMN `brandid` varchar(50) COMMENT '商圈品牌ID' AFTER `business_type`, -ADD COLUMN `card_id` varchar(50) COMMENT '商圈会员卡ID' AFTER `brandid`; \ No newline at end of file +ADD COLUMN `card_id` varchar(50) COMMENT '商圈会员卡ID' AFTER `brandid`; + +ALTER TABLE `mallink`.`wx_pay_account` +ADD COLUMN `merchant_cert_serial_no` varchar(100) AFTER `cert_serial_no`; \ No newline at end of file diff --git a/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java b/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java index 08734a692..b8baa4700 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java @@ -146,11 +146,11 @@ public class BaseController { throw new MallinkException(ErrorCode.USER_APPINFO_NOT_EXIST); } - WxPayAccount payAccount = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, "payAccount:"+appinfo.getPayId(), WxPayAccount.class); + WxPayAccount payAccount = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, Constant.payaccountPrev+appinfo.getPayId(), WxPayAccount.class); if (null == payAccount) { payAccount = wxPayAccountService.getById(appinfo.getPayId()); if (null != payAccount) { - RedisCacheUtils.cache(objectCommonRedisTemplate, "payAccount:"+appinfo.getPayId(), payAccount, 24*60*60); + RedisCacheUtils.cache(objectCommonRedisTemplate, Constant.payaccountPrev+appinfo.getPayId(), payAccount, 24*60*60); } } if (null == payAccount) { diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessCircleController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessCircleController.java index 285502c77..1c7515761 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessCircleController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessCircleController.java @@ -7,13 +7,18 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.EnumAppPlat; +import com.iformall.enums.EnumBusinessCircleAuthorizeState; import com.iformall.service.*; +import com.iformall.utils.Constant; +import com.iformall.utils.RedisCacheUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; @@ -27,16 +32,31 @@ public class WxBusinessCircleController extends BaseController { @Autowired WxBusinessCircleOrderService wxBusinessCircleOrderService; + @Autowired + @Qualifier("objectCommonRedisTemplate") + RedisTemplate objectCommonRedisTemplate; + @ApiOperation("获取商圈授权状态") @GetMapping("/getAuthorizeState") - @RedisCache public ResultData getAuthorizeState() { logger.debug("[" + getIpAddr() + "] WxBusinessCircleController::getAuthorizeState"); CUser user = getCUser(); if(!EnumAppPlat.WX.equals(user.getAppPlat())){ return new ResultData(ErrorCode.SYS_METHOD_NOT_SUPPORT.getCode(),"平台不支持此请求"); } + String key = Constant.wx_user_authorize_state + user.getOpenId(); + EnumBusinessCircleAuthorizeState cacheObject = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, key, EnumBusinessCircleAuthorizeState.class); + if(cacheObject != null){ + return new ResultData(cacheObject); + } + ResultData resultData = wxBusinessCircleOrderService.syncauthorizeState(getTenantInfo(), user.getOpenId()); + if(Result.SUCCESS == resultData.code){ + EnumBusinessCircleAuthorizeState data = (EnumBusinessCircleAuthorizeState) resultData.data; + if(EnumBusinessCircleAuthorizeState.AUTHORIZED.equals(data)){ + RedisCacheUtils.cache(objectCommonRedisTemplate,key,data,3600*24*3); + } + } return resultData; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java index 9e1a4972b..9d18c0054 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java @@ -22,26 +22,39 @@ public class WxPayAccount extends TenantEntity { private String subMchId; @io.swagger.annotations.ApiModelProperty(value="服务商模式下的子商户公众账号ID",name="subAppId") private String subAppId; + @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") private String apiKey; + @io.swagger.annotations.ApiModelProperty(value="平台证书本地存放位置",name="certPath") + private String certPath; @io.swagger.annotations.ApiModelProperty(value="商户支付密钥",name="merchantApiKey") private String merchantApiKey; + @io.swagger.annotations.ApiModelProperty(value="商户自己的证书",name="merchantCertPath") + private String merchantCertPath; + @io.swagger.annotations.ApiModelProperty(value="微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)",name="notifyUrl") private String notifyUrl; @io.swagger.annotations.ApiModelProperty(value="tt回调token",name="notifyToken") private String notifyToken; - @io.swagger.annotations.ApiModelProperty(value="平台证书本地存放位置",name="certPath") - private String certPath; - @io.swagger.annotations.ApiModelProperty(value="商户自己的证书",name="merchantCertPath") - private String merchantCertPath; - @io.swagger.annotations.ApiModelProperty(value="商户自己的证书密钥文件",name="merchantCertPemPath") - private String merchantCertPemPath; - @io.swagger.annotations.ApiModelProperty(value="商户自己的密钥文件",name="merchantKeyPath") - private String merchantKeyPath; + + @io.swagger.annotations.ApiModelProperty(value="平台apiV3秘钥",name="apiV3Key") + private String apiV3Key; + @io.swagger.annotations.ApiModelProperty(value="平台证书序列号",name="certSerialNo") + private String certSerialNo; + @io.swagger.annotations.ApiModelProperty(value="平台私钥文件",name="privateKeyPath") + private String privateKeyPath; + @io.swagger.annotations.ApiModelProperty(value="平台证书密钥文件",name="privateCertPemPath") + private String privateCertPemPath; + @io.swagger.annotations.ApiModelProperty(value="商户自己的apiv3密钥",name="merchantApiv3Key") private String merchantApiv3Key; - - + @io.swagger.annotations.ApiModelProperty(value="商户自己的平台证书序列号",name="merchantCertSerialNo") + private String merchantCertSerialNo; + @io.swagger.annotations.ApiModelProperty(value="商户自己的密钥文件",name="merchantKeyPath") + private String merchantKeyPath; + @io.swagger.annotations.ApiModelProperty(value="商户自己的证书密钥文件",name="merchantCertPemPath") + private String merchantCertPemPath; + @io.swagger.annotations.ApiModelProperty(value="商户模式-0:普通商户模式1:服务商模式",name="type") private Integer type; @io.swagger.annotations.ApiModelProperty(value="EnumPayMchType 0:总分1:直连",name="mchType") @@ -56,6 +69,7 @@ public class WxPayAccount extends TenantEntity { private Integer rate; @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") private Integer realRate; + @io.swagger.annotations.ApiModelProperty(value="是否抽成",name="isCommission") private Integer isCommission; @io.swagger.annotations.ApiModelProperty(value="系统提点",name="systemRate") @@ -88,21 +102,12 @@ public class WxPayAccount extends TenantEntity { private String serviceId; @io.swagger.annotations.ApiModelProperty(value="微信支付分回调地址",name="payScoreNotifyUrl") private String payScoreNotifyUrl; - @io.swagger.annotations.ApiModelProperty(value="平台apiV3秘钥",name="apiV3Key") - private String apiV3Key; - @io.swagger.annotations.ApiModelProperty(value="平台证书序列号",name="certSerialNo") - private String certSerialNo; - @io.swagger.annotations.ApiModelProperty(value="平台私钥文件",name="privateKeyPath") - private String privateKeyPath; - @io.swagger.annotations.ApiModelProperty(value="平台证书密钥文件",name="privateCertPemPath") - private String privateCertPemPath; + @io.swagger.annotations.ApiModelProperty(value="商圈版本",name="businessType") private Integer businessType; - @io.swagger.annotations.ApiModelProperty(value="品牌ID",name="brandid") private String brandid; - @io.swagger.annotations.ApiModelProperty(value="商圈会员卡ID",name="cardId") private String cardId; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java index 666fa82c1..f9d3b705c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java @@ -320,14 +320,17 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { throw new MallinkException(ErrorCode.ORDER_PRESS_IS_OVERTIME); } }else{ - if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()) { + if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode() + || order.getOrderStatus()==EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode()) { logger.error("订单已支付: " + order.toString() + " , payWay: " + payWay.toString()); throw new MallinkException(ErrorCode.ORDER_HAD_PAY); - } else if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()) { + } else if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode() + || order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_COOPERATING_BREAK.getCode()) { logger.error("订单已取消: " + order.toString() + " , payWay: " + payWay.toString()); throw new MallinkException(ErrorCode.ORDER_HAD_CANCEL); } else { - if (order.getOrderStatus() != EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()) { + if (order.getOrderStatus() != EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode() + || order.getOrderStatus() != EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()) { logger.error("订单已支付: " + order.toString() + " , payWay: " + payWay.toString()); throw new MallinkException(ErrorCode.ORDER_IS_NOT_PAY); } diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index d0a0b620f..d5b8c76ca 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -42,6 +42,9 @@ public class Constant { // C端token public static final String tokenPrev = "weapp:token:"; + // 微信C授权积分状态缓存 + public static final String wx_user_authorize_state = "weapp:wxuser:authorizestate:"; + public static final String TOKEN_WXC_END = ":wx-cuser"; public static final String TOKEN_TTC_END = ":tt-cuser"; @@ -97,7 +100,7 @@ public class Constant { //获取mall信息 public static final String appinfoPrev = "appinfo:"; - public static final String payaccountPrev = "payaccount:"; + public static final String payaccountPrev = "payAccount:"; public static final String sharingReceicerPrev = "sharingReceicer:"; public static final String mallinfoPrev = "mallinfo:"; public static final String subMallinfoPrev = "mallinfo:subMallinfo:"; diff --git a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml index 01dea7fdf..cc946fbf9 100644 --- a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml @@ -5,35 +5,43 @@ + + + - - + + - - + + + + + + + + + + + - - - - @@ -41,10 +49,15 @@ - `id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`sub_app_id`,`api_key`,`merchant_api_key`,`notify_url`,`notify_token`,`cert_path`, - `merchant_cert_path`,`type`,`mch_type`,`open_pay`,`share`,`rate`,`real_rate`,`is_commission`,`system_rate`,`sell_rate`, - `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_pem_path`, - `merchant_key_path`,`merchant_apiv3_key`,`merchant_cert_pem_path`,`business_type`,`brandid`,`card_id` + `id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`sub_app_id`, + `api_key`,`cert_path`,`merchant_api_key`,`merchant_cert_path`, + `notify_url`,`notify_token`, + `api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_pem_path`, + `merchant_apiv3_key`,`merchant_cert_serial_no`,`merchant_key_path`,`merchant_cert_pem_path`, + `type`,`mch_type`,`open_pay`,`pay_version`,`share`,`rate`,`real_rate`, + `is_commission`,`system_rate`,`sell_rate`, + `service_id`,`pay_score_notify_url`, + `business_type`,`brandid`,`card_id` @@ -64,30 +77,12 @@ and `sub_mch_id` = #{subMchId} - - - and `api_key` like concat('%', #{apiKey},'%') - - - - and `notify_url` like concat('%', #{notifyUrl},'%') - - - - and `cert_path` like concat('%', #{certPath},'%') - and `type` = #{type} and `share` = #{share} - - and `rate` = #{rate} - - - and `real_rate` = #{realRate} - and `is_commission` = #{isCommission}