|
@@ -10,12 +10,22 @@
|
|
|
|
|
|
package com.qs.mp.web.controller.api.channel;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.parser.Feature;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.eptok.yspay.opensdkjava.fund.BankAuthorityApi;
|
|
|
+import com.eptok.yspay.opensdkjava.pojo.vo.OnlineReqDataVo;
|
|
|
+import com.eptok.yspay.opensdkjava.util.DateUtil;
|
|
|
+import com.eptok.yspay.opensdkjava.util.SrcDesUtil;
|
|
|
+import com.eptok.yspay.opensdkjava.util.YsOnlineSignUtils;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
+import com.qs.mp.channel.domain.ChannelBank;
|
|
|
import com.qs.mp.channel.domain.ChannelBankCard;
|
|
|
import com.qs.mp.channel.domain.ChannelCart;
|
|
|
import com.qs.mp.channel.domain.ChannelWithdraw;
|
|
|
+import com.qs.mp.channel.domain.param.ChannelBankCardCreateParam;
|
|
|
import com.qs.mp.channel.domain.param.ChannelCartParam;
|
|
|
import com.qs.mp.channel.domain.param.ChannelWithdrawParam;
|
|
|
import com.qs.mp.channel.domain.vo.ChannelCartVO;
|
|
@@ -24,24 +34,33 @@ import com.qs.mp.channel.service.IChannelBankCardService;
|
|
|
import com.qs.mp.channel.service.IChannelCartService;
|
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
|
import com.qs.mp.channel.service.IChannelWithdrawService;
|
|
|
+import com.qs.mp.common.constant.YsServerApiConstants;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.redis.RedisCache;
|
|
|
+import com.qs.mp.common.domain.YsCallLog;
|
|
|
import com.qs.mp.common.domain.param.BatchLongIdsParam;
|
|
|
import com.qs.mp.common.enums.ChannelStatusEnum;
|
|
|
+import com.qs.mp.common.enums.YsCallBizTypeEnum;
|
|
|
+import com.qs.mp.common.service.IYsCallLogService;
|
|
|
import com.qs.mp.common.utils.StringUtils;
|
|
|
+import com.qs.mp.common.utils.http.OkHttpUtil;
|
|
|
import com.qs.mp.system.service.ISysConfigService;
|
|
|
import com.qs.mp.utils.SecurityUtils;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import javax.validation.Valid;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import ma.glasnost.orika.MapperFacade;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -52,7 +71,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RestController
|
|
|
@RequestMapping("/api/v1/mp/channel")
|
|
|
@Api(tags = "渠道提现接口")
|
|
|
-@AllArgsConstructor
|
|
|
public class ChannelWithdrawController extends BaseApiController {
|
|
|
|
|
|
|
|
@@ -82,6 +100,109 @@ public class ChannelWithdrawController extends BaseApiController {
|
|
|
*/
|
|
|
private final String FEE_RATE_DEFAULT_VALUE = "0.8";
|
|
|
|
|
|
+
|
|
|
+ @Value("${ys-pay.partner-id}")
|
|
|
+ private String partnerId;
|
|
|
+
|
|
|
+ @Value("${ys-pay.private-key-pass}")
|
|
|
+ private String privateKeyPass;
|
|
|
+
|
|
|
+ @Value("${ys-pay.private-key-path}")
|
|
|
+ private String privateKeyPath;
|
|
|
+
|
|
|
+ @Value("${ys-pay.public-key-path}")
|
|
|
+ private String publicKeyPath;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IYsCallLogService ysCallLogService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "银行卡实名认证绑定")
|
|
|
+ @PostMapping("/withdraw/bankCardAuth")
|
|
|
+ public AjaxResult bankCardAuth(@Validated @RequestBody ChannelBankCardCreateParam param) {
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+
|
|
|
+ // 判断是否已经绑定过银行卡
|
|
|
+ int count = channelBankCardService.count(new LambdaQueryWrapper<ChannelBankCard>()
|
|
|
+ .eq(ChannelBankCard::getChannelId, channelId));
|
|
|
+ if (count > 0) {
|
|
|
+ return AjaxResult.error("已经绑定过银行卡");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, String> mapData = new HashMap<>();
|
|
|
+ mapData.put("partner_id", partnerId);
|
|
|
+ mapData.put("method", "ysepay.authenticate.three.key.element.precise");
|
|
|
+ mapData.put("timestamp", DateUtil.getDateNow());
|
|
|
+ mapData.put("sign_type", "RSA");
|
|
|
+ mapData.put("charset", "utf-8");
|
|
|
+ mapData.put("version", "3.0");
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ String tradeNo = DateUtil.getDateNowYmd() + DateUtil.getRandom(14);
|
|
|
+ json.put("out_trade_no", tradeNo);
|
|
|
+ json.put("shopdate", DateUtil.getDateNowYmd());
|
|
|
+ json.put("bank_account_name", param.getUserName());
|
|
|
+ json.put("bank_account_no", param.getCardNo());
|
|
|
+ json.put("id_card", param.getIdCard());
|
|
|
+ mapData.put("biz_content", json.toString());
|
|
|
+ //参数签名
|
|
|
+ try {
|
|
|
+ String sign = YsOnlineSignUtils.sign(mapData, privateKeyPass, privateKeyPath);
|
|
|
+ mapData.put("sign", sign);
|
|
|
+ logger.info("认证信息签名成功,sign = " + sign);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("签名异常" + e);
|
|
|
+ }
|
|
|
+
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ logger.info("银行实名认证三要素调用sdk接口addScanMerc请求入参为:"+ JSONObject.toJSONString(mapData));
|
|
|
+ result = OkHttpUtil.post("https://openapi.ysepay.com/gateway.do", mapData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.info("银行实名认证三要素失败:"+ e.getMessage());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存银行认证的请求记录
|
|
|
+ YsCallLog ysCallLog = new YsCallLog();
|
|
|
+ ysCallLog.setBizId(tradeNo);
|
|
|
+ ysCallLog.setBizType(YsCallBizTypeEnum.BANK_CARD_AUTH);
|
|
|
+ ysCallLog.setReqJson(JSONObject.toJSONString(mapData));
|
|
|
+ ysCallLog.setResJson(result);
|
|
|
+ ysCallLogService.save(ysCallLog);
|
|
|
+
|
|
|
+ if (result == null) {
|
|
|
+ logger.error("银行实名认证三要素失败,res为空,req =" + JSONObject.toJSONString(mapData));
|
|
|
+ return AjaxResult.error("认证失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解析结果
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result, Feature.OrderedField);
|
|
|
+ // 加签内容
|
|
|
+ JSONObject content = JSON.parseObject(
|
|
|
+ (String) jsonObject.get("ysepay_authenticate_three_key_element_precise_response"));
|
|
|
+
|
|
|
+ // 校验结果
|
|
|
+ String orderStatus = (String) content.get("order_status");
|
|
|
+ if (StringUtils.isNotBlank(orderStatus) && !"SUCCESS".equals(orderStatus)) {
|
|
|
+ return AjaxResult.error("绑卡认证失败,请核实信息正确性");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 进行绑卡
|
|
|
+ ChannelBankCard channelBankCard = new ChannelBankCard();
|
|
|
+ channelBankCard.setChannelId(channelId);
|
|
|
+ channelBankCard.setBankName(param.getBankName());
|
|
|
+ channelBankCard.setIdCard(param.getIdCard());
|
|
|
+ channelBankCard.setCardNo(param.getCardNo());
|
|
|
+ channelBankCard.setUserName(param.getUserName());
|
|
|
+ boolean res = channelBankCardService.save(channelBankCard);
|
|
|
+ if (!res) {
|
|
|
+ return AjaxResult.error("绑卡失败");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 渠道提现计算手续费
|
|
|
*/
|