| @@ -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`; | |||
| 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`; | |||
| @@ -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) { | |||
| @@ -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<String, Object> 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; | |||
| } | |||
| @@ -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; | |||
| @@ -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); | |||
| } | |||
| @@ -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:"; | |||
| @@ -5,35 +5,43 @@ | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="mch_id" jdbcType="VARCHAR" property="mchId"/> | |||
| <result column="sub_mch_id" jdbcType="VARCHAR" property="subMchId"/> | |||
| <result column="sub_app_id" jdbcType="VARCHAR" property="subAppId"/> | |||
| <result column="api_key" jdbcType="VARCHAR" property="apiKey"/> | |||
| <result column="cert_path" jdbcType="VARCHAR" property="certPath"/> | |||
| <result column="merchant_api_key" jdbcType="VARCHAR" property="merchantApiKey"/> | |||
| <result column="merchant_key_path" jdbcType="VARCHAR" property="merchantKeyPath"/> | |||
| <result column="merchant_apiv3_key" jdbcType="VARCHAR" property="merchantApiv3Key"/> | |||
| <result column="merchant_cert_path" jdbcType="VARCHAR" property="merchantCertPath"/> | |||
| <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/> | |||
| <result column="notify_token" jdbcType="VARCHAR" property="notifyToken"/> | |||
| <result column="cert_path" jdbcType="VARCHAR" property="certPath"/> | |||
| <result column="merchant_cert_path" jdbcType="VARCHAR" property="merchantCertPath"/> | |||
| <result column="api_v3_key" jdbcType="VARCHAR" property="apiV3Key"/> | |||
| <result column="cert_serial_no" jdbcType="VARCHAR" property="certSerialNo"/> | |||
| <result column="private_key_path" jdbcType="VARCHAR" property="privateKeyPath"/> | |||
| <result column="private_cert_pem_path" jdbcType="VARCHAR" property="privateCertPemPath"/> | |||
| <result column="merchant_apiv3_key" jdbcType="VARCHAR" property="merchantApiv3Key"/> | |||
| <result column="merchant_cert_serial_no" jdbcType="VARCHAR" property="merchantCertSerialNo"/> | |||
| <result column="merchant_key_path" jdbcType="VARCHAR" property="merchantKeyPath"/> | |||
| <result column="merchant_cert_pem_path" jdbcType="VARCHAR" property="merchantCertPemPath"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="mch_type" jdbcType="INTEGER" property="mchType"/> | |||
| <result column="open_pay" jdbcType="VARCHAR" property="openPay"/> | |||
| <result column="pay_version" jdbcType="INTEGER" property="payVersion"/> | |||
| <result column="share" jdbcType="INTEGER" property="share"/> | |||
| <result column="rate" jdbcType="INTEGER" property="rate"/> | |||
| <result column="real_rate" jdbcType="INTEGER" property="realRate"/> | |||
| <result column="is_commission" jdbcType="INTEGER" property="isCommission"/> | |||
| <result column="system_rate" jdbcType="INTEGER" property="systemRate"/> | |||
| <result column="sell_rate" jdbcType="INTEGER" property="sellRate"/> | |||
| <result column="service_id" jdbcType="VARCHAR" property="serviceId"/> | |||
| <result column="pay_score_notify_url" jdbcType="VARCHAR" property="payScoreNotifyUrl"/> | |||
| <result column="api_v3_key" jdbcType="VARCHAR" property="apiV3Key"/> | |||
| <result column="cert_serial_no" jdbcType="VARCHAR" property="certSerialNo"/> | |||
| <result column="private_key_path" jdbcType="VARCHAR" property="privateKeyPath"/> | |||
| <result column="private_cert_pem_path" jdbcType="VARCHAR" property="privateCertPemPath"/> | |||
| <result column="business_type" jdbcType="INTEGER" property="businessType"/> | |||
| <result column="brandid" jdbcType="VARCHAR" property="brandid"/> | |||
| @@ -41,10 +49,15 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `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` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -64,30 +77,12 @@ | |||
| <if test=" null != subMchId "> | |||
| and `sub_mch_id` = #{subMchId} | |||
| </if> | |||
| <if test=" null != apiKey "> | |||
| and `api_key` like concat('%', #{apiKey},'%') | |||
| </if> | |||
| <if test=" null != notifyUrl "> | |||
| and `notify_url` like concat('%', #{notifyUrl},'%') | |||
| </if> | |||
| <if test=" null != certPath "> | |||
| and `cert_path` like concat('%', #{certPath},'%') | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != share "> | |||
| and `share` = #{share} | |||
| </if> | |||
| <if test=" null != rate "> | |||
| and `rate` = #{rate} | |||
| </if> | |||
| <if test=" null != realRate "> | |||
| and `real_rate` = #{realRate} | |||
| </if> | |||
| <if test=" null != isCommission "> | |||
| and `is_commission` = #{isCommission} | |||
| </if> | |||