2024-09-23 商户对接文档
parent
4fe409b739
commit
bfb9d1c53b
|
|
@ -29,4 +29,9 @@ public class RedisConstant {
|
|||
* H5登录验证码
|
||||
*/
|
||||
public final static String H5_LOGIN_CACHE = CacheConstants.PROJET+"H5:login:cache:";
|
||||
|
||||
/**
|
||||
* H5申请幂等校验
|
||||
*/
|
||||
public final static String H5_APPLY_CHECK = CacheConstants.PROJET+"H5:apply:check";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,7 @@ public class CustomerApplyLog extends BaseEntity
|
|||
@Excel(name = "成交金额 分")
|
||||
private BigDecimal price;
|
||||
|
||||
@Excel(name = "订单号")
|
||||
private String orderNo;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ public class Merchant extends BaseEntity
|
|||
@Excel(name = "标签")
|
||||
private String label;
|
||||
|
||||
@Excel(name = "下游渠道标识")
|
||||
private String channelSign;
|
||||
|
||||
/** 无社保 */
|
||||
@Excel(name = "无社保")
|
||||
private Boolean socialSecurityNo;
|
||||
|
|
|
|||
|
|
@ -327,7 +327,14 @@ public class SecureUtils {
|
|||
|
||||
String s = "{\"accumulationFund\":1,\"age\":18,\"car\":1,\"career\":1,\"city\":\"重庆\",\"cityCode\":1000,\"creditCard\":1,\"education\":1,\"guarantee\":1,\"hourse\":1,\"idCardMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"monthlyIncome\":5000,\"nameMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"phoneMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"sex\":0,\"socialSecurity\":1,\"zhiMa\":600}";
|
||||
String s1 = "{\"accumulationFund\":1,\"age\":18,\"car\":1,\"career\":1,\"city\":\"重庆\",\"cityCode\":1000,\"creditCard\":1,\"education\":1,\"guarantee\":1,\"hourse\":1,\"idCard\":\"341202199306023511\",\"idCardMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"monthlyIncome\":5000,\"name\":\"朱三\",\"nameMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"phone\":\"15205600635\",\"phoneMd5\":\"331d17d1ca8a091410e3238fab16a863\",\"sex\":0,\"socialSecurity\":1,\"zhiMa\":600}";
|
||||
System.out.println(AesEncode(s,"LwLjtU1Bt8dcxxjY"));
|
||||
String s3 = "{\n" +
|
||||
" \"orderNo\":\"111111\",\n" +
|
||||
" \"md5\":\"aaaaaa\",\n" +
|
||||
" \"price\":100.00,\n" +
|
||||
" \"orderStatus\":\"2\"\n" +
|
||||
"}";
|
||||
|
||||
System.out.println(AesEncode(s3,"LwLjtU1Bt8dcxxjY"));
|
||||
}
|
||||
/**
|
||||
* 解密
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.ruoyi.common.core.domain.http.Channel;
|
|||
import com.ruoyi.common.core.domain.http.Customer;
|
||||
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
|
||||
import com.ruoyi.common.core.domain.http.Merchant;
|
||||
import com.ruoyi.common.core.utils.LocalDateTimeUtils;
|
||||
import com.ruoyi.common.core.utils.ProbitUtil;
|
||||
import com.ruoyi.common.core.utils.SecureUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
|
|
@ -239,15 +240,16 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService
|
|||
result.put("data",map);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
String url = channel.getHtmlLocation() + "token="+remoteCustomerService.getCustomerToken(customer.getPhone());
|
||||
String url = channel.getHtmlLocation() + "?token="+remoteCustomerService.getCustomerToken(customer.getPhone());
|
||||
map.put("url",url);
|
||||
map.put("regist",true);
|
||||
result.put("data",map);
|
||||
CustomerApplyLog customerApplyLog = new CustomerApplyLog();
|
||||
customerApplyLog.setCustomerId(customerInfoByPhoneMd5.getData().getId());
|
||||
customerApplyLog.setChannelId(channel.getId());
|
||||
customerApplyLog.setOrderStatus(0l);
|
||||
remoteCustomerApplyLogService.add(customerApplyLog);
|
||||
//CustomerApplyLog customerApplyLog = new CustomerApplyLog();
|
||||
// customerApplyLog.setCustomerId(customerInfoByPhoneMd5.getData().getId());
|
||||
// customerApplyLog.setChannelId(channel.getId());
|
||||
// customerApplyLog.setOrderStatus(0l);
|
||||
//+"&orderNo="+ LocalDateTimeUtils.getStringFromLocalDateTime()
|
||||
//remoteCustomerApplyLogService.add(customerApplyLog);
|
||||
//返回上游信息
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.system.domain.dto.ApplyCallback;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
|
|
@ -122,4 +123,12 @@ public class CustomerApplyLogController extends BaseController
|
|||
{
|
||||
return toAjax(customerApplyLogService.deleteCustomerApplyLogByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下游数据回调
|
||||
*/
|
||||
@PostMapping("/applyCallback")
|
||||
public AjaxResult applyCallback(@RequestBody ApplyCallback applyCallback){
|
||||
return customerApplyLogService.applyCallBack(applyCallback);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.system.domain.dto.ApplyCallback;
|
||||
import com.ruoyi.system.service.IChannelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -132,4 +133,14 @@ public class MerchantController extends BaseController
|
|||
public AjaxResult getMatchMerchantList(HttpServletRequest request){
|
||||
return merchantService.getMatchMerchantList(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* H5申请商户
|
||||
*/
|
||||
@GetMapping("/h5applyMerchant")
|
||||
public AjaxResult H5applyMerchant(@RequestParam("merchantId") Long merchantId,HttpServletRequest request){
|
||||
return merchantService.H5applyMerchant(merchantId,request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApplyCallback {
|
||||
|
||||
private String sign;
|
||||
|
||||
private String Data;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ApplyCallbackDto {
|
||||
|
||||
|
||||
//订单号
|
||||
private String orderNo;
|
||||
|
||||
//md5
|
||||
private String md5;
|
||||
|
||||
//订单价格
|
||||
private BigDecimal price;
|
||||
|
||||
//订单状态
|
||||
private Integer orderStatus;
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.system.domain.dto.ApplyCallback;
|
||||
|
||||
/**
|
||||
* 客户申请记录Service接口
|
||||
|
|
@ -75,4 +77,11 @@ public interface ICustomerApplyLogService extends IService<CustomerApplyLog>
|
|||
* @return
|
||||
*/
|
||||
R<Boolean> getCustomerApply(Long customerID);
|
||||
|
||||
/**
|
||||
* 申请回调
|
||||
* @param applyCallback
|
||||
* @return
|
||||
*/
|
||||
AjaxResult applyCallBack(ApplyCallback applyCallback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,4 +84,11 @@ public interface IMerchantService extends IService<Merchant>
|
|||
*/
|
||||
public List<Merchant> findAllMerchantList();
|
||||
|
||||
/**
|
||||
* H5申请订单
|
||||
* @param merchantId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
AjaxResult H5applyMerchant(Long merchantId, HttpServletRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,24 @@ package com.ruoyi.system.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.LocalDateTimeUtils;
|
||||
import com.ruoyi.common.core.utils.SecureUtils;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.system.domain.dto.ApplyCallback;
|
||||
import com.ruoyi.system.domain.dto.ApplyCallbackDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.CustomerApplyLogMapper;
|
||||
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
|
||||
import com.ruoyi.system.service.ICustomerApplyLogService;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 客户申请记录Service业务层处理
|
||||
|
|
@ -21,6 +28,7 @@ import com.ruoyi.system.service.ICustomerApplyLogService;
|
|||
* @date 2024-09-15
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CustomerApplyLogServiceImpl extends ServiceImpl<CustomerApplyLogMapper, CustomerApplyLog> implements IService<CustomerApplyLog>,ICustomerApplyLogService
|
||||
{
|
||||
@Autowired
|
||||
|
|
@ -131,4 +139,41 @@ public class CustomerApplyLogServiceImpl extends ServiceImpl<CustomerApplyLogMap
|
|||
.le(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayEndTime())));
|
||||
return R.ok(aLong>0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请回调
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult applyCallBack(ApplyCallback applyCallback) {
|
||||
String s = SecureUtils.AesUtil.AesDecode(applyCallback.getData(), applyCallback.getSign());
|
||||
if (StringUtils.isEmpty(s)){
|
||||
return AjaxResult.error("解密异常");
|
||||
}
|
||||
ApplyCallbackDto applyCallbackDto;
|
||||
try {
|
||||
applyCallbackDto = JSONObject.parseObject(s, ApplyCallbackDto.class);
|
||||
log.info("渠道:{},回调数据:{}",applyCallback.getSign(),applyCallbackDto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error("数据转换异常");
|
||||
}
|
||||
try {
|
||||
CustomerApplyLog customerApplyLog = customerApplyLogMapper.selectOne(new LambdaQueryWrapper<CustomerApplyLog>().eq(CustomerApplyLog::getOrderNo, applyCallbackDto.getOrderNo()));
|
||||
if (applyCallbackDto.getOrderStatus()!=null) {
|
||||
customerApplyLog.setOrderStatus(applyCallbackDto.getOrderStatus().longValue());
|
||||
}
|
||||
if (applyCallbackDto.getPrice()!=null){
|
||||
if (customerApplyLog.getPrice()==null){
|
||||
customerApplyLog.setPrice(applyCallbackDto.getPrice());
|
||||
}else {
|
||||
customerApplyLog.setPrice(customerApplyLog.getPrice().add(applyCallbackDto.getPrice()));
|
||||
}
|
||||
}
|
||||
customerApplyLogMapper.updateById(customerApplyLog);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error("数据异常");
|
||||
}
|
||||
return AjaxResult.success("回调成功");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,24 @@ package com.ruoyi.system.service.impl;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.constant.RedisConstant;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.http.Customer;
|
||||
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.redis.service.CustomerTokenService;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.system.domain.dto.MerchantListDto;
|
||||
import com.ruoyi.system.mapper.CustomerApplyLogMapper;
|
||||
import com.ruoyi.system.mapper.CustomerMapper;
|
||||
|
|
@ -42,6 +47,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|||
private final CustomerTokenService customerTokenService;
|
||||
private final ICustomerApplyLogService customerApplyLogService;
|
||||
private final CustomerMapper customerMapper;
|
||||
private final RedisService redisService;
|
||||
|
||||
/**
|
||||
* 查询商户
|
||||
|
|
@ -154,6 +160,32 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|||
return AjaxResult.success(merchantListDtos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult H5applyMerchant(Long merchantId, HttpServletRequest request) {
|
||||
//获取用户
|
||||
String authorization = request.getHeader("Authorization");
|
||||
Long customerId = customerTokenService.getCustomerId(authorization, false);
|
||||
Boolean aBoolean = redisService.hasKey(RedisConstant.H5_APPLY_CHECK + customerId);
|
||||
if (aBoolean){
|
||||
return AjaxResult.error("请勿重复点击");
|
||||
}
|
||||
Customer customer = customerMapper.selectById(customerId);
|
||||
Merchant merchant = merchantMapper.selectById(merchantId);
|
||||
redisService.setCacheObject(RedisConstant.H5_APPLY_CHECK+customerId,1,10l, TimeUnit.SECONDS);
|
||||
//生成订单号
|
||||
String orderNo = System.currentTimeMillis()+""+merchantId+""+customerId;
|
||||
//记录申请订单
|
||||
CustomerApplyLog customerApplyLog = new CustomerApplyLog();
|
||||
customerApplyLog.setCustomerId(customerId);
|
||||
customerApplyLog.setMerchantId(merchantId);
|
||||
customerApplyLog.setChannelId(customer.getChannelId());
|
||||
customerApplyLog.setOrderStatus(0l);
|
||||
customerApplyLog.setOrderNo(orderNo);
|
||||
customerApplyLog.setCreateTime(new Date());
|
||||
customerApplyLogService.save(customerApplyLog);
|
||||
return AjaxResult.success("点击成功","orderNo="+orderNo+"&sign="+merchant.getChannelSign());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前筛符合的商户
|
||||
* @param customer
|
||||
|
|
|
|||
Loading…
Reference in New Issue