فهرست منبع

Merge remote-tracking branch 'origin/developer' into developerC

zhijiezhao 3 سال پیش
والد
کامیت
36abea0cb4

+ 107 - 0
src/main/java/com/caimei365/order/controller/PayNonOrderApi.java

@@ -364,4 +364,111 @@ public class PayNonOrderApi {
         return payNonOrderService.vipCheck(recordId);
         return payNonOrderService.vipCheck(recordId);
     }
     }
 
 
+
+    /**
+     * 开通认证通会员-微信线上支付
+     * @param payVipDto {
+     *                  vipRecordId   会员购买记录Id
+     *                  returnUrl     页面回调地址
+     *                  code          微信小程序code
+     *                  state         微信公众号state参数
+     * }
+     */
+    @ApiOperation("开通认证通会员-微信线上支付")
+    @PostMapping("/auth/vip/wechat")
+    public ResponseJson<JSONObject> payAuthVipByWeChat(PayVipDto payVipDto, @RequestHeader HttpHeaders headers){
+        if (null == payVipDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payVipDto.getCode())) {
+            return ResponseJson.error("微信code不能为空!", null);
+        }
+        return payNonOrderService.payAuthVipByWeChat(payVipDto, headers);
+    }
+
+    /**
+     * 开通认证通会员-支付宝线上支付
+     * @param payVipDto {
+     *                  vipRecordId   会员购买记录Id
+     *                  returnUrl     页面回调地址
+     * }
+     */
+    @ApiOperation("开通认证通会员-支付宝线上支付")
+    @PostMapping("/auth/vip/alipay")
+    public ResponseJson<JSONObject> payAuthVipByAlipay(PayVipDto payVipDto, @RequestHeader HttpHeaders headers){
+        if (null == payVipDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payVipDto.getReturnUrl())) {
+            return ResponseJson.error("回调地址不能为空!", null);
+        }
+        return payNonOrderService.payAuthVipByAlipay(payVipDto, headers);
+    }
+
+    /**
+     * 开通认证通会员-银联线上支付
+     * @param payVipDto {
+     *               vipRecordId   会员购买记录Id
+     *               returnUrl     页面回调地址
+     *               bankCode      银行编码(银联支付使用)
+     *               userType      用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
+     * }
+     */
+    @ApiOperation("开通认证通会员-银联线上支付")
+    @PostMapping("/auth/vip/union")
+    public ResponseJson<JSONObject> payAuthVipByUnionPay(PayVipDto payVipDto, @RequestHeader HttpHeaders headers){
+        if (null == payVipDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payVipDto.getReturnUrl())) {
+            return ResponseJson.error("回调地址不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payVipDto.getBankCode())) {
+            return ResponseJson.error("银行编码不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payVipDto.getUserType())) {
+            return ResponseJson.error("银行用户类型不能为空!", null);
+        }
+        return payNonOrderService.payAuthVipByUnionPay(payVipDto, headers);
+    }
+
+    /**
+     * 开通认证通会员-支付回调
+     */
+    @ApiOperation("开通认证通会员-支付回调")
+    @GetMapping("/auth/vip/callback")
+    public String paymentAuthVipCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException {
+        if (StringUtils.isBlank(data)) {
+            return "回调参数失败";
+        }
+        return payNonOrderService.paymentAuthVipCallback(data);
+    }
+
+    /**
+     * 开通认证通会员-线上退款
+     * @param payVipDto {
+     *               vipRecordId   会员购买记录Id
+     *               code          退款口令
+     * }
+     */
+    @ApiOperation("开通认证通会员-线上退款)")
+    @PostMapping("/auth/vip/online/refund")
+    public ResponseJson<JSONObject> authVipOnlineRefund(PayVipDto payVipDto) throws NoSuchAlgorithmException, InvalidKeySpecException {
+        if (null == payVipDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payVipDto.getCode()) || !"SVIP".equals(payVipDto.getCode())) {
+            return ResponseJson.error("退款口令code不正确!", null);
+        }
+        return payNonOrderService.superVipOnlineRefund(payVipDto);
+    }
+
+    @ApiOperation("购买认证通会员-查询是否购买成功")
+    @GetMapping("/auth/vip/check")
+    public ResponseJson authVipCheck(Integer vipRecordId) {
+        if (null == vipRecordId) {
+            return ResponseJson.error("购买记录id不能为空!", null);
+        }
+        return payNonOrderService.authVipCheck(vipRecordId);
+    }
 }
 }

+ 9 - 3
src/main/java/com/caimei365/order/controller/PayOrderApi.java

@@ -86,7 +86,7 @@ public class PayOrderApi {
 
 
     /**
     /**
      *  生成网银支付链接
      *  生成网银支付链接
-     * @param payLinkDto {
+     * @param payLinkDto {vvv
      *                   orderId       订单ID
      *                   orderId       订单ID
      *                   vipRecordId   会员购买记录Id
      *                   vipRecordId   会员购买记录Id
      * }
      * }
@@ -94,12 +94,18 @@ public class PayOrderApi {
     @ApiOperation("生成网银支付链接(旧:/PayOrder/payLink)")
     @ApiOperation("生成网银支付链接(旧:/PayOrder/payLink)")
     @PostMapping("/link")
     @PostMapping("/link")
     public ResponseJson<String> getPayLink(PayLinkDto payLinkDto) {
     public ResponseJson<String> getPayLink(PayLinkDto payLinkDto) {
-        if (null == payLinkDto.getOrderId() && null == payLinkDto.getVipRecordId()) {
-            return ResponseJson.error("订单Id和会员购买记录Id不能同时为空!", null);
+        if (null == payLinkDto.getOrderId() && null == payLinkDto.getVipRecordId() && null == payLinkDto.getAuthVipRecordId()) {
+            return ResponseJson.error("订单Id和会员购买记录Id和认证通会员购买记录Id不能同时为空!", null);
         }
         }
         if (null != payLinkDto.getOrderId() && null != payLinkDto.getVipRecordId()) {
         if (null != payLinkDto.getOrderId() && null != payLinkDto.getVipRecordId()) {
             return ResponseJson.error("订单Id和会员购买记录Id不能同时出现!", null);
             return ResponseJson.error("订单Id和会员购买记录Id不能同时出现!", null);
         }
         }
+        if (null != payLinkDto.getAuthVipRecordId() && null != payLinkDto.getVipRecordId()) {
+            return ResponseJson.error("认证通会员购买记录Id和会员购买记录Id不能同时出现!", null);
+        }
+        if (null != payLinkDto.getOrderId() && null != payLinkDto.getAuthVipRecordId()) {
+            return ResponseJson.error("订单Id和认证通会员购买记录Id不能同时出现!", null);
+        }
         return payOrderService.getPayLink(payLinkDto);
         return payOrderService.getPayLink(payLinkDto);
     }
     }
 
 

+ 7 - 0
src/main/java/com/caimei365/order/mapper/BaseMapper.java

@@ -224,4 +224,11 @@ public interface BaseMapper {
     String findType(String mbOrderId);
     String findType(String mbOrderId);
 
 
     Double getonlineMoney(Integer userId);
     Double getonlineMoney(Integer userId);
+
+    /**
+     * 查询认证通用户名称
+     * @param userId
+     * @return
+     */
+    AuthUserVo getAuthUser(Integer userId);
 }
 }

+ 53 - 0
src/main/java/com/caimei365/order/mapper/PayOrderMapper.java

@@ -7,6 +7,7 @@ import com.caimei365.order.model.vo.CouponCheckVo;
 import com.caimei365.order.model.vo.OrderPayLinkVo;
 import com.caimei365.order.model.vo.OrderPayLinkVo;
 import com.caimei365.order.model.vo.OrderVo;
 import com.caimei365.order.model.vo.OrderVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -190,6 +191,54 @@ public interface PayOrderMapper {
      */
      */
     List<OrderReceiptRelationPo> getOnlineBalance(String currentTime);
     List<OrderReceiptRelationPo> getOnlineBalance(String currentTime);
 
 
+    /**
+     * 查询认证通会员开通历史记录
+     * @param authVipRecordId
+     * @return
+     */
+    VipRecordBo getAuthVipRecord(Integer authVipRecordId);
+
+    /**
+     * 查询认证通会员套餐价格
+     * @param packageId
+     * @return
+     */
+    Double getAuthVipPackagePrice(Integer packageId);
+
+    /**
+     * 查询认证通会员信息
+     * @param userId
+     * @return
+     */
+    UserVipPo getAuthVipInfo(int userId);
+
+    /**
+     * 查询认证通会员套餐信息
+     * @param vipId
+     * @return
+     */
+    AuthVipPackagePo getAuthVipPackageById(int vipId);
+
+    /**
+     * 更新认证通会员信息
+     */
+    void updateAuthVipInfo(UserVipPo authVip);
+    /**
+     * 新增认证通会员信息
+     */
+    void insertAuthVipInfo(UserVipPo authVip);
+    /**
+     * 更新认证通会员支付历史记录
+     */
+    void updateAuthVipRecord(VipRecordBo record);
+
+    /**
+     * 认证通会员支付链接
+     * @param recordId   会员购买记录Id
+     * @param amount  本次待付款金额
+     */
+    OrderPayLinkVo getAuthVipPayLink(@Param("recordId") int recordId, @Param("amount") Double amount);
+
     Double getCouponPrice(Integer couponId);
     Double getCouponPrice(Integer couponId);
 
 
     void insertCouponRecord(CouponRecordPo cr);
     void insertCouponRecord(CouponRecordPo cr);
@@ -201,4 +250,8 @@ public interface PayOrderMapper {
     Integer findClubType(Integer userId);
     Integer findClubType(Integer userId);
 
 
     List<CouponCheckVo> findCouponOrder();
     List<CouponCheckVo> findCouponOrder();
+
+    void deleteAuthVipRoleRelation(int userId);
+
+    void insertAuthVipRoleRelation(Integer userId, Integer roleId);
 }
 }

+ 5 - 0
src/main/java/com/caimei365/order/model/dto/PayLinkDto.java

@@ -24,6 +24,11 @@ public class PayLinkDto implements Serializable {
      */
      */
     @ApiModelProperty("会员购买记录Id")
     @ApiModelProperty("会员购买记录Id")
     private Integer vipRecordId;
     private Integer vipRecordId;
+    /**
+     * 认证通会员购买记录Id
+     */
+    @ApiModelProperty("认证通会员购买记录Id")
+    private Integer authVipRecordId;
     /**
     /**
      * 支付类型,1企业网银,2个人网银
      * 支付类型,1企业网银,2个人网银
      */
      */

+ 42 - 0
src/main/java/com/caimei365/order/model/po/AuthVipPackagePo.java

@@ -0,0 +1,42 @@
+package com.caimei365.order.model.po;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2022/2/14
+ */
+@Data
+public class AuthVipPackagePo {
+    /**
+     * id
+     */
+    private Integer id;
+
+    /**
+     * 套餐时长
+     */
+    private Integer duration;
+
+    /**
+     * 套餐规格:1月,2年
+     */
+    private Integer unit;
+
+    /**
+     * 原价
+     */
+    private BigDecimal originalPrice;
+
+    /**
+     * 现价
+     */
+    private BigDecimal price;
+}

+ 1 - 1
src/main/java/com/caimei365/order/model/po/DiscernReceiptPo.java

@@ -27,7 +27,7 @@ public class DiscernReceiptPo implements Serializable {
      */
      */
     private Integer payType;
     private Integer payType;
     /**
     /**
-     * 收款款项类型:1订单款,2非订单款,3返佣款 , 5供应商退款,6超级会员款 ,7二手商品上架费,8优惠券购买费
+     * 收款款项类型:1订单款,2非订单款,3返佣款 , 5供应商退款,6超级会员款 ,7二手商品上架费,8优惠券购买费,9认证通会员款
      */
      */
     private Integer receiptType;
     private Integer receiptType;
     /**
     /**

+ 5 - 1
src/main/java/com/caimei365/order/model/po/OrderReceiptRelationPo.java

@@ -18,7 +18,7 @@ public class OrderReceiptRelationPo implements Serializable {
      */
      */
     private Integer id;
     private Integer id;
     /**
     /**
-     * 关系类型:1返佣订单(返佣款)、2非返佣订单(订单款或者非订单款)、3超级会员款、4二手商品上架费
+     * 关系类型:1返佣订单(返佣款)、2非返佣订单(订单款或者非订单款)、3超级会员款、4二手商品上架费,5认证通会员款
      */
      */
     private Integer relationType;
     private Integer relationType;
     /**
     /**
@@ -41,6 +41,10 @@ public class OrderReceiptRelationPo implements Serializable {
      * 优惠券购买记录id
      * 优惠券购买记录id
      */
      */
     private Integer couponRecordId;
     private Integer couponRecordId;
+    /**
+     *  认证通会员购买记录Id
+     */
+    private Integer authVipRecordId;
     /**
     /**
      * 删除标记 0 否,其余是
      * 删除标记 0 否,其余是
      */
      */

+ 4 - 0
src/main/java/com/caimei365/order/model/po/SplitAccountPo.java

@@ -40,6 +40,10 @@ public class SplitAccountPo implements Serializable {
      * 优惠券购买记录id
      * 优惠券购买记录id
      */
      */
     private Integer couponRecordId;
     private Integer couponRecordId;
+    /**
+     * 认证通会员购买记录id
+     */
+    private Integer authVipRecordId;
     /**
     /**
      * 分账类型:1公账-专票,2私账-无票,3公账-普票,4供应商子商户,5佣金账户
      * 分账类型:1公账-专票,2私账-无票,3公账-普票,4供应商子商户,5佣金账户
      */
      */

+ 30 - 0
src/main/java/com/caimei365/order/model/vo/AuthUserVo.java

@@ -0,0 +1,30 @@
+package com.caimei365.order.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/8/6
+ */
+@Data
+public class AuthUserVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 用户id
+     */
+    private Integer authUserId;
+
+    /**
+     * 供应商名称
+     */
+    private String name;
+
+    /**
+     * 手机号
+     */
+    private String mobile;
+}

+ 4 - 0
src/main/java/com/caimei365/order/model/vo/OrderPayLinkVo.java

@@ -29,6 +29,10 @@ public class OrderPayLinkVo implements Serializable {
      * 优惠券购买记录id
      * 优惠券购买记录id
      */
      */
     private Integer couponRecordId;
     private Integer couponRecordId;
+    /**
+     * 认证通会员购买记录Id
+     */
+    private Integer authVipRecordId;
     /**
     /**
      * 会员套餐包月数
      * 会员套餐包月数
      */
      */

+ 46 - 0
src/main/java/com/caimei365/order/service/PayNonOrderService.java

@@ -111,4 +111,50 @@ public interface PayNonOrderService {
 
 
     ResponseJson vipCheck(Integer recordId);
     ResponseJson vipCheck(Integer recordId);
 
 
+    /**
+     * 开通认证通会员-微信线上支付
+     * @param payVipDto {
+     *               vipRecordId   会员购买记录Id
+     *               returnUrl     页面回调地址
+     *               code          微信小程序code
+     *               state         微信公众号state参数
+     * }
+     */
+    ResponseJson<JSONObject> payAuthVipByWeChat(PayVipDto payVipDto, HttpHeaders headers);
+    /**
+     * 开通认证通会员-支付宝线上支付
+     * @param payVipDto {
+     *               vipRecordId   会员购买记录Id
+     *               returnUrl     页面回调地址
+     * }
+     */
+    ResponseJson<JSONObject> payAuthVipByAlipay(PayVipDto payVipDto, HttpHeaders headers);
+    /**
+     * 开通认证通会员-银联线上支付
+     * @param payVipDto {
+     *               vipRecordId   会员购买记录Id
+     *               returnUrl     页面回调地址
+     *               bankCode      银行编码(银联支付使用)
+     *               userType      用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
+     * }
+     */
+    ResponseJson<JSONObject> payAuthVipByUnionPay(PayVipDto payVipDto, HttpHeaders headers);
+    /**
+     * 开通认证通会员-支付回调
+     */
+    String paymentAuthVipCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException;
+    /**
+     * 开通认证通会员-线上退款
+     * @param payVipDto {
+     *               vipRecordId   会员购买记录Id
+     *               code          退款口令
+     * }
+     */
+    ResponseJson<JSONObject> authVipOnlineRefund(PayVipDto payVipDto) throws NoSuchAlgorithmException, InvalidKeySpecException;
+
+    /**
+     * 购买认证通会员-查询是否购买成功
+     * @return
+     */
+    ResponseJson authVipCheck(Integer vipRecordId);
 }
 }

+ 413 - 1
src/main/java/com/caimei365/order/service/impl/PayNonOrderServiceImpl.java

@@ -29,7 +29,6 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
-import java.math.BigDecimal;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.InvalidKeySpecException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
@@ -58,6 +57,8 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
     private String secondHandUrl;
     private String secondHandUrl;
     @Value("${pay.vip-notify-url}")
     @Value("${pay.vip-notify-url}")
     private String superVipUrl;
     private String superVipUrl;
+    @Value("${pay.auth-vip-notify-url}")
+    private String authVipUrl;
     @Value("${pay.coupon-notify-url}")
     @Value("${pay.coupon-notify-url}")
     private String couponUrl;
     private String couponUrl;
     @Resource
     @Resource
@@ -1040,4 +1041,415 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
         payOrderMapper.updateSplitAccountByPay(mbOrderId);
         payOrderMapper.updateSplitAccountByPay(mbOrderId);
         return "SUCCESS";
         return "SUCCESS";
     }
     }
+
+    /**
+     * 开通认证通会员-微信线上支付
+     *
+     * @param payVipDto {
+     *                  vipRecordId   会员购买记录Id
+     *                  returnUrl     页面回调地址
+     *                  code          微信小程序code
+     *                  state         微信公众号state参数
+     *                  }
+     * @param headers
+     */
+    @Override
+    public ResponseJson<JSONObject> payAuthVipByWeChat(PayVipDto payVipDto, HttpHeaders headers) {
+        PayParamBo tempParam = new PayParamBo();
+        // payDto -> payParam
+        BeanUtils.copyProperties(payVipDto, tempParam);
+        ResponseJson<PayParamBo> jsonParam = getWeChatResponseJson(tempParam, headers);
+        if (-1 == jsonParam.getCode()) {
+            return ResponseJson.error(jsonParam.getMsg(), null);
+        }
+        PayParamBo payParam = jsonParam.getData();
+        // 获取会员套餐记录
+        VipRecordBo record = payOrderMapper.getAuthVipRecord(payParam.getVipRecordId());
+        if (null == record) {
+            log.info("【开通认证通会员-微信线上支付】该笔记录异常,记录Id:" + payParam.getVipRecordId());
+            return ResponseJson.error("该笔记录异常!", null);
+        }
+        if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
+            return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
+        }
+        payParam.setVipId(record.getPackageId());
+        payParam.setUserId(record.getUserId());
+        // 获取会员套餐价格
+        Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
+        payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
+        payParam.setNotifyUrl(authVipUrl);
+        log.info("【开通认证通会员微信支付】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId() + ",获取openId:" + payParam.getOpenId());
+        return toPayAuthVip(payParam, headers);
+    }
+
+    /**
+     * 开通认证通会员-支付宝线上支付
+     *
+     * @param payVipDto {
+     *                  vipRecordId   会员购买记录Id
+     *                  returnUrl     页面回调地址
+     *                  }
+     * @param headers
+     */
+    @Override
+    public ResponseJson<JSONObject> payAuthVipByAlipay(PayVipDto payVipDto, HttpHeaders headers) {
+        PayParamBo payParam = new PayParamBo();
+        // payDto -> payParam
+        BeanUtils.copyProperties(payVipDto, payParam);
+        //支付宝支付
+        payParam.setPayWay("ALIPAY");
+        payParam.setPayType("ALIPAY_H5");
+        // 获取会员套餐记录
+        VipRecordBo record = payOrderMapper.getAuthVipRecord(payParam.getVipRecordId());
+        if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
+            return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
+        }
+        payParam.setVipId(record.getPackageId());
+        payParam.setUserId(record.getUserId());
+        // 获取会员套餐价格
+        Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
+        payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
+        payParam.setNotifyUrl(authVipUrl);
+        log.info("【开通认证通会员支付宝支付】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId());
+        return toPayAuthVip(payParam, headers);
+    }
+
+    /**
+     * 开通认证通会员-银联线上支付
+     *
+     * @param payVipDto {
+     *                  vipRecordId   会员购买记录Id
+     *                  returnUrl     页面回调地址
+     *                  bankCode      银行编码(银联支付使用)
+     *                  userType      用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
+     *                  }
+     * @param headers
+     */
+    @Override
+    public ResponseJson<JSONObject> payAuthVipByUnionPay(PayVipDto payVipDto, HttpHeaders headers) {
+        PayParamBo payParam = new PayParamBo();
+        // payDto -> payParam
+        BeanUtils.copyProperties(payVipDto, payParam);
+        // 银联支付
+        payParam.setPayWay("UNIONPAY");
+        payParam.setPayType("GATEWAY_UNIONPAY");
+        // 获取会员套餐记录
+        VipRecordBo record = payOrderMapper.getAuthVipRecord(payParam.getVipRecordId());
+        if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
+            return ResponseJson.error("该笔记录已支付,请勿重复支付!", null);
+        }
+        payParam.setVipId(record.getPackageId());
+        payParam.setUserId(record.getUserId());
+        // 获取会员套餐价格
+        Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
+        payParam.setPayAmount(MathUtil.mul(price, 100).intValue());
+        payParam.setNotifyUrl(authVipUrl);
+        log.info("【开通认证通会员银联线上支付】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId());
+        return toPayAuthVip(payParam, headers);
+    }
+
+
+    /**
+     * 开通认证通会员支付
+     */
+    private ResponseJson<JSONObject> toPayAuthVip(PayParamBo payParam, HttpHeaders headers) {
+        // 定义支付请求结果
+        JSONObject result = null;
+        try {
+            // 时间戳
+            long time = System.currentTimeMillis() / 1000;
+            // 设置支付基础参数
+            JSONObject json = getPayJsonObject(payParam, headers, time);
+            // 支付环境
+            String environment = "";
+            if (payParam.getNotifyUrl().contains("18002")) {
+                environment = "DEV";
+            } else if (payParam.getNotifyUrl().contains("core-b")) {
+                environment = "BETA";
+            }
+            // 商户订单号
+            String orderId = payParam.getUserId() + "R" + payParam.getVipRecordId() + "V" + payParam.getVipId() + "T" + time + environment;
+            json.put("orderId", orderId);
+            //商品名称
+            String product = "采美订单" + orderId;
+            json.put("product", product);
+            //支付类型
+            String payType = PayUtil.getPayTypeId(payParam.getPayType(), payParam.getUserType());
+            String attach = payParam.getVipId() + "," + payParam.getUserId() + "," + payParam.getVipRecordId() + "," + payType;
+            json.put("attach", attach);
+            // 开通认证通会员默认公账
+            List<Map<String, String>> list = new ArrayList<>();
+            Map<String, String> map = new HashMap<>(3);
+            map.put("subUserNo", PayUtil.publicAccountNo);
+            // 1按比例分账
+            map.put("splitBillType", "1");
+            // 1比例值总额
+            map.put("splitBillValue", "1");
+            list.add(map);
+            String splitBillDetail = JSONObject.toJSONString(list);
+            json.put("splitBillDetail", splitBillDetail);
+            String sign = PayUtil.getPaySign(json, PayUtil.merKey);
+            json.put("sign", sign);
+            // 私钥加密
+            String data = RSAUtil.privateEncrypt(json.toJSONString(), PayUtil.merKey);
+            // 提交
+            result = PayUtil.httpGet("https://platform.mhxxkj.com/paygateway/mbpay/order/v1", PayUtil.merAccount, data);
+        } catch (Exception e) {
+            log.error("错误信息", e);
+            return ResponseJson.error("支付失败!", null);
+        }
+        String code = result.getString("code");
+        if (!"000000".equals(code)) {
+            String msg = result.getString("msg");
+            log.info("第三方支付失败>>>>>>>msg:" + msg);
+            return ResponseJson.error(msg, null);
+        }
+        // 保存开通认证通会员分账参数
+        JSONObject data = result.getJSONObject("data");
+        SplitAccountPo splitAccount = new SplitAccountPo();
+        splitAccount.setAuthVipRecordId(payParam.getVipRecordId());
+        // 认证通会员 公账-专票
+        splitAccount.setType(1);
+        // 待分账总金额
+        double splitAmount = MathUtil.div(payParam.getPayAmount(), 100).doubleValue();
+        // 总手续费
+        double procedureFee;
+        if ("UNIONPAY".equals(payParam.getPayWay())) {
+            procedureFee = 8.00;
+        } else {
+            //手续费
+            procedureFee = MathUtil.mul(splitAmount, 0.0038, 2).doubleValue();
+            if (MathUtil.compare(procedureFee, 0) == 0) {
+                procedureFee = 0.01;
+            }
+        }
+        splitAmount = MathUtil.sub(splitAmount, procedureFee).doubleValue();
+        splitAccount.setSplitAccount(splitAmount);
+        splitAccount.setMbOrderId(data.getString("mbOrderId"));
+        splitAccount.setOrderRequestNo(data.getString("orderId"));
+        splitAccount.setPayStatus(0);
+        // 保存分账详情
+        payOrderMapper.insertSplitAccount(splitAccount);
+        log.info("【开通认证通会员支付成功!】>>>>>>>>>>>vipRecordId:" + payParam.getVipRecordId() + ",data:" + data.toJSONString());
+        return ResponseJson.success(result);
+    }
+
+    /**
+     * 开通认证通会员-支付回调
+     *
+     * @param data
+     */
+    @Override
+    public String paymentAuthVipCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException {
+        log.info("******************** 开通认证通会员异步回调 start *******************");
+        // 公钥解密
+        JSONObject json = PayUtil.publicKeyDecrypt(data, PayUtil.publicKey);
+        log.info("【开通认证通会员异步回调】>>>>>>>>>>>公钥解密:" + json);
+        // 公钥验签
+        String signaa = json.getString("sign");
+        json.remove("sign");
+        String signbb = PayUtil.getPaySign(json, PayUtil.publicKey);
+        if (!signaa.equals(signbb)) {
+            return "验签失败";
+        }
+        // 订单状态
+        String orderStatus = json.getString("orderStatus");
+        // 平台唯一流水号
+        String mbOrderId = json.getString("mbOrderId");
+        // 商户唯一订单号
+        String orderRequestNo = json.getString("orderId");
+        // 金额,以元为单位
+        Double amount = json.getDouble("amount");
+        String payFormData = json.toJSONString();
+        log.info("【开通认证通会员异步回调】>>>>>>>>>>>支付订单状态:" + orderStatus);
+        if ("FAILED".equals(orderStatus)) {
+            return "支付失败";
+        }
+        log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>本次支付金额:" + amount);
+        // 附加数据,支付时若有传输则原样返回(vipId,userId,recordId,payType),下单时为空,则不返回该数据
+        String attach = json.getString("attach");
+        String[] split = attach.split(",");
+        int vipId = 0;
+        int userId = 0;
+        int recordId = 0;
+        int payType = 0;
+        try {
+            // 会员套餐Id
+            vipId = Integer.parseInt(split[0]);
+            // 用户Id
+            userId = Integer.parseInt(split[1]);
+            // 购买历史记录Id
+            recordId = Integer.parseInt(split[2]);
+            // 支付方式
+            payType = Integer.parseInt(split[3]);
+        } catch (NumberFormatException e) {
+            log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>获取回调参数解析失败!");
+        }
+        //认证通会员数据库修改
+        UserVipPo authVip = new UserVipPo();
+        UserVipPo dbAuthVip = payOrderMapper.getAuthVipInfo(userId);
+        Date beginTime = new Date();
+        if (null != dbAuthVip) {
+            authVip.setId(dbAuthVip.getId());
+            if (dbAuthVip.getEndTime().compareTo(beginTime) > 0) {
+                // 有效期内续费,用原结束时间作为开始时间来计算结束时间
+                beginTime = dbAuthVip.getEndTime();
+                authVip.setBeginTime(beginTime);
+            } else {
+                // 过期重新续费
+                authVip.setBeginTime(beginTime);
+            }
+        } else {
+            authVip.setBeginTime(beginTime);
+        }
+        authVip.setUserId(userId);
+        authVip.setUpdateTime(new Date());
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(beginTime);
+        // 查询认证通会员套餐信息
+        AuthVipPackagePo packagePo = payOrderMapper.getAuthVipPackageById(vipId);
+        cal.add(1 == packagePo.getUnit() ? Calendar.MONTH : Calendar.YEAR, packagePo.getDuration());
+        authVip.setEndTime(cal.getTime());
+        authVip.setDelFlag(0);
+        if (null != authVip.getId()) {
+            // 更新会员信息
+            payOrderMapper.updateAuthVipInfo(authVip);
+            if (authVip.getBeginTime().compareTo(beginTime) >= 0) {
+                // 删除原有角色关联
+                payOrderMapper.deleteAuthVipRoleRelation(userId);
+                // 会员过期重新分配角色
+                saveRoleRelation(userId, "1");
+            }
+        } else {
+            // 新增会员信息
+            payOrderMapper.insertAuthVipInfo(authVip);
+            // 删除原有角色关联
+            payOrderMapper.deleteAuthVipRoleRelation(userId);
+            // 分配角色
+            saveRoleRelation(userId, "1");
+        }
+        // 修改会员历史记录支付状态
+        VipRecordBo record = payOrderMapper.getAuthVipRecord(recordId);
+        record.setPayStatus(1);
+        record.setBeginTime(beginTime);
+        record.setEndTime(cal.getTime());
+        record.setPayWay(1);
+        record.setPayType(payType);
+        record.setPayTime(new Date());
+        payOrderMapper.updateAuthVipRecord(record);
+        // 修改支付链接状态
+        OrderPayLinkVo orderPayLink = payOrderMapper.getAuthVipPayLink(recordId, amount);
+        if (null != orderPayLink && (12 == payType || 17 == payType)) {
+            orderPayLink.setPayStatus(1);
+            payOrderMapper.updateOrderPayLinkStatus(orderPayLink);
+        }
+        Date date = new Date();
+        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
+        // 保存收款记录
+        DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
+        discernReceipt.setPayWay(1);
+        discernReceipt.setPayType(record.getPayType());
+        discernReceipt.setReceiptType(9);
+        discernReceipt.setReceiptStatus(3);
+        discernReceipt.setReceiptAmount(amount);
+        discernReceipt.setConfirmType(4);
+        discernReceipt.setRePayFlag(1);
+        discernReceipt.setFormData(payFormData);
+        discernReceipt.setReceiptDate(curDateStr);
+        discernReceipt.setConfirmDate(curDateStr);
+        discernReceipt.setReviewDate(curDateStr);
+        discernReceipt.setUpdateDate(curDateStr);
+        discernReceipt.setDelFlag(0);
+        // 保存 收款记录
+        baseMapper.insertDiscernReceipt(discernReceipt);
+        log.info("【开通认证通会员异步回调】>>>>>>>>>>>>>>保存识别款项(insert[cm_discern_receipt])id:" + discernReceipt.getId() + ",vipRecordId:" + recordId);
+        // 收款项和订单关系表
+        OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
+        relation.setReceiptId(discernReceipt.getId());
+        relation.setAuthVipRecordId(recordId);
+        relation.setAssociateAmount(amount);
+        relation.setMbOrderId(mbOrderId);
+        relation.setOrderRequestNo(orderRequestNo);
+        relation.setSplitStatus(1);
+        relation.setRelationType(3);
+        relation.setDelFlag(0);
+        // 保存 收款项和订单关系
+        baseMapper.insertOrderReceiptRelation(relation);
+        log.info("【开通认证通会员异步回调】>>>>>>>>>>>收款项和购买历史关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",vipRecordId:" + recordId);
+        //修改分账付款状态
+        payOrderMapper.updateSplitAccountByPay(mbOrderId);
+        return "SUCCESS";
+    }
+
+    /**
+     * 开通认证通会员-线上退款
+     *
+     * @param payVipDto {
+     *                  vipRecordId   会员购买记录Id
+     *                  code          退款口令
+     *                  }
+     */
+    @Override
+    public ResponseJson<JSONObject> authVipOnlineRefund(PayVipDto payVipDto) throws NoSuchAlgorithmException, InvalidKeySpecException {
+        // 认证通会员支付记录
+        DiscernReceiptVo discernReceipt = orderCommonMapper.getVipDiscernReceipt(payVipDto.getVipRecordId());
+        JSONObject json = new JSONObject();
+        json.put("merAccount", PayUtil.merAccount);
+        // 当前时间戳
+        long time = System.currentTimeMillis() / 1000;
+        json.put("time", time);
+        //商户退款流水号,由商户自行生成,必须唯一
+        String randomLetter = CodeUtil.randomLetter(6);
+        String merchantRefundNo = payVipDto.getVipRecordId() + payVipDto.getCode() + randomLetter + "##" + discernReceipt.getId();
+        json.put("merchantRefundNo", merchantRefundNo);
+        //退款金额,单位分,必须大于0
+        double refundAmt = MathUtil.mul(discernReceipt.getAssociateAmount(), 100).doubleValue();
+        json.put("refundAmt", refundAmt);
+        //退款原因
+        String refundCause = "用户主动退款";
+        json.put("refundCause", refundCause);
+        //平台交易订单号
+        json.put("mbOrderId", discernReceipt.getMbOrderId());
+        String sign = PayUtil.getPaySign(json, PayUtil.merKey);
+        json.put("sign", sign);
+        String data = PayUtil.privateKeyEncrypt(json, PayUtil.merKey);
+        JSONObject result = PayUtil.httpPost("https://platform.mhxxkj.com/paygateway/mbrefund/orderRefund/v1", PayUtil.merAccount, data);
+        String code = result.getString("code");
+        if (!"000000".equals(code)) {
+            String msg = result.getString("msg");
+            log.info("【线上退款】失败>>>>>>>msg:" + msg);
+            return ResponseJson.error(result);
+        }
+        log.info("【线上退款】成功>>>>>>>vipRecordId:" + payVipDto.getVipRecordId());
+        return ResponseJson.success(result);
+    }
+
+    @Override
+    public ResponseJson<Map<String,Map<String,String>>> authVipCheck(Integer vipRecordId) {
+        // 获取会员套餐记录
+        VipRecordBo record = payOrderMapper.getAuthVipRecord(vipRecordId);
+        Map<String, Map<String,String>> map1 = new HashMap<>();
+        Map<String, String> map2 = new HashMap<>();
+        if (null != record.getPayStatus() && 1 == record.getPayStatus()) {
+            map2.put("status", "1");
+            map1.put("data", map2);
+            return ResponseJson.success("支付成功!", map1);
+        }
+        map2.put("status", "0");
+        map1.put("data", map2);
+        return ResponseJson.success("支付失败", map1);
+    }
+
+    public void saveRoleRelation(Integer userId, String roleIds) {
+        if (StringUtils.isNotEmpty(roleIds)) {
+            // 设置用户角色
+            String[] split = roleIds.split(",");
+            for (String s : split) {
+                if (org.springframework.util.StringUtils.hasLength(s)) {
+                    // 保存用户角色关系
+                    payOrderMapper.insertAuthVipRoleRelation(userId, Integer.valueOf(s));
+                }
+            }
+        }
+    }
 }
 }

+ 23 - 4
src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java

@@ -375,8 +375,10 @@ public class PayOrderServiceImpl implements PayOrderService {
                 return ResponseJson.error("订单不存在", null);
                 return ResponseJson.error("订单不存在", null);
             }
             }
             orderPayLink = payOrderMapper.getOrderPayLink(payLinkDto.getOrderId(), null);
             orderPayLink = payOrderMapper.getOrderPayLink(payLinkDto.getOrderId(), null);
-        } else {
+        } else if (null != payLinkDto.getVipRecordId()) {
             orderPayLink = payOrderMapper.getVipPayLink(payLinkDto.getVipRecordId(), null);
             orderPayLink = payOrderMapper.getVipPayLink(payLinkDto.getVipRecordId(), null);
+        } else {
+            orderPayLink = payOrderMapper.getAuthVipPayLink(payLinkDto.getAuthVipRecordId(), null);
         }
         }
         // 时间戳
         // 时间戳
         long time = System.currentTimeMillis() / 1000;
         long time = System.currentTimeMillis() / 1000;
@@ -406,11 +408,19 @@ public class PayOrderServiceImpl implements PayOrderService {
             Integer mouth = payOrderMapper.getVipPackageDurationById(record.getPackageId());
             Integer mouth = payOrderMapper.getVipPackageDurationById(record.getPackageId());
             orderPayLink.setVipMonth(mouth);
             orderPayLink.setVipMonth(mouth);
             orderPayLink.setUnpaidAmount(price);
             orderPayLink.setUnpaidAmount(price);
+        }else if (null != payLinkDto.getAuthVipRecordId()){
+            // 获取认证通会员套餐记录
+            VipRecordBo record = payOrderMapper.getAuthVipRecord(payLinkDto.getAuthVipRecordId());
+            // 获取认证通会员套餐信息
+            AuthVipPackagePo packagePo = payOrderMapper.getAuthVipPackageById(record.getPackageId());
+            orderPayLink.setVipMonth(1 == packagePo.getUnit() ? packagePo.getDuration() : packagePo.getDuration() * 12);
+            orderPayLink.setUnpaidAmount(packagePo.getPrice().doubleValue());
         } else {
         } else {
             orderPayLink.setUnpaidAmount(payLinkDto.getUnpaidAmount());
             orderPayLink.setUnpaidAmount(payLinkDto.getUnpaidAmount());
         }
         }
         orderPayLink.setOrderId(payLinkDto.getOrderId());
         orderPayLink.setOrderId(payLinkDto.getOrderId());
         orderPayLink.setVipRecordId(payLinkDto.getVipRecordId());
         orderPayLink.setVipRecordId(payLinkDto.getVipRecordId());
+        orderPayLink.setAuthVipRecordId(payLinkDto.getAuthVipRecordId());
         orderPayLink.setPayType(payLinkDto.getPayType());
         orderPayLink.setPayType(payLinkDto.getPayType());
         orderPayLink.setRedirectLink(redirectLink);
         orderPayLink.setRedirectLink(redirectLink);
         orderPayLink.setLinkLogo(linkLogo);
         orderPayLink.setLinkLogo(linkLogo);
@@ -445,14 +455,16 @@ public class PayOrderServiceImpl implements PayOrderService {
     @Override
     @Override
     public ResponseJson<Map<String, Object>> linkPayData(String linkLogo) {
     public ResponseJson<Map<String, Object>> linkPayData(String linkLogo) {
         OrderPayLinkVo orderPayLink = payOrderMapper.getPayLinkByLinkLogo(linkLogo);
         OrderPayLinkVo orderPayLink = payOrderMapper.getPayLinkByLinkLogo(linkLogo);
-        if (null == orderPayLink || (null == orderPayLink.getOrderId() && null == orderPayLink.getVipRecordId())) {
+        if (null == orderPayLink || (null == orderPayLink.getOrderId() && null == orderPayLink.getVipRecordId() && null == orderPayLink.getAuthVipRecordId())) {
             // 已重新生成链接
             // 已重新生成链接
             return ResponseJson.error("链接已更新,请重新获取", null);
             return ResponseJson.error("链接已更新,请重新获取", null);
         }
         }
         // 链接状态,0成功
         // 链接状态,0成功
         int code = 0;
         int code = 0;
         String userName = "";
         String userName = "";
-        // 链接类型:1订单,2超级会员
+        // 认证通供应商信息
+        AuthUserVo authUser = null;
+        // 链接类型:1订单,2超级会员,3认证通会员
         int type = 0;
         int type = 0;
         // 订单支付记录
         // 订单支付记录
         List<DiscernReceiptVo> discernReceiptList = null;
         List<DiscernReceiptVo> discernReceiptList = null;
@@ -464,12 +476,18 @@ public class PayOrderServiceImpl implements PayOrderService {
             discernReceiptList = orderCommonMapper.getDiscernReceipt(order.getOrderId(), order.getShopOrderIds());
             discernReceiptList = orderCommonMapper.getDiscernReceipt(order.getOrderId(), order.getShopOrderIds());
             // 机构信息
             // 机构信息
             userName = baseMapper.getUserNameByUserId(order.getUserId());
             userName = baseMapper.getUserNameByUserId(order.getUserId());
-        } else {
+        } else if (null != orderPayLink.getVipRecordId()) {
             type = 2;
             type = 2;
             // 获取会员套餐记录
             // 获取会员套餐记录
             VipRecordBo record = payOrderMapper.getVipPackageRecord(orderPayLink.getVipRecordId());
             VipRecordBo record = payOrderMapper.getVipPackageRecord(orderPayLink.getVipRecordId());
             // 机构信息
             // 机构信息
             userName = baseMapper.getUserNameByUserId(record.getUserId());
             userName = baseMapper.getUserNameByUserId(record.getUserId());
+        } else {
+            type = 3;
+            // 获取会员套餐记录
+            VipRecordBo record = payOrderMapper.getAuthVipRecord(orderPayLink.getAuthVipRecordId());
+            // 机构信息
+            authUser = baseMapper.getAuthUser(record.getUserId());
         }
         }
         if (orderPayLink.getEffectiveTime().compareTo(new Date()) < 0) {
         if (orderPayLink.getEffectiveTime().compareTo(new Date()) < 0) {
             //链接失效
             //链接失效
@@ -504,6 +522,7 @@ public class PayOrderServiceImpl implements PayOrderService {
         map.put("type", type);
         map.put("type", type);
         map.put("orderPayLink", orderPayLink);
         map.put("orderPayLink", orderPayLink);
         map.put("userName", userName);
         map.put("userName", userName);
+        map.put("authUser", authUser);
         map.put("code", code);
         map.put("code", code);
         map.put("time", time);
         map.put("time", time);
         return ResponseJson.success(map);
         return ResponseJson.success(map);

+ 8 - 2
src/main/resources/mapper/BaseMapper.xml

@@ -264,9 +264,9 @@
     </insert>
     </insert>
     <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id"
     <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id"
             parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
             parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
-        INSERT INTO cm_receipt_order_relation (relationType, receiptId, associateAmount, orderId, couponRecordId, vipRecordId, delFlag,
+        INSERT INTO cm_receipt_order_relation (relationType, receiptId, associateAmount, orderId, couponRecordId, vipRecordId,authVipRecordId, delFlag,
                                                mbOrderId, orderRequestNo, splitStatus, productId)
                                                mbOrderId, orderRequestNo, splitStatus, productId)
-        VALUES (#{relationType}, #{receiptId}, #{associateAmount}, #{orderId},#{couponRecordId}, #{vipRecordId}, #{delFlag}, #{mbOrderId},
+        VALUES (#{relationType}, #{receiptId}, #{associateAmount}, #{orderId},#{couponRecordId}, #{vipRecordId}, #{authVipRecordId}, #{delFlag}, #{mbOrderId},
                 #{orderRequestNo}, #{splitStatus}, #{productId})
                 #{orderRequestNo}, #{splitStatus}, #{productId})
     </insert>
     </insert>
     <insert id="insertBeansHistory" parameterType="com.caimei365.order.model.po.UserBeansHistoryPo">
     <insert id="insertBeansHistory" parameterType="com.caimei365.order.model.po.UserBeansHistoryPo">
@@ -333,4 +333,10 @@
     <select id="getonlineMoney" resultType="java.lang.Double">
     <select id="getonlineMoney" resultType="java.lang.Double">
         select onlineMoney FROM USER WHERE userId = #{userId}
         select onlineMoney FROM USER WHERE userId = #{userId}
     </select>
     </select>
+    <select id="getAuthUser" resultType="com.caimei365.order.model.vo.AuthUserVo">
+        select authUserId,name,mobile
+        from cm_brand_auth_user
+        where authUserId = #{userId}
+        LIMIT 1
+    </select>
 </mapper>
 </mapper>

+ 64 - 5
src/main/resources/mapper/PayOrderMapper.xml

@@ -37,14 +37,19 @@
         SET ableUserMoney = #{ableUserMoney}
         SET ableUserMoney = #{ableUserMoney}
         WHERE userID = #{userId}
         WHERE userID = #{userId}
     </update>
     </update>
+    <delete id="deleteAuthVipRoleRelation">
+        DELETE FROM auth_role_user WHERE user_id = #{userId}
+    </delete>
     <insert id="insertOrderPayLink" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.vo.OrderPayLinkVo" useGeneratedKeys="true">
     <insert id="insertOrderPayLink" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.vo.OrderPayLinkVo" useGeneratedKeys="true">
-        INSERT INTO cm_order_pay_link (orderId, vipRecordId, vipMonth, linkLogo, unpaidAmount, generateTime, effectiveTime, payStatus, payType, delFlag)
-        VALUES (#{orderId}, #{vipRecordId}, #{vipMonth}, #{linkLogo}, #{unpaidAmount}, #{generateTime}, #{effectiveTime}, #{payStatus}, #{payType}, #{delFlag})
+        INSERT INTO cm_order_pay_link (orderId, vipRecordId, authVipRecordId, vipMonth, linkLogo, unpaidAmount,
+                                       generateTime, effectiveTime, payStatus, payType, delFlag)
+        VALUES (#{orderId}, #{vipRecordId}, #{authVipRecordId}, #{vipMonth}, #{linkLogo}, #{unpaidAmount},
+                #{generateTime}, #{effectiveTime}, #{payStatus}, #{payType}, #{delFlag})
     </insert>
     </insert>
     <insert id="insertSplitAccount" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.po.SplitAccountPo">
     <insert id="insertSplitAccount" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.po.SplitAccountPo">
-        INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId,vipRecordId, type, subUserNo, splitAccount,
+        INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId,vipRecordId, authVipRecordId, type, subUserNo, splitAccount,
                                         mbOrderId, orderRequestNo,payStatus, productType, splitTime)
                                         mbOrderId, orderRequestNo,payStatus, productType, splitTime)
-        VALUES (#{orderId}, #{productId}, #{orderProductId}, #{shopId},#{couponRecordId},#{vipRecordId}, #{type}, #{subUserNo}, #{splitAccount},
+        VALUES (#{orderId}, #{productId}, #{orderProductId}, #{shopId},#{couponRecordId},#{vipRecordId}, #{authVipRecordId}, #{type}, #{subUserNo}, #{splitAccount},
                 #{mbOrderId}, #{orderRequestNo}, #{payStatus}, #{productType}, NOW());
                 #{mbOrderId}, #{orderRequestNo}, #{payStatus}, #{productType}, NOW());
     </insert>
     </insert>
     <insert id="insertPayShop" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.PayShopPo">
     <insert id="insertPayShop" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.PayShopPo">
@@ -63,9 +68,16 @@
         INSERT INTO cm_svip_user(userId, beginTime, endTime, delFlag, updateTime)
         INSERT INTO cm_svip_user(userId, beginTime, endTime, delFlag, updateTime)
         VALUES (#{userId}, #{beginTime}, #{endTime}, #{delFlag}, #{updateTime})
         VALUES (#{userId}, #{beginTime}, #{endTime}, #{delFlag}, #{updateTime})
     </insert>
     </insert>
+    <insert id="insertAuthVipInfo">
+        INSERT INTO auth_vip_user(authUserId, beginTime, endTime, delFlag, updateTime)
+        VALUES (#{userId}, #{beginTime}, #{endTime}, #{delFlag}, #{updateTime})
+    </insert>
     <insert id="insertCouponRecord" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.CouponRecordPo" useGeneratedKeys="true">
     <insert id="insertCouponRecord" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.CouponRecordPo" useGeneratedKeys="true">
         INSERT INTO cm_coupon_buyrecord (couponId, userId) VALUES (#{couponId},#{userId})
         INSERT INTO cm_coupon_buyrecord (couponId, userId) VALUES (#{couponId},#{userId})
     </insert>
     </insert>
+    <insert id="insertAuthVipRoleRelation">
+        INSERT INTO auth_role_user(user_id, role_id) VALUES(#{userId}, #{roleId})
+    </insert>
     <update id="updateUserVipInfo">
     <update id="updateUserVipInfo">
         UPDATE cm_svip_user set userId=#{userId}, beginTime=#{beginTime}, endTime=#{endTime}, delFlag=#{delFlag}, updateTime=#{updateTime}
         UPDATE cm_svip_user set userId=#{userId}, beginTime=#{beginTime}, endTime=#{endTime}, delFlag=#{delFlag}, updateTime=#{updateTime}
         WHERE userId = #{userId}
         WHERE userId = #{userId}
@@ -76,7 +88,7 @@
     </update>
     </update>
     <update id="updateOrderPayLink">
     <update id="updateOrderPayLink">
         UPDATE cm_order_pay_link SET
         UPDATE cm_order_pay_link SET
-            orderId = #{orderId}, vipRecordId = #{vipRecordId}, vipMonth = #{vipMonth}, linkLogo = #{linkLogo}, unpaidAmount = #{unpaidAmount}, generateTime = #{generateTime},
+            orderId = #{orderId}, vipRecordId = #{vipRecordId}, authVipRecordId = #{authVipRecordId}, vipMonth = #{vipMonth}, linkLogo = #{linkLogo}, unpaidAmount = #{unpaidAmount}, generateTime = #{generateTime},
             effectiveTime = #{effectiveTime}, payStatus = #{payStatus}, payType = #{payType}, delFlag = #{delFlag}
             effectiveTime = #{effectiveTime}, payStatus = #{payStatus}, payType = #{payType}, delFlag = #{delFlag}
         WHERE id = #{id}
         WHERE id = #{id}
     </update>
     </update>
@@ -122,6 +134,17 @@
         set payStatus = 1
         set payStatus = 1
         where id = #{recordId}
         where id = #{recordId}
     </update>
     </update>
+    <update id="bugFix">
+        UPDATE USER SET userMoney = ableUserMoney WHERE userId = #{userId}
+    </update>
+    <update id="updateAuthVipInfo">
+        UPDATE auth_vip_user set authUserId=#{userId}, beginTime=#{beginTime}, endTime=#{endTime}, delFlag=#{delFlag}, updateTime=#{updateTime}
+        WHERE authUserId = #{userId}
+    </update>
+    <update id="updateAuthVipRecord">
+        UPDATE auth_vip_history set payStatus=#{payStatus},payWay=#{payWay},payType=#{payType},beginTime=#{beginTime},endTime=#{endTime},payTime=#{payTime}
+        WHERE id = #{id}
+    </update>
     <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
     <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
         SELECT STATUS FROM cm_pay_online_switch WHERE id=1
         SELECT STATUS FROM cm_pay_online_switch WHERE id=1
     </select>
     </select>
@@ -177,6 +200,7 @@
             id,
             id,
             orderId,
             orderId,
             vipRecordId,
             vipRecordId,
+            authVipRecordId,
             vipMonth,
             vipMonth,
             linkLogo,
             linkLogo,
             unpaidAmount,
             unpaidAmount,
@@ -321,4 +345,39 @@
           AND co.delflag = 0
           AND co.delflag = 0
           AND cop.orderId NOT IN (SELECT orderId FROM cm_coupon_buyrecord WHERE orderId IS NOT NULL)
           AND cop.orderId NOT IN (SELECT orderId FROM cm_coupon_buyrecord WHERE orderId IS NOT NULL)
     </select>
     </select>
+    <select id="getAuthVipRecord" resultType="com.caimei365.order.model.bo.VipRecordBo">
+        SELECT id, authUserId as userId, packageId, price, payStatus FROM auth_vip_history WHERE id = #{authVipRecordId};
+    </select>
+    <select id="getAuthVipPackagePrice" resultType="java.lang.Double">
+        SELECT price FROM auth_vip_package WHERE id = #{packageId};
+    </select>
+    <select id="getAuthVipInfo" resultType="com.caimei365.order.model.po.UserVipPo">
+        SELECT id,authUserId as userId, beginTime, endTime, updateTime, delFlag
+        FROM auth_vip_user
+        WHERE authUserId = #{#userId}
+    </select>
+    <select id="getAuthVipPackageById" resultType="com.caimei365.order.model.po.AuthVipPackagePo">
+        select duration,unit,price from auth_vip_package where id =#{vipId}
+    </select>
+    <select id="getAuthVipPayLink" resultType="com.caimei365.order.model.vo.OrderPayLinkVo">
+        SELECT
+        id,
+        orderId,
+        vipRecordId,
+        linkLogo,
+        unpaidAmount,
+        generateTime,
+        effectiveTime,
+        payStatus,
+        payType,
+        delFlag
+        FROM
+        cm_order_pay_link
+        WHERE authVipRecordId = #{recordId}
+        <if test="amount != null">
+            AND unpaidAmount = #{amount}
+        </if>
+        AND delFlag = '0' AND payStatus = '0'
+        ORDER BY id DESC LIMIT 1
+    </select>
 </mapper>
 </mapper>