瀏覽代碼

抽离支付宝支付方法

udream-cxs 4 年之前
父節點
當前提交
fc74df6040

+ 58 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/neety/protocol/ChatMsgDTO.java

@@ -0,0 +1,58 @@
+package cn.com.ty.lift.ud.neety.protocol;
+
+import lombok.Data;
+
+/**
+ * 聊天记录
+ * 
+ * @author Xson
+ * @date 2020-04-22
+ */
+@Data
+public class ChatMsgDTO {
+
+    /**
+     * session 会话
+     */
+    private String sessionid;
+
+    /**
+     * 来自
+     */
+    private String fromUser;
+
+    /**
+     * 到达
+     */
+    private Integer toUser;
+
+    /**
+     * 信息 聊天信息
+     */
+    private String msg;
+
+    /**
+     * 状态 0:正常1:屏蔽
+     */
+    private Integer statuz;
+
+    /**
+     * '消息类型:1文本、2图片、3视频、4语言'
+     */
+    private Integer type;
+
+    private String name;
+
+    private String avatarUrl;
+
+    private String signature;
+
+    private Integer age;
+
+    private Integer userLevel;
+
+    private Integer gender;
+    
+    private String createTime;
+
+}

+ 84 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/neety/protocol/IMMessage.java

@@ -0,0 +1,84 @@
+package cn.com.ty.lift.ud.neety.protocol;
+
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.msgpack.annotation.Message;
+
+/**
+ * 自定义消息实体类
+ * @author sKing
+ * 2020年5月9日
+ */
+@Message
+@Data
+public class IMMessage {
+
+    private String addr; // IP地址及端口
+    private String cmd; // 命令类型[LOGIN]或者[SYSTEM]或者[LOGOUT]
+    private long time; // 命令发送时间
+    private int online; // 当前在线人数
+    private String name; // 发送人
+    private String avatarUrl; // 头像
+    private String userId; // 用户id
+    private String receiver; // 接收人
+    private String msg; // 消息内容
+    private Integer type; // 发送消息类型
+    private Integer dura; // 语音音频时长
+    private String fromUser; // 当前用户id
+    private String sessionid; // 房间号
+    private int dataTable; // 消息来源1:问诊,2:出诊,3:附近的人
+
+    public void setMsg(String msg) {
+        this.msg = StringUtils.isNotBlank(msg) ?msg : null;
+    }
+
+    public IMMessage() {}
+
+    public IMMessage(String cmd, long time, int online, String msg) {
+        this.cmd = cmd;
+        this.time = time;
+        this.online = online;
+        this.msg = msg;
+    }
+
+    public IMMessage(String cmd, long time, String sender, String content, String room) {
+        this.cmd = cmd;
+        this.time = time;
+        this.name = sender;
+        this.msg = content;
+        this.sessionid = room;
+    }
+
+    public IMMessage(String cmd, long time, String sender) {
+        this.cmd = cmd;
+        this.time = time;
+        this.name = sender;
+    }
+
+    public IMMessage(String cmd, String type, long time, String sender, String content, String headPic, String room) {
+        this.cmd = cmd;
+        this.time = time;
+        this.name = sender;
+        this.msg = content;
+        this.avatarUrl = headPic;
+        this.sessionid = room;
+        this.type = StringUtils.isNotBlank(type) == true ? Integer.parseInt(type) : 1;
+    }
+
+    public IMMessage(String addr, String cmd, long time, int online, String name, String avatarUrl, String userId, String receiver, String msg, Integer type, Integer dura, String fromUser, String sessionid, int dataTable) {
+        this.addr = addr;
+        this.cmd = cmd;
+        this.time = time;
+        this.online = online;
+        this.name = name;
+        this.avatarUrl = avatarUrl;
+        this.userId = userId;
+        this.receiver = receiver;
+        this.msg = msg;
+        this.type = null == type ? type : 1;
+        this.dura = dura;
+        this.fromUser = fromUser;
+        this.sessionid = sessionid;
+        this.dataTable = dataTable;
+    }
+}

+ 198 - 216
lift-ud-service/src/main/java/cn/com/ty/lift/ud/pay/controller/AlipayController.java

@@ -1,14 +1,11 @@
 package cn.com.ty.lift.ud.pay.controller;
 
 import cn.com.ty.lift.ud.chat.mapper.entity.LiftCaseEntity;
-import cn.com.ty.lift.ud.chat.service.IChatSessionService;
 import cn.com.ty.lift.ud.chat.service.ILiftCaseService;
 import cn.com.ty.lift.ud.common.RandomizingID;
 import cn.com.ty.lift.ud.operation.mapper.entity.UserLevelRuleEntity;
 import cn.com.ty.lift.ud.operation.mapper.entity.VipFeeSettingEntity;
-import cn.com.ty.lift.ud.operation.service.ICommissionSettingService;
 import cn.com.ty.lift.ud.operation.service.IUserLevelRuleService;
-import cn.com.ty.lift.ud.operation.service.IUserRebateRuleService;
 import cn.com.ty.lift.ud.operation.service.IVipFeeSettingService;
 import cn.com.ty.lift.ud.pay.alipay.AlipayConfig;
 import cn.com.ty.lift.ud.pay.alipay.AlipaySupport;
@@ -27,16 +24,12 @@ import cn.com.ty.lift.ud.payment.service.IUserRechargeDetailService;
 import cn.com.ty.lift.ud.payment.service.IUserWithdrawService;
 import cn.com.ty.lift.ud.question.mapper.QuestionBankMapper;
 import cn.com.ty.lift.ud.question.mapper.entity.QuestionBankEntity;
-import cn.com.ty.lift.ud.question.service.IQuestionOperateService;
 import cn.com.ty.lift.ud.schoolVideo.mapper.entity.SchoolVideoEntity;
-import cn.com.ty.lift.ud.schoolVideo.service.ISchoolVideoOperateService;
 import cn.com.ty.lift.ud.schoolVideo.service.ISchoolVideoService;
 import cn.com.ty.lift.ud.tableDict.service.ITableDictService;
-import cn.com.ty.lift.ud.userAccount.service.IUserAccountService;
 import cn.com.ty.lift.ud.userInfo.mapper.UserInfoMapper;
 import cn.com.ty.lift.ud.userInfo.mapper.entity.UserInfoEntity;
 import cn.com.ty.lift.ud.userInfo.service.IUserInfoService;
-import cn.com.ty.lift.ud.userRebate.service.IUserRebateService;
 import cn.com.ty.lift.ud.utils.UUIDUtil;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.alibaba.fastjson.JSON;
@@ -53,7 +46,6 @@ import com.alipay.api.request.AlipayFundTransUniTransferRequest;
 import com.alipay.api.response.AlipayDataBillBalanceQueryResponse;
 import com.alipay.api.response.AlipayFundTransUniTransferResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import io.netty.channel.Channel;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -71,7 +63,9 @@ import java.math.BigDecimal;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 /**
  * 支付宝前端控制器
@@ -91,8 +85,6 @@ public class AlipayController {
     @Autowired
     private ILiftCaseService liftCaseService;
     @Autowired
-    private IChatSessionService chatSessionService;
-    @Autowired
     private IUserBillService userBillService;
     @Autowired
     private IUserRechargeDetailService userRechargeDetailService;
@@ -101,39 +93,36 @@ public class AlipayController {
     @Autowired
     private QuestionBankMapper questionBankMapper;
     @Autowired
-    private IQuestionOperateService iQuestionOperateService;
-    @Autowired
-    private ICommissionSettingService iCommissionSettingService;
-    @Autowired
-    private IUserBillService iUserBillService;
-    @Autowired
     private ITyBillService iTyBillService;
     @Autowired
-    private ISchoolVideoOperateService schoolVideoOperateService;
-    @Autowired
     private ISchoolVideoService schoolVideoService;
     @Autowired
     private ITableDictService tableDictService;
     @Autowired
     private IVipFeeSettingService vipFeeSettingService;
     @Autowired
-    private IUserRebateService iUserRebateService;
-    @Autowired
     private UserInfoMapper userInfoMapper;
     @Autowired
     private IUserLevelRuleService iUserLevelRuleService;
     @Autowired
     private IUserWithdrawService userWithdrawService;
-
-    @Autowired
-    private IUserAccountService iUserAccountService;
-
-    @Autowired
-    private IUserRebateRuleService iUserRebateRuleService;
-
     @Autowired
     private AlipayService alipayService;
 
+    /**
+     * app支付回调
+     *
+     * @param response
+     * @param request
+     * @return 支付相关信息
+     */
+    @ApiOperation("app支付回调")
+    @ApiIgnore
+    @RequestMapping(value = "/alipayNotify", method = RequestMethod.POST)
+    public String alipayNotify(HttpServletResponse response, HttpServletRequest request) {
+        return alipayNotify1(response, request);
+    }
+
     /**
      * 支付宝-电脑网站支付
      *
@@ -144,6 +133,169 @@ public class AlipayController {
     @ApiOperation("支付宝-电脑网站支付")
     @GetMapping("/alipay/pc")
     public void alipayPc(HttpServletResponse response, @RequestParam("money") String money, @RequestParam("outTradeNo") String outTradeNo) {
+        alipayPc1(response, money, outTradeNo);
+    }
+
+    /**
+     * 支付宝-诊单APP支付
+     *
+     * @param pay 订单对象
+     * @return
+     */
+    @ApiOperation("APP支付宝-诊单支付")
+    @PostMapping("/alipay")
+    public RestResponse alipayApp(@RequestBody PayDTO pay) {
+        return alipayApp1(pay);
+    }
+
+    /**
+     * 支付宝-打赏APP支付
+     *
+     * @param pay 订单对象
+     * @return
+     */
+    @ApiOperation("APP支付宝-打赏支付")
+    @PostMapping("/reward")
+    public RestResponse rewardApp(@RequestBody PayDTO pay) {
+        return rewardApp1(pay);
+    }
+
+    /**
+     * APP支付宝-查询商户余额
+     *
+     * @return
+     */
+    @ApiOperation("APP支付宝-查询商户余额")
+    @PostMapping("/balanceQuery")
+    public RestResponse balanceQuery() {
+        return balanceQuery1();
+    }
+
+    /**
+     * 支付宝-APP用户充值
+     *
+     * @param pay 订单对象
+     * @return
+     */
+    @ApiOperation("支付宝-APP用户充值")
+    @PostMapping("/alipayRecharge")
+    public RestResponse alipayRechargeApp(@RequestBody PayDTO pay) {
+        return alipayRechargeApp1(pay);
+    }
+
+    /**
+     * 支付宝-WEB提现打款
+     *
+     * @param pay 订单对象
+     * @return
+     */
+//    @CrossOrigin
+    @ApiOperation("支付宝-WEB提现打款")
+    @PostMapping("/withdrawMoney")
+    public RestResponse withdrawMoney(@RequestBody PayDTO pay) {
+        return withdrawMoney1(pay);
+    }
+
+    /**
+     * 支付宝-充值成为VIP用户
+     *
+     * @param pay 订单对象
+     * @return
+     */
+    @ApiOperation("APP支付宝-充值成为VIP用户")
+    @PostMapping("/rechargeVIP")
+    public RestResponse rechargeVIP(@RequestBody PayDTO pay) {
+        return rechargeVIP1(pay);
+    }
+
+    /**
+     * 平台账户余额支付
+     *
+     * @param pay 订单对象
+     * @return
+     */
+    @ApiOperation("平台账户余额支付")
+    @PostMapping("/alipayBalanceApp")
+    public RestResponse alipayBalanceApp(@RequestBody PayDTO pay) {
+        return alipayBalanceApp1(pay);
+    }
+
+
+
+    private String alipayNotify1(HttpServletResponse response, HttpServletRequest request){
+        Map<String, String> params = alipayParamsMap(request);
+        log.info("《====支付宝回调=====》:{}", params);
+
+        // 获取验签结果
+        boolean signVerified = alipaySignVerifiedResult(params, alipayConfig.getAlipayCertPath());
+
+        if (signVerified) {
+            // appId
+            String alipayAppId = alipayConfig.getAppid();
+
+            log.info("支付宝验签成功");
+            // 校验APP_ID
+            String appId = params.get("app_id");
+            if (!alipayAppId.equalsIgnoreCase(appId)) {
+                log.error("支付宝APP_ID校验失败");
+                return "fail";
+            }
+            try {
+                // 拿到订单号、金额以及支付宝流水号
+                String outTradeNo = params.get("out_trade_no");
+                String totalAmount = params.get("total_amount");
+                String tradeNo = params.get("trade_no");
+
+                // 拿到公共回传参数
+                String passbackParams = params.get("passback_params");
+                passbackParams = URLDecoder.decode(passbackParams, "UTF-8");
+                PassbackParamsDTO paramsDTO = JSON.parseObject(passbackParams, PassbackParamsDTO.class);
+
+                // 重新查询支付宝订单,再判断交易状态。
+                boolean tradeStatus = alipaySupport.tradeQuery(tradeNo, outTradeNo);
+
+                // 判断交易状态
+                if (tradeStatus) {
+                    log.info("支付宝APP支付,交易成功,即将处理的业务代码:{}", paramsDTO.getMemo());
+
+                    if (paramsDTO.getType() == PassbackEnum.LIFT_CASE_PAY.getCode()) {
+                        alipayService.zfbCasePaymentComplete(outTradeNo, totalAmount, tradeNo);
+
+                    } else if (paramsDTO.getType() == PassbackEnum.RECHARGE_PAY.getCode()) {
+                        alipayService.rechargePay(outTradeNo, totalAmount, tradeNo, paramsDTO);
+
+                    } else if (paramsDTO.getType() == PassbackEnum.LIFT_CALL_PAY.getCode()) {
+                        alipayService.zfbCallPaymentComplete(outTradeNo, totalAmount, tradeNo);
+
+                    } else if (paramsDTO.getType() == PassbackEnum.REWARD_PAY.getCode()) {
+                        Long questionId = Long.valueOf(paramsDTO.getDataId());
+                        alipayService.questionPaymentComplete(questionId, paramsDTO.getUserId(), tradeNo, totalAmount, 1);
+
+                    } else if (paramsDTO.getType() == PassbackEnum.VIDEO_PAY.getCode()) {
+                        Long videoId = Long.valueOf(paramsDTO.getDataId());
+                        alipayService.videoPaymentComplete(videoId, paramsDTO.getUserId(), tradeNo, totalAmount, 1);
+
+                    } else if (paramsDTO.getType() == PassbackEnum.RECHARGE_VIP_PAY.getCode()) {
+                        Long vipFeeSetting = Long.valueOf(paramsDTO.getDataId());
+                        alipayService.toVIPPaymentComplete(vipFeeSetting, paramsDTO.getUserId(), tradeNo, totalAmount);
+
+                    } else {
+                        log.error("好可惜,回调类型不存在:{}", paramsDTO.getType());
+                    }
+
+                } else {
+                    log.error("支付宝APP支付,交易状态为未支付");
+                    return "fail";
+                }
+            } catch (Exception e) {
+                log.error("================支付宝回调接口处理业务代码中发生异常================");
+                log.info(e.getMessage());
+            }
+        }
+        return "success";
+    }
+
+    private void alipayPc1(HttpServletResponse response,String money,String outTradeNo){
         log.info("====进入【支付宝-电脑网站支付】====");
         if (StringUtils.isBlank(money) || StringUtils.isBlank(outTradeNo)) {
             log.error("支付金额、订单号参数不能为空。");
@@ -178,15 +330,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * 支付宝-诊单APP支付
-     *
-     * @param pay 订单对象
-     * @return
-     */
-    @ApiOperation("APP支付宝-诊单支付")
-    @PostMapping("/alipay")
-    public RestResponse alipayApp(@RequestBody PayDTO pay) {
+    private RestResponse alipayApp1(PayDTO pay){
         if (StringUtils.isBlank(pay.getOrders())) {
             log.error("订单号不能为空。");
             return RestResponse.fail("0", "订单号不能为空。");
@@ -262,15 +406,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * 支付宝-打赏APP支付
-     *
-     * @param pay 订单对象
-     * @return
-     */
-    @ApiOperation("APP支付宝-打赏支付")
-    @PostMapping("/reward")
-    public RestResponse rewardApp(@RequestBody PayDTO pay) {
+    private RestResponse rewardApp1(PayDTO pay){
         if (StringUtils.isBlank(pay.getOrders())) {
             log.error("订单号参数不能为空。");
             return RestResponse.fail("0", "订单号不能为空。");
@@ -352,14 +488,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * APP支付宝-查询商户余额
-     *
-     * @return
-     */
-    @ApiOperation("APP支付宝-查询商户余额")
-    @PostMapping("/balanceQuery")
-    public RestResponse balanceQuery() {
+    private RestResponse balanceQuery1(){
         try {
 
             AlipayDataBillBalanceQueryRequest request = new AlipayDataBillBalanceQueryRequest();
@@ -373,15 +502,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * 支付宝-APP用户充值
-     *
-     * @param pay 订单对象
-     * @return
-     */
-    @ApiOperation("支付宝-APP用户充值")
-    @PostMapping("/alipayRecharge")
-    public RestResponse apyRechargeApp(@RequestBody PayDTO pay) {
+    private RestResponse alipayRechargeApp1(PayDTO pay){
         if (StringUtils.isBlank(pay.getOrders())) {
             log.error("请输入订单号.");
             return RestResponse.fail("0", "请输入订单号.");
@@ -436,16 +557,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * 支付宝-WEB提现打款
-     *
-     * @param pay 订单对象
-     * @return
-     */
-//    @CrossOrigin
-    @ApiOperation("支付宝-WEB提现打款")
-    @PostMapping("/withdrawMoney")
-    public RestResponse withdrawMoney(@RequestBody PayDTO pay) {
+    private RestResponse withdrawMoney1(PayDTO pay){
         if (StringUtils.isBlank(pay.getOrders())) {
             log.error("请输入订单号.");
             return RestResponse.fail("0", "请输入订单号.");
@@ -579,15 +691,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * 支付宝-充值成为VIP用户
-     *
-     * @param pay 订单对象
-     * @return
-     */
-    @ApiOperation("APP支付宝-充值成为VIP用户")
-    @PostMapping("/rechargeVIP")
-    public RestResponse rechargeVIP(@RequestBody PayDTO pay) {
+    private RestResponse rechargeVIP1(PayDTO pay){
         if (StringUtils.isBlank(pay.getOrders())) {
             log.error("订单号不能为空。");
             return RestResponse.fail("0", "订单号不能为空。");
@@ -598,18 +702,16 @@ public class AlipayController {
             return RestResponse.fail("0", "打赏用户id不能为空。");
         }
 
-        QueryWrapper<VipFeeSettingEntity> queryWrapper = new QueryWrapper<VipFeeSettingEntity>();
-        queryWrapper.eq("id", pay.getOrders());
-        VipFeeSettingEntity orders = vipFeeSettingService.getOne(queryWrapper);
+        VipFeeSettingEntity vipFeeSettingEntity = vipFeeSettingService.getOne( new QueryWrapper<VipFeeSettingEntity>().eq("id", pay.getOrders()));
 
-        if (null == orders) {
+        if (null == vipFeeSettingEntity) {
             log.error("该项会费不存在请检查!");
             return RestResponse.fail("0", "该项会费不存在请检查!");
         }
 
         /** 0 待审核 1 审核通过 2 驳回 3 待提交 */
         final int flag = 1;
-        if (flag != orders.getExamineFlag()) {
+        if (flag != vipFeeSettingEntity.getExamineFlag()) {
             log.error("该项会费不支持使用请检查!");
             return RestResponse.fail("0", "该项会费不支持使用请检查!");
         }
@@ -619,14 +721,14 @@ public class AlipayController {
             log.error("当前用户不存在");
             return RestResponse.fail("当前用户不存在");
         }
-        UserLevelRuleEntity userLevelRole = iUserLevelRuleService.getById(orders.getUserLevelId());
+        UserLevelRuleEntity userLevelRole = iUserLevelRuleService.getById(vipFeeSettingEntity.getUserLevelId());
         if (null == userLevelRole) {
             log.error("当前会员角色等级不存在,请检查");
             return RestResponse.fail("当前会员角色等级不存在,请检查");
         }
 
         try {
-            BigDecimal totalAmount = orders.getPrice();
+            BigDecimal totalAmount = vipFeeSettingEntity.getPrice();
 
             // APP支付请求参数。
             AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
@@ -635,8 +737,8 @@ public class AlipayController {
             model.setProductCode("QUICK_MSECURITY_PAY");
             model.setSubject(alipayConfig.getSubjectName());
             // 公用回传参数
-            String passbackParams = assemblePassbackParams(PassbackEnum.RECHARGE_VIP_PAY.getCode(), orders.getName(),
-                    pay.getUserId(), orders.getId().toString());
+            String passbackParams = assemblePassbackParams(PassbackEnum.RECHARGE_VIP_PAY.getCode(), vipFeeSettingEntity.getName(),
+                    pay.getUserId(), vipFeeSettingEntity.getId().toString());
 
             model.setPassbackParams(passbackParams);
 
@@ -657,16 +759,7 @@ public class AlipayController {
         }
     }
 
-    /**
-     * 平台账户余额支付
-     *
-     * @param pay 订单对象
-     * @return
-     */
-    @ApiOperation("平台账户余额支付")
-    @PostMapping("/alipayBalanceApp")
-    public RestResponse alipayBalanceApp(@RequestBody PayDTO pay) {
-
+    private RestResponse alipayBalanceApp1(PayDTO pay){
         if (null == pay.getPayType()) {
             log.error("余额支付类型不能为空。");
             return RestResponse.fail("0", "余额支付类型不能为空。");
@@ -697,6 +790,8 @@ public class AlipayController {
         // }
     }
 
+
+
     /**
      * 余额打赏视频
      *
@@ -894,90 +989,7 @@ public class AlipayController {
         return RestResponse.success("SUCCESS");
     }
 
-    /**
-     * app支付回调
-     *
-     * @param response
-     * @param request
-     * @return 支付相关信息
-     */
-    @ApiOperation("app支付回调")
-    @ApiIgnore
-    @RequestMapping(value = "/alipayNotify", method = RequestMethod.POST)
-    public String alipayNotify(HttpServletResponse response, HttpServletRequest request) {
-        Map<String, String> params = alipayParamsMap(request);
-
-        log.info("《====支付宝回调=====》:{}", params);
-
-        // 获取验签结果
-        boolean signVerified = alipaySignVerifiedResult(params, alipayConfig.getAlipayCertPath());
-
-        if (signVerified) {
-            // appId
-            String alipayAppId = alipayConfig.getAppid();
 
-            log.info("支付宝验签成功");
-            // 校验APP_ID
-            String appId = params.get("app_id");
-            if (!alipayAppId.equalsIgnoreCase(appId)) {
-                log.error("支付宝APP_ID校验失败");
-                return "fail";
-            }
-            try {
-                // 拿到订单号、金额以及支付宝流水号
-                String outTradeNo = params.get("out_trade_no");
-                String totalAmount = params.get("total_amount");
-                String tradeNo = params.get("trade_no");
-
-                // 拿到公共回传参数
-                String passbackParams = params.get("passback_params");
-                passbackParams = URLDecoder.decode(passbackParams, "UTF-8");
-                PassbackParamsDTO dto = JSON.parseObject(passbackParams, PassbackParamsDTO.class);
-
-                // 重新查询支付宝订单,再判断交易状态。
-                boolean tradeStatus = alipaySupport.tradeQuery(tradeNo, outTradeNo);
-
-                // 判断交易状态
-                if (tradeStatus) {
-
-                    log.info("支付宝APP支付,交易成功,即将处理的业务代码:{}", dto.getMemo());
-
-                    if (dto.getType() == PassbackEnum.LIFT_CASE_PAY.getCode()) {
-                        alipayService.zfbCasePaymentComplete(outTradeNo, totalAmount, tradeNo);
-
-                    } else if (dto.getType() == PassbackEnum.RECHARGE_PAY.getCode()) {
-                        alipayService.rechargePay(outTradeNo, totalAmount, tradeNo, dto);
-
-                    } else if (dto.getType() == PassbackEnum.LIFT_CALL_PAY.getCode()) {
-                        alipayService.zfbCallPaymentComplete(outTradeNo, totalAmount, tradeNo);
-
-                    } else if (dto.getType() == PassbackEnum.REWARD_PAY.getCode()) {
-                        Long questionId = Long.valueOf(dto.getDataId());
-                        alipayService.questionPaymentComplete(questionId, dto.getUserId(), tradeNo, totalAmount, 1);
-
-                    } else if (dto.getType() == PassbackEnum.VIDEO_PAY.getCode()) {
-                        Long videoId = Long.valueOf(dto.getDataId());
-                        alipayService.videoPaymentComplete(videoId, dto.getUserId(), tradeNo, totalAmount, 1);
-
-                    } else if (dto.getType() == PassbackEnum.RECHARGE_VIP_PAY.getCode()) {
-                        Long vipFeeSetting = Long.valueOf(dto.getDataId());
-                        alipayService.toVIPPaymentComplete(vipFeeSetting, dto.getUserId(), tradeNo, totalAmount);
-
-                    } else {
-                        log.error("好可惜,回调类型不存在:{}", dto.getType());
-                    }
-
-                } else {
-                    log.error("支付宝APP支付,交易状态为未支付");
-                    return "fail";
-                }
-            } catch (Exception e) {
-                log.error("================支付宝回调接口处理业务代码中发生异常================");
-                log.info(e.getMessage());
-            }
-        }
-        return "success";
-    }
 
     /**
      * 获取两个时间点的月份差
@@ -1019,8 +1031,7 @@ public class AlipayController {
             // valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
             params.put(name, valueStr);
         }
-        log.info("====支付宝回调参数====");
-        log.info(params.toString());
+
         return params;
     }
 
@@ -1054,8 +1065,7 @@ public class AlipayController {
      * @return
      * @throws UnsupportedEncodingException
      */
-    private String assemblePassbackParams(Integer type, String memo, Long userId, String dataId)
-            throws UnsupportedEncodingException {
+    private String assemblePassbackParams(Integer type, String memo, Long userId, String dataId) throws UnsupportedEncodingException {
         PassbackParamsDTO dto = new PassbackParamsDTO();
         dto.setType(type);
         dto.setMemo(memo);
@@ -1063,32 +1073,4 @@ public class AlipayController {
         dto.setDataId(dataId);
         return URLEncoder.encode(JSON.toJSONString(dto), "UTF-8");
     }
-
-    public static void main(String[] args) throws UnsupportedEncodingException {
-        Map<String, Object> map = new HashMap<>();
-        map.put("type", 1);
-        map.put("name", "测试");
-        String strEncoder = JSON.toJSONString(map);
-        String passbackParams = URLEncoder.encode(strEncoder, "UTF-8");
-        System.out.println(passbackParams.length());
-
-        passbackParams = URLDecoder.decode(passbackParams, "UTF-8");
-        System.out.println(passbackParams);
-
-        System.out.println(UUIDUtil.getUuidByTime(8));
-        LocalDateTime of1 = LocalDateTime.of(2019, 9, 25, 1, 1);// 2018-9-25 01:01
-        LocalDateTime of2 = LocalDateTime.of(2019, 10, 25, 23, 16); // 2019-9-25 23:16
-        int month = monthDiff(of1, of2);
-        System.out.println(month);
-        System.out.println(LocalDateTime.now().plusMonths(10));
-        if (BigDecimal.valueOf(20.00).compareTo(BigDecimal.valueOf(20.01)) == -1) {
-            log.error("余额不足。");
-        }
-
-        Set<HashMap<String, Channel>> newUserChannel = new HashSet<>();
-        if (!newUserChannel.isEmpty()) {
-
-        }
-    }
-
 }

+ 10 - 19
lift-ud-service/src/main/java/cn/com/ty/lift/ud/pay/service/impl/AlipayServiceImpl.java

@@ -11,6 +11,7 @@ import cn.com.ty.lift.ud.chat.mapper.entity.ChatSessionEntity;
 import cn.com.ty.lift.ud.chat.mapper.entity.LiftCaseEntity;
 import cn.com.ty.lift.ud.chat.service.IChatSessionService;
 import cn.com.ty.lift.ud.chat.service.ILiftCaseService;
+import cn.com.ty.lift.ud.constant.CommonConst;
 import cn.com.ty.lift.ud.neety.protocol.RoomInfo;
 import cn.com.ty.lift.ud.neety.protocol.UserInfo;
 import cn.com.ty.lift.ud.operation.mapper.entity.CommissionSettingEntity;
@@ -1121,16 +1122,14 @@ public class AlipayServiceImpl implements AlipayService {
      */
     @Override
     public void toVIPPaymentComplete(Long vipFeeSetting, Long userId, String tradeNo, String totalAmount) {
-        QueryWrapper<VipFeeSettingEntity> queryWrapper = new QueryWrapper<VipFeeSettingEntity>();
-        queryWrapper.eq("id", vipFeeSetting);
-        VipFeeSettingEntity entity = vipFeeSettingService.getOne(queryWrapper);
+        VipFeeSettingEntity vipFeeSettingEntity = vipFeeSettingService.getOne(new QueryWrapper<VipFeeSettingEntity>().eq("id", vipFeeSetting));
         UserInfoEntity userInfoEntity = userInfoMapper.getByUserId(userId);
         if (null == userInfoEntity) {
             log.error("当前用户不存在");
         } else {
             // 根据有效期查询会费
-            BigDecimal fee = entity.getPrice();
-            UserLevelRuleEntity userLevelRole = iUserLevelRuleService.getById(entity.getUserLevelId());
+            BigDecimal fee = vipFeeSettingEntity.getPrice();
+            UserLevelRuleEntity userLevelRole = iUserLevelRuleService.getById(vipFeeSettingEntity.getUserLevelId());
             if (null == userLevelRole) {
                 log.error("当前会员角色等级不存在,请检查");
             }
@@ -1144,35 +1143,27 @@ public class AlipayServiceImpl implements AlipayService {
             }
 
             if (null != userInfoEntity.getVipEndTime() && userInfoEntity.getVipFlag() == 2) {
-                vipEndTime = userInfoEntity.getVipEndTime().plusMonths(entity.getPeriod());
+                vipEndTime = userInfoEntity.getVipEndTime().plusMonths(vipFeeSettingEntity.getPeriod());
             } else {
-                vipEndTime = vipEndTime.plusMonths(entity.getPeriod());
+                vipEndTime = vipEndTime.plusMonths(vipFeeSettingEntity.getPeriod());
             }
 
             int month = monthDiff(LocalDateTime.now(), vipEndTime);
-            // 获取VIP的等级
-            int level = 1;
-            if (month >= 1 && month < 3) {
-                level = 1;
-            } else if (month >= 3 && month < 12) {
-                level = 3;
-            } else if (month >= 12) {
-                level = 12;
-            }
+
             UserAccount userAccount = iUserAccountService.getOneById(userId);
             UserLevelRuleEntity expert = iUserLevelRuleService.getByCode("EXPERT");
             if (null != userAccount && userAccount.getExpertFlag() == 1) {
                 // 专家,如果是专家,user_level_name 显示专家,user_level 保存会员角色ID
-                userInfoMapper.toVip(userLevelRole.getId(), expert.getName(), code, vipStartTime, vipEndTime, month > 0 ? month : 0, entity.getId(), userId);
+                userInfoMapper.toVip(userLevelRole.getId(), expert.getName(), code, vipStartTime, vipEndTime, month > 0 ? month : 0, vipFeeSettingEntity.getId(), userId);
             } else {
                 // 不是专家
-                userInfoMapper.toVip(userLevelRole.getId(), userLevelRole.getName(), code, vipStartTime, vipEndTime, month > 0 ? month : 0, entity.getId(), userId);
+                userInfoMapper.toVip(userLevelRole.getId(), userLevelRole.getName(), code, vipStartTime, vipEndTime, month > 0 ? month : 0, vipFeeSettingEntity.getId(), userId);
             }
 
             // 如果是第一次成为会员,或者不是后台直接升级成会员的(是vip但是没有邀请码)
             // user_rebate 中修改此人的会费信息,并且给他的上级返利
             // 判断是否是第一次充值成为会员
-            UserBillEntity userBill = iUserBillService.getByUserIdAndBusinessType(userId, 1);
+            UserBillEntity userBill = iUserBillService.getByUserIdAndBusinessType(userId, CommonConst.BUSINESS_TYPE_BECOME_VIP);
             if (null == userBill && userInfoEntity.getRequestCode() == null) {
                 // 第一次成为会员
                 // 如果他有上级,上级的user_bill中加入流水信息,余额增加