银盛修改费率 /merchantInfo/updateMerchantRate

银盛查询修改费率状态 /merchantInfo/queryMerchantRate
银盛修改回调 /notifyCallback/changeRateCallBack
This commit is contained in:
wangw 2024-04-10 14:16:06 +08:00
parent 63b65d5c74
commit 6309b5c0bb
14 changed files with 285 additions and 22 deletions

View File

@ -41,6 +41,29 @@ public class MerchantInfoController {
@Resource
private SxfMerchantAuditService sxfMerchantAuditService;
/**
* 银盛修改费率接口
* @param custId merchatId 示例 QRY24********95
* @param channel 4是D0 6是D1
* @param mercId 商户Code 示例 M8002023********12
* @return
*/
@GetMapping("/updateMerchantRate")
public RespBody updateMerchantRate(@RequestParam String custId,@RequestParam Integer channel,@RequestParam String mercId) {
return merchantInfoService.updateMerchantRate(custId,channel,mercId);
}
/**
* 修改状态查询接口
* @param changeSysFlowId 变更流水号 merchantInfo/updateMerchantRate 返回
* @return
*/
@GetMapping("/queryMerchantRate")
public RespBody queryMerchantRate(@RequestParam String changeSysFlowId,@RequestParam Integer channel) {
return merchantInfoService.queryCustChange(changeSysFlowId,channel);
}
/**
* 实名认证信息

View File

@ -9,7 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
@Slf4j
@ -22,58 +24,77 @@ public class NotifyController {
@Autowired
private HfMerService hfMerService;
@RequestMapping("changeRateCallBack")
public void changeRateCallBack(HttpServletRequest request, HttpServletResponse response) throws IOException {
StringBuilder requestBody = new StringBuilder();
try {
BufferedReader reader = request.getReader();
String line;
while ((line = reader.readLine()) != null) {
requestBody.append(line);
}
} catch (IOException e) {
log.error("银盛修改费率回调结果:", e);
}
String requestBodyString = requestBody.toString();
log.info("银盛修改费率回调结果 param{}, body{}",JSON.toJSONString(request.getParameterMap()),requestBodyString);
//费率回调 固定notifyType=5 status==00表示通过
//{"notifyType":"5","change":{"note":"审核通过","changeSysFlowId":"CHG202404100018298"},"status":"00"}
// JSONObject bizContent = JSON.parseObject(JSON.parseObject(requestBodyString).get("bizContent").toString());
// String string = bizContent.getString("status");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().write("success");
}
@PostMapping("feedCallBack")
public String feedCallBack(HttpServletRequest request) throws Exception {
log.info(JSON.toJSONString(request.getParameterMap()));
String type = request.getParameter("type");
String type = request.getParameter("type");
//验签请参data
String data = request.getParameter("data");
//验签请参sign
//验签请参sign
String sign = request.getParameter("sign");
hfMerService.callBack(type,data,sign);
hfMerService.callBack(type, data, sign);
return "SUCCESS";
}
@PostMapping("testFeedCallBack")
public String feedCallBack(@RequestBody JSONObject object){
public String feedCallBack(@RequestBody JSONObject object) {
log.info(object.toJSONString());
String type = object.getString("type");
//验签请参data
String data = object.getString("data");
//验签请参sign
String sign = object.getString("sign");
hfMerService.callBack(type.substring(1,type.length()-1),data.substring(1,data.length()-1),sign.substring(1,sign.length()-1));
hfMerService.callBack(type.substring(1, type.length() - 1), data.substring(1, data.length() - 1), sign.substring(1, sign.length() - 1));
return "SUCCESS";
}
@PostMapping("authUser")
public String authUser(@RequestParam("requestId") String requestId){
public String authUser(@RequestParam("requestId") String requestId) {
hfMerService.authInfo(requestId);
return "SUCCESS";
}
@PostMapping("merchantResident")
public String merchantResident(@RequestParam("userId") String userId){
hfMerService.merchantResident(userId,null);
public String merchantResident(@RequestParam("userId") String userId) {
hfMerService.merchantResident(userId, null);
return "SUCCESS";
}
@PostMapping("createStore")
public String createStore(@RequestParam("userId") String userId){
public String createStore(@RequestParam("userId") String userId) {
hfMerService.createStore(userId);
return "SUCCESS";
}
@PostMapping("modifySettle")
public String modifySettle(@RequestParam("userId") String userId){
public String modifySettle(@RequestParam("userId") String userId) {
hfMerService.modifySettle(userId);
return "SUCCESS";
}
}

View File

@ -45,6 +45,7 @@ public class LoginInterceptor implements HandlerInterceptor {
||"/admin/notifyCallback/createStore".equals(requestURI)
||"/admin/notifyCallback/modifySettle".equals(requestURI)
||"/admin/promotion/merchantCode".equals(requestURI)
||"/admin/notifyCallback/changeRateCallBack".equals(requestURI)
){
return true;
}

View File

@ -1,6 +1,8 @@
package com.chaozhanggui.admin.system.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -462,4 +464,19 @@ public class MerchantInfoService {
return new RespBody("000000");
}
public RespBody updateMerchantRate(String custId,Integer channel,String mercId){
String s = merchantService.updateMerchantRate(custId, channel,mercId);
JSONObject jsonObject = JSON.parseObject(s);
RespBody result=new RespBody("000000");
result.setData(jsonObject);
return result;
}
public RespBody queryCustChange(String changeSysFlowId,Integer channel){
String s = merchantService.queryCustChange(changeSysFlowId,channel);
JSONObject jsonObject = JSON.parseObject(s);
RespBody result=new RespBody("000000");
result.setData(jsonObject);
return result;
}
}

View File

@ -21,5 +21,7 @@ public interface TbPlussMerchantChannelFeeMapper {
int updateByPrimaryKey(TbPlussMerchantChannelFee record);
void updateByMercIdAndChannel(TbPlussMerchantChannelFee record);
TbPlussMerchantChannelFee selectByChannelAndMerchantCode(@Param("channelId") Integer channelId,@Param("merchantCode") String merchantCode);
}

View File

@ -0,0 +1,22 @@
package com.chaozhanggui.dao.system.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@AllArgsConstructor
public class RateFeeDetail {
private String rateType;
private String rateFee;
private String rateBottom;
private String rateTop;
public RateFeeDetail(String rateType, String rateFee, String rateBottom) {
this(rateType, rateFee, rateBottom, null);
}
}

View File

@ -0,0 +1,21 @@
package com.chaozhanggui.dao.system.entity;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class RateFeeInfo {
private RateFeeDetail wxPayFee;
private RateFeeDetail aliPayFee;
private RateFeeDetail bank1debitPayFee;
private RateFeeDetail bank1creditPayFee;
private RateFeeDetail bank2debitPayFee;
private RateFeeDetail bank2creditPayFee;
}

View File

@ -0,0 +1,20 @@
package com.chaozhanggui.dao.system.entity;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data
public class RateInfo {
private String contractType;
private String notifyUrl;
private RateFeeInfo codeScanT1Fee;
private RateFeeDetail codeScanD0Fee;
private String mercId;
}

View File

@ -0,0 +1,18 @@
package com.chaozhanggui.dao.system.entity;
import lombok.Data;
/**
* @author lyf
*/
@Data
public class RateInfoD1 {
private String contractType;
private String notifyUrl;
private RateFeeInfo codeScanT1Fee;
private String mercId;
}

View File

@ -104,6 +104,15 @@
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByMercIdAndChannel" parameterType="com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelFee">
update tb_pluss_merchant_channel_fee
set
fee_str = #{feeStr,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where merchant_code = #{merchantCode,jdbcType=VARCHAR}
AND channel = #{channel,jdbcType=VARCHAR}
</update>
<select id="selectByChannelAndMerchantCode" resultMap="BaseResultMap">
SELECT * FROM tb_pluss_merchant_channel_fee WHERE merchant_code=#{merchantCode} AND channel=#{channelId}

View File

@ -27,7 +27,7 @@ public class ReqEntity {
private String certId = "826521773920170";
private String version = "1.0";
private String version = "1.0";//从枚举类 ReqMethod 中获取
public static ReqEntity get(ReqMethods reqMethod) {
Date date = new Date();
@ -44,6 +44,7 @@ public class ReqEntity {
ReqEntity entity = new ReqEntity();
entity.timeStamp = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
entity.method = reqMethod.getMethod();
entity.version = reqMethod.getVersion();
entity.reqId = "SYB_" + RandomUtil.randomString(4) + DateUtil.format(date, "yyMMddHHmmss");
return entity;

View File

@ -20,9 +20,9 @@ public enum ReqMethod {
reportAgain(Req.Url.PREFIX + "smsc/saas/sweep/reportAgain"),
changeMercBaseInfo(Req.Url.PREFIX + "smsc/changeMercBaseInfo"),
uploadChangePic(Req.Url.PREFIX + "file/smsc/uploadChangePic"),
queryCustChange(Req.Url.PREFIX + "smsc/queryCustChange"),
queryCustChange(Req.Url.PREFIX + "smsc/queryCustChange","smsc.queryCustChange","1.2"),
changeMercStlAccInfo(Req.Url.PREFIX + "t1/smsc/changeMercStlAccInfo"),
changeRate(Req.Url.PREFIX + "smsc/changeRate"),
changeRate(Req.Url.PREFIX + "smsc/changeRate","smsc.changeRate","1.3"),
openOnlinePay(Req.Url.PREFIX + "smsc/saas/authority/online"),
regionList(Req.Url.PREFIX + "pregate/trade/findCmmtAreaInfoList"),
@ -45,14 +45,18 @@ public enum ReqMethod {
private final String method;
ReqMethod(String url, String method) {
private final String version;
ReqMethod(String url, String method,String version) {
this.url = url;
this.method = method;
this.version = version;
}
ReqMethod(String url) {
this(url, url.replace(Req.Url.PREFIX, "").replace('/', '.'));
this(url, url.replace(Req.Url.PREFIX, "").replace('/', '.'),"1.0");
}
}

View File

@ -224,4 +224,12 @@ public class MerchantService {
break;
}
}
public String updateMerchantRate(String custId,Integer channel,String mercId){
return ysAuditServiceV3.updateMerchantRate(custId,channel,mercId);
}
public String queryCustChange(String changeSysFlowId,Integer channel){
return ysAuditServiceV3.queryCustChange(changeSysFlowId,channel);
}
}

View File

@ -12,6 +12,7 @@ import cn.hutool.crypto.asymmetric.SignAlgorithm;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -29,6 +30,7 @@ import com.chaozhanggui.merchant.entity.ys.*;
import com.chaozhanggui.merchant.service.sxf.MerchantImageService;
import com.chaozhanggui.merchant.service.sxf.RegionReflectService;
import com.chaozhanggui.merchant.service.sxf.SxfMerchantAuditService;
import com.chaozhanggui.merchant.vo.FeesSetVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
@ -102,6 +104,8 @@ public class YSAuditServiceV3 {
@Resource
private TbPlussMerchantBaseInfoMapper merchantBaseInfoMapper;
@Resource
private TbPlussMerchantChannelFeeMapper feeMapper;
@Resource
private TbPlussMccReflectMapper mccReflectMapper;
@Autowired
private YsConfigV3 ysConfigV3;
@ -300,6 +304,75 @@ public class YSAuditServiceV3 {
noticeMapper.insertSelective(notice);
}
public String queryCustChange(String changeSysFlowId,Integer channel){
JSONObject param=new JSONObject();
param.put("changeSysFlowId",changeSysFlowId);
RespEntity respEntity = req(ReqMethod.queryCustChange, param, channel);
String subCode = respEntity.getSubCode();
//校验进件信息
if (!Objects.equals(subCode, BIZ_SUCCESS)) {
throw new MsgException(respEntity.getSubMsg());
}
return respEntity.getBusinessData();
}
public String updateMerchantRate(String custId,Integer channel,String mercId){
RespEntity respEntity;
String result="";
if (channel == 4) {
RateInfo rateInfo = new RateInfo();
rateInfo.setMercId(custId);
rateInfo.setContractType("2");
rateInfo.setNotifyUrl("http://newky.sxczgkj.cn/api/admin/notifyCallback/changeRateCallBack");
RateFeeInfo rateFeeInfo = new RateFeeInfo();
rateFeeInfo.setAliPayFee(new RateFeeDetail("0", "0.30", "1"));
rateFeeInfo.setWxPayFee(new RateFeeDetail("0", "0.30", "1"));
rateFeeInfo.setBank1debitPayFee(new RateFeeDetail("0", "0.61", "1", "999900"));
rateFeeInfo.setBank1creditPayFee(new RateFeeDetail("0", "0.61", "1", "999900"));
rateFeeInfo.setBank2debitPayFee(new RateFeeDetail("0", "0.60", "1", "999900"));
rateFeeInfo.setBank2creditPayFee(new RateFeeDetail("0", "0.60", "1"));
RateFeeDetail codeScanD0Fee = new RateFeeDetail("0", "0.10", "1");
rateInfo.setCodeScanD0Fee(codeScanD0Fee);
rateInfo.setCodeScanT1Fee(rateFeeInfo);
respEntity = req(ReqMethod.changeRate, (JSONObject) JSON.toJSON(rateInfo), channel);
String subCode = respEntity.getSubCode();
//校验进件信息
if (!Objects.equals(subCode, BIZ_SUCCESS)) {
throw new MsgException(respEntity.getSubMsg());
}
log.info("银盛修改费率D0:{}",JSON.parseObject(respEntity.getBusinessData()));
result=JSON.parseObject(respEntity.getBusinessData()).toString();
channelFee(0.30d, 0.30d, channel+"", mercId);
} else {
RateInfoD1 rateInfoD1 = new RateInfoD1();
rateInfoD1.setMercId(custId);
rateInfoD1.setContractType("2");
rateInfoD1.setNotifyUrl("http://newky.sxczgkj.cn/api/admin/notifyCallback/changeRateCallBack");
RateFeeInfo rateFeeInfo = new RateFeeInfo();
rateFeeInfo.setAliPayFee(new RateFeeDetail("0", "0.30", "1"));
rateFeeInfo.setWxPayFee(new RateFeeDetail("0", "0.30", "1"));
rateFeeInfo.setBank1debitPayFee(new RateFeeDetail("0", "0.61", "1", "999900"));
rateFeeInfo.setBank1creditPayFee(new RateFeeDetail("0", "0.61", "1", "999900"));
rateFeeInfo.setBank2debitPayFee(new RateFeeDetail("0", "0.60", "1", "999900"));
rateFeeInfo.setBank2creditPayFee(new RateFeeDetail("0", "0.60", "1"));
rateInfoD1.setCodeScanT1Fee(rateFeeInfo);
respEntity = req(ReqMethod.changeRate, (JSONObject) JSON.toJSON(rateInfoD1), channel);
String subCode = respEntity.getSubCode();
//校验进件信息
if (!Objects.equals(subCode, BIZ_SUCCESS)) {
throw new MsgException(respEntity.getSubMsg());
}
result=respEntity.getBusinessData();
log.info("银盛修改费率D1:{}",JSON.toJSON(respEntity));
channelFee(0.30d, 0.30d, channel+"", mercId);
}
return result;
}
/**
* 组装进件基本信息
@ -684,28 +757,28 @@ public class YSAuditServiceV3 {
log.info("业务参数==============>" + JSONObject.toJSONString(reqData));
log.info("key = " + key);
// log.info("key = " + key);
AES aes = new AES(key.getBytes(StandardCharsets.UTF_8));
String s = aes.encryptBase64(request.getBizContent());
request.setBizContent(s);
String encryptOriginData = SignUtils.getSignContent((JSONObject) JSON.toJSON(request));
log.info("加签源数据==============>" + encryptOriginData);
// log.info("加签源数据==============>" + encryptOriginData);
request.setSign(Base64.encode(sign.sign(encryptOriginData.getBytes())));
log.warn("请求报文==============>" + JSONObject.toJSONString(request));
log.info("请求地址:{}", reqMethod.getUrl());
HttpEntity<JSONObject> reqEntity = new HttpEntity<>((JSONObject) JSON.toJSON(request), headers);
String respStr = restTemplate.postForObject(reqMethod.getUrl(), reqEntity, String.class);
log.info("返回信息base64{}", respStr);
// log.info("返回信息base64{}", respStr);
byte[] decode = Base64.decode(respStr);
respStr = new String(decode, StandardCharsets.UTF_8);
log.info("返回信息:{}", respStr);
JSONObject param = JSON.parseObject(respStr);
String signContent = SignUtils.getSignContent(param);
System.out.println("加签原参数:" + signContent);
// System.out.println("加签原参数:" + signContent);
boolean checkSign;
try {
@ -1008,4 +1081,27 @@ public class YSAuditServiceV3 {
}
}
public void channelFee(Double WECHAT, Double ALIPAY, String channel, String merchantCode) {
JSONArray array = new JSONArray();
Set<FeesSetVo> feesSet = new HashSet<>();
FeesSetVo w = new FeesSetVo();
w.setFeeCode("WECHAT");
w.setFeeValue(WECHAT);
array.add(w);
FeesSetVo a = new FeesSetVo();
a.setFeeCode("ALIPAY");
a.setFeeValue(ALIPAY);
array.add(a);
feesSet.add(w);
feesSet.add(a);
TbPlussMerchantChannelFee merchantChannelFee = new TbPlussMerchantChannelFee();
merchantChannelFee.setChannel(channel);
merchantChannelFee.setMerchantCode(merchantCode);
merchantChannelFee.setFeeStr(array.toJSONString());
merchantChannelFee.setUpdateTime(new Date());
feeMapper.updateByMercIdAndChannel(merchantChannelFee);
}
}