|
@@ -1,14 +1,11 @@
|
|
package cn.com.ty.lift.ud.pay.controller;
|
|
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.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.chat.service.ILiftCaseService;
|
|
import cn.com.ty.lift.ud.common.RandomizingID;
|
|
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.UserLevelRuleEntity;
|
|
import cn.com.ty.lift.ud.operation.mapper.entity.VipFeeSettingEntity;
|
|
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.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.operation.service.IVipFeeSettingService;
|
|
import cn.com.ty.lift.ud.pay.alipay.AlipayConfig;
|
|
import cn.com.ty.lift.ud.pay.alipay.AlipayConfig;
|
|
import cn.com.ty.lift.ud.pay.alipay.AlipaySupport;
|
|
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.payment.service.IUserWithdrawService;
|
|
import cn.com.ty.lift.ud.question.mapper.QuestionBankMapper;
|
|
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.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.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.schoolVideo.service.ISchoolVideoService;
|
|
import cn.com.ty.lift.ud.tableDict.service.ITableDictService;
|
|
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.UserInfoMapper;
|
|
import cn.com.ty.lift.ud.userInfo.mapper.entity.UserInfoEntity;
|
|
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.userInfo.service.IUserInfoService;
|
|
-import cn.com.ty.lift.ud.userRebate.service.IUserRebateService;
|
|
|
|
import cn.com.ty.lift.ud.utils.UUIDUtil;
|
|
import cn.com.ty.lift.ud.utils.UUIDUtil;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
import com.alibaba.fastjson.JSON;
|
|
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.AlipayDataBillBalanceQueryResponse;
|
|
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
|
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import io.netty.channel.Channel;
|
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -71,7 +63,9 @@ import java.math.BigDecimal;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
import java.time.LocalDateTime;
|
|
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
|
|
@Autowired
|
|
private ILiftCaseService liftCaseService;
|
|
private ILiftCaseService liftCaseService;
|
|
@Autowired
|
|
@Autowired
|
|
- private IChatSessionService chatSessionService;
|
|
|
|
- @Autowired
|
|
|
|
private IUserBillService userBillService;
|
|
private IUserBillService userBillService;
|
|
@Autowired
|
|
@Autowired
|
|
private IUserRechargeDetailService userRechargeDetailService;
|
|
private IUserRechargeDetailService userRechargeDetailService;
|
|
@@ -101,39 +93,36 @@ public class AlipayController {
|
|
@Autowired
|
|
@Autowired
|
|
private QuestionBankMapper questionBankMapper;
|
|
private QuestionBankMapper questionBankMapper;
|
|
@Autowired
|
|
@Autowired
|
|
- private IQuestionOperateService iQuestionOperateService;
|
|
|
|
- @Autowired
|
|
|
|
- private ICommissionSettingService iCommissionSettingService;
|
|
|
|
- @Autowired
|
|
|
|
- private IUserBillService iUserBillService;
|
|
|
|
- @Autowired
|
|
|
|
private ITyBillService iTyBillService;
|
|
private ITyBillService iTyBillService;
|
|
@Autowired
|
|
@Autowired
|
|
- private ISchoolVideoOperateService schoolVideoOperateService;
|
|
|
|
- @Autowired
|
|
|
|
private ISchoolVideoService schoolVideoService;
|
|
private ISchoolVideoService schoolVideoService;
|
|
@Autowired
|
|
@Autowired
|
|
private ITableDictService tableDictService;
|
|
private ITableDictService tableDictService;
|
|
@Autowired
|
|
@Autowired
|
|
private IVipFeeSettingService vipFeeSettingService;
|
|
private IVipFeeSettingService vipFeeSettingService;
|
|
@Autowired
|
|
@Autowired
|
|
- private IUserRebateService iUserRebateService;
|
|
|
|
- @Autowired
|
|
|
|
private UserInfoMapper userInfoMapper;
|
|
private UserInfoMapper userInfoMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private IUserLevelRuleService iUserLevelRuleService;
|
|
private IUserLevelRuleService iUserLevelRuleService;
|
|
@Autowired
|
|
@Autowired
|
|
private IUserWithdrawService userWithdrawService;
|
|
private IUserWithdrawService userWithdrawService;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private IUserAccountService iUserAccountService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private IUserRebateRuleService iUserRebateRuleService;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private AlipayService alipayService;
|
|
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("支付宝-电脑网站支付")
|
|
@ApiOperation("支付宝-电脑网站支付")
|
|
@GetMapping("/alipay/pc")
|
|
@GetMapping("/alipay/pc")
|
|
public void alipayPc(HttpServletResponse response, @RequestParam("money") String money, @RequestParam("outTradeNo") String outTradeNo) {
|
|
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("====进入【支付宝-电脑网站支付】====");
|
|
log.info("====进入【支付宝-电脑网站支付】====");
|
|
if (StringUtils.isBlank(money) || StringUtils.isBlank(outTradeNo)) {
|
|
if (StringUtils.isBlank(money) || StringUtils.isBlank(outTradeNo)) {
|
|
log.error("支付金额、订单号参数不能为空。");
|
|
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())) {
|
|
if (StringUtils.isBlank(pay.getOrders())) {
|
|
log.error("订单号不能为空。");
|
|
log.error("订单号不能为空。");
|
|
return RestResponse.fail("0", "订单号不能为空。");
|
|
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())) {
|
|
if (StringUtils.isBlank(pay.getOrders())) {
|
|
log.error("订单号参数不能为空。");
|
|
log.error("订单号参数不能为空。");
|
|
return RestResponse.fail("0", "订单号不能为空。");
|
|
return RestResponse.fail("0", "订单号不能为空。");
|
|
@@ -352,14 +488,7 @@ public class AlipayController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * APP支付宝-查询商户余额
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @ApiOperation("APP支付宝-查询商户余额")
|
|
|
|
- @PostMapping("/balanceQuery")
|
|
|
|
- public RestResponse balanceQuery() {
|
|
|
|
|
|
+ private RestResponse balanceQuery1(){
|
|
try {
|
|
try {
|
|
|
|
|
|
AlipayDataBillBalanceQueryRequest request = new AlipayDataBillBalanceQueryRequest();
|
|
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())) {
|
|
if (StringUtils.isBlank(pay.getOrders())) {
|
|
log.error("请输入订单号.");
|
|
log.error("请输入订单号.");
|
|
return RestResponse.fail("0", "请输入订单号.");
|
|
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())) {
|
|
if (StringUtils.isBlank(pay.getOrders())) {
|
|
log.error("请输入订单号.");
|
|
log.error("请输入订单号.");
|
|
return RestResponse.fail("0", "请输入订单号.");
|
|
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())) {
|
|
if (StringUtils.isBlank(pay.getOrders())) {
|
|
log.error("订单号不能为空。");
|
|
log.error("订单号不能为空。");
|
|
return RestResponse.fail("0", "订单号不能为空。");
|
|
return RestResponse.fail("0", "订单号不能为空。");
|
|
@@ -598,18 +702,16 @@ public class AlipayController {
|
|
return RestResponse.fail("0", "打赏用户id不能为空。");
|
|
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("该项会费不存在请检查!");
|
|
log.error("该项会费不存在请检查!");
|
|
return RestResponse.fail("0", "该项会费不存在请检查!");
|
|
return RestResponse.fail("0", "该项会费不存在请检查!");
|
|
}
|
|
}
|
|
|
|
|
|
/** 0 待审核 1 审核通过 2 驳回 3 待提交 */
|
|
/** 0 待审核 1 审核通过 2 驳回 3 待提交 */
|
|
final int flag = 1;
|
|
final int flag = 1;
|
|
- if (flag != orders.getExamineFlag()) {
|
|
|
|
|
|
+ if (flag != vipFeeSettingEntity.getExamineFlag()) {
|
|
log.error("该项会费不支持使用请检查!");
|
|
log.error("该项会费不支持使用请检查!");
|
|
return RestResponse.fail("0", "该项会费不支持使用请检查!");
|
|
return RestResponse.fail("0", "该项会费不支持使用请检查!");
|
|
}
|
|
}
|
|
@@ -619,14 +721,14 @@ public class AlipayController {
|
|
log.error("当前用户不存在");
|
|
log.error("当前用户不存在");
|
|
return RestResponse.fail("当前用户不存在");
|
|
return RestResponse.fail("当前用户不存在");
|
|
}
|
|
}
|
|
- UserLevelRuleEntity userLevelRole = iUserLevelRuleService.getById(orders.getUserLevelId());
|
|
|
|
|
|
+ UserLevelRuleEntity userLevelRole = iUserLevelRuleService.getById(vipFeeSettingEntity.getUserLevelId());
|
|
if (null == userLevelRole) {
|
|
if (null == userLevelRole) {
|
|
log.error("当前会员角色等级不存在,请检查");
|
|
log.error("当前会员角色等级不存在,请检查");
|
|
return RestResponse.fail("当前会员角色等级不存在,请检查");
|
|
return RestResponse.fail("当前会员角色等级不存在,请检查");
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- BigDecimal totalAmount = orders.getPrice();
|
|
|
|
|
|
+ BigDecimal totalAmount = vipFeeSettingEntity.getPrice();
|
|
|
|
|
|
// APP支付请求参数。
|
|
// APP支付请求参数。
|
|
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
|
|
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
|
|
@@ -635,8 +737,8 @@ public class AlipayController {
|
|
model.setProductCode("QUICK_MSECURITY_PAY");
|
|
model.setProductCode("QUICK_MSECURITY_PAY");
|
|
model.setSubject(alipayConfig.getSubjectName());
|
|
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);
|
|
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()) {
|
|
if (null == pay.getPayType()) {
|
|
log.error("余额支付类型不能为空。");
|
|
log.error("余额支付类型不能为空。");
|
|
return RestResponse.fail("0", "余额支付类型不能为空。");
|
|
return RestResponse.fail("0", "余额支付类型不能为空。");
|
|
@@ -697,6 +790,8 @@ public class AlipayController {
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 余额打赏视频
|
|
* 余额打赏视频
|
|
*
|
|
*
|
|
@@ -894,90 +989,7 @@ public class AlipayController {
|
|
return RestResponse.success("SUCCESS");
|
|
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");
|
|
// valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
|
params.put(name, valueStr);
|
|
params.put(name, valueStr);
|
|
}
|
|
}
|
|
- log.info("====支付宝回调参数====");
|
|
|
|
- log.info(params.toString());
|
|
|
|
|
|
+
|
|
return params;
|
|
return params;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1054,8 +1065,7 @@ public class AlipayController {
|
|
* @return
|
|
* @return
|
|
* @throws UnsupportedEncodingException
|
|
* @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();
|
|
PassbackParamsDTO dto = new PassbackParamsDTO();
|
|
dto.setType(type);
|
|
dto.setType(type);
|
|
dto.setMemo(memo);
|
|
dto.setMemo(memo);
|
|
@@ -1063,32 +1073,4 @@ public class AlipayController {
|
|
dto.setDataId(dataId);
|
|
dto.setDataId(dataId);
|
|
return URLEncoder.encode(JSON.toJSONString(dto), "UTF-8");
|
|
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()) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|