随行付进件通知加入mcc

This commit is contained in:
liuyingfang
2023-09-07 11:39:17 +08:00
parent 994b2c182b
commit f8d624ef28
11 changed files with 335 additions and 99 deletions

View File

@@ -57,7 +57,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
map.put("freeQuota",bigDecimal == null?
new BigDecimal("0.00") : bigDecimal);
map.put("returnFree",userAccountByUserId == null || userAccountByUserId.getBalance() == null?
new BigDecimal("0.00") : userAccountByUserId.getBalance());
new BigDecimal("0.00") : userAccountByUserId.getBalance().setScale(2, BigDecimal.ROUND_DOWN));
return map;
}
@@ -88,7 +88,6 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public void makerQuota(MerchantOrder order){
//查询自己是否为创客
MerchantBaseInfo merchantBaseInfoByMerchantCode = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(order.getMerchantCode());
if(ObjectUtil.isEmpty(merchantBaseInfoByMerchantCode)){
@@ -106,56 +105,39 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
log.error("用户所属关系不存在");
return;
}
if("1".equals(userInfo.getIsExtend())){
if("1".equals(userInfo.getIsExtend())) {
UserMakerQuota userMakerQuota = userMakerQuotaMapper.selectByUserId(userInfo.getUserId().intValue());
if(ObjectUtil.isEmpty(userMakerQuota)){
log.error("当前额度为0,{},{},{}",order.getOrderNumber(),order.getConsumeFee(),userInfo.getUserId());
if (ObjectUtil.isEmpty(userMakerQuota)) {
giveParentQuota(userInfo,order);
return;
}
BigDecimal havingBalance=userMakerQuota.getAmount().subtract(new BigDecimal(order.getConsumeFee())).setScale(2,BigDecimal.ROUND_DOWN);
if(havingBalance.compareTo(BigDecimal.ZERO)>=0){
BigDecimal profit=new BigDecimal(order.getConsumeFee()).multiply(new BigDecimal("0.0038")).setScale(2, BigDecimal.ROUND_DOWN);
BigDecimal havingBalance = userMakerQuota.getAmount().subtract(new BigDecimal(String.valueOf(order.getConsumeFee()))).setScale(2, BigDecimal.ROUND_DOWN);
if (havingBalance.compareTo(BigDecimal.ZERO) >= 0) {
BigDecimal profit = new BigDecimal(String.valueOf(order.getConsumeFee())).subtract(new BigDecimal(String.valueOf(order.getEnterFee())));
BigDecimal bigDecimal = new BigDecimal(order.getConsumeFee().toString());
//提现金额
userAccountService.modFunds(userInfo.getUserId().intValue(), "LD", "增加收益", profit, "");
//额度改变
modMakerFunds(userInfo.getUserId().intValue(), "LD", "收款消耗", bigDecimal.negate(), "",order.getOrderNumber());
modMakerFunds(userInfo.getUserId().intValue(), "LD", "收款消耗", bigDecimal.negate(), "", order.getOrderNumber());
//
giveParentQuota(userInfo,order);
return;
}
if(havingBalance.compareTo(BigDecimal.ZERO)<0){
BigDecimal profit=userMakerQuota.getAmount().multiply(new BigDecimal("0.0038")).setScale(2, BigDecimal.ROUND_DOWN);
if (havingBalance.compareTo(BigDecimal.ZERO) < 0) {
BigDecimal profit = userMakerQuota.getAmount().multiply(new BigDecimal("0.0038")).setScale(6, BigDecimal.ROUND_DOWN);
//提现金额
userAccountService.modFunds(userInfo.getUserId().intValue(), "LD", "增加收益", profit.abs(), "");
modMakerFunds(userInfo.getUserId().intValue(), "LD", "收款消耗", userMakerQuota.getAmount().abs().negate(), "",order.getOrderNumber());
modMakerFunds(userInfo.getUserId().intValue(), "LD", "收款消耗", userMakerQuota.getAmount().abs().negate(), "", order.getOrderNumber());
giveParentQuota(userInfo,order);
return;
}
}else {
UserPromotion userParent = userPromotionMapper.selectByUserIdMC(Long.valueOf(userInfo.getParentUserId()));
if (userParent == null){
log.error("不存在的用户关系:{}",userInfo.getParentUserId());
return;
}
if (!"1".equals(userParent.getIsExtend())){
log.error("商户用户类型异常:{},{}",userParent.getUserId(),userParent.getIsExtend());
return;
}
BigDecimal profit = new BigDecimal(order.getConsumeFee()).multiply(new BigDecimal("0.5")).setScale(2, BigDecimal.ROUND_DOWN);
String s = String.valueOf(userParent.getUserId());
Integer integer = Integer.valueOf(s);
this.modMakerFunds(integer, "SD", "免费额度", profit, "", order.getOrderNumber());
return;
}
giveParentQuota(userInfo,order);
}
//增加提现金额
@Transactional(rollbackFor = Exception.class)
public void profit(UserPromotion userInfo,BigDecimal consumeFee,MerchantOrder order){
UserMakerQuota userMakerQuota = userMakerQuotaMapper.selectByUserId(userInfo.getUserId().intValue());
if (userMakerQuota != null) {
@@ -183,6 +165,28 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
}
/**
* 给上级额度
* @param userInfo
* @param order
*/
@Transactional(rollbackFor = Exception.class)
public void giveParentQuota( UserPromotion userInfo,MerchantOrder order){
UserPromotion userParent = userPromotionMapper.selectByUserIdMC(Long.valueOf(userInfo.getParentUserId()));
if (userParent == null){
log.error("不存在的用户关系:{}",userInfo.getParentUserId());
return;
}
if (!"1".equals(userParent.getIsExtend())){
log.error("商户用户类型异常:{},{}",userParent.getUserId(),userParent.getIsExtend());
return;
}
BigDecimal profit = new BigDecimal(order.getConsumeFee()).multiply(new BigDecimal("0.5")).setScale(2, BigDecimal.ROUND_DOWN);
String s = String.valueOf(userParent.getUserId());
Integer integer = Integer.valueOf(s);
this.modMakerFunds(integer, "SD", "免费额度", profit, "", order.getOrderNumber());
}
/**
* 创客额度相关
* @param userId

View File

@@ -35,7 +35,6 @@ public interface MerchantChannelStatusService extends IService<MerchantChannelSt
qWrapper.eq(MerchantChannelStatus::getVirChannelFlag, channelType);
qWrapper.eq(MerchantChannelStatus::getMerchantCode, merchantCode);
qWrapper.eq(MerchantChannelStatus::getAuthorizationStatus,1);
return getOne(qWrapper);
}
default MerchantChannelStatus getByMerchantCodeAndChannelTypeNew(String merchantCode, String channelType) {

View File

@@ -1695,25 +1695,25 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
Map<String, Object> resultMap = new HashMap<>();
MerchantRefundOrder refundOrder = new MerchantRefundOrder();
if(!"test".equals(environment)){
if (channel.getChannel() == 1) {
resultMap = sxfPayService.refundPay(order, channel.getMerchantId());
} else if (channel.getChannel() == 2) {
MsgException.throwException("通道已关闭!");
} else if (channel.getChannel() == 3) {
resultMap = ryxPayService.refundPay(order, channel.getMerchantId());
} else if (channel.getChannel() == 4) {
resultMap = ysPayOldService.refundPay(order, channel.getMerchantId());
}else if(channel.getChannel()==5){
resultMap = lkLPayServiceImpl.refundPay(order,channel.getMerchantCode());
}
else {
MsgException.throwException("未知通道!");
}
if (ResultCode.SUCCESS.code() != (Integer) resultMap.get("code")) {
throw new MsgException(resultMap.get("msg") + "");
}
if (channel.getChannel() == 1) {
resultMap = sxfPayService.refundPay(order, channel.getMerchantId());
} else if (channel.getChannel() == 2) {
MsgException.throwException("通道已关闭!");
} else if (channel.getChannel() == 3) {
resultMap = ryxPayService.refundPay(order, channel.getMerchantId());
} else if (channel.getChannel() == 4) {
resultMap = ysPayOldService.refundPay(order, channel.getMerchantId());
}else if(channel.getChannel()==5){
resultMap = lkLPayServiceImpl.refundPay(order,channel.getMerchantCode());
}
else {
MsgException.throwException("未知通道!");
}
if (ResultCode.SUCCESS.code() != (Integer) resultMap.get("code")) {
throw new MsgException(resultMap.get("msg") + "");
}
log.info("通道返回信息:{}",JSONUtil.toJsonStr(resultMap));

View File

@@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpEntity;
@@ -66,6 +67,9 @@ public class SxfMerchantAuditServiceImpl extends BaseMerchantAuditService {
@Lazy @Autowired
private MerchantImageService miService;
/**
* @param merchantImage 上传图片信息
* orgId - 机构编号;
@@ -232,6 +236,7 @@ public class SxfMerchantAuditServiceImpl extends BaseMerchantAuditService {
// step 1、组合请求数据
reqData.putAll(getMerchantAuditInfo(userId, merchantBaseInfo, mcs));
reqData.put("callbackUrl", ParametersUtil.domain + "/api/auditCallback/sxf");
//TODO 加与不加支付宝通道ID
reqData.put("specifyALiPayChannel", "2088441721243954");

View File

@@ -1,5 +1,6 @@
package cn.pluss.platform.task;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.BankCardService;
import cn.pluss.platform.MerchantAuditRecordService;
import cn.pluss.platform.entity.*;
@@ -13,6 +14,7 @@ import cn.pluss.platform.suixingfu.SxfConstants;
import cn.pluss.platform.user.impl.GeneralPushUtil;
import cn.pluss.platform.util.IpUtils;
import cn.pluss.platform.util.LogExceptionUtils;
import cn.pluss.platform.util.ParametersUtil;
import cn.pluss.platform.wx.WxCertService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -23,6 +25,7 @@ import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@@ -33,6 +36,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@@ -84,6 +88,8 @@ public class SxfMerAuditHandler {
@Lazy
private SxfMerAuditHandler self;
@Async
public void auditHandler(JSONObject auditResult) {
execute(auditResult);
@@ -96,7 +102,7 @@ public class SxfMerAuditHandler {
MerchantChannelStatus mcs = self.auditCallback(auditResult);
try {
log.info("===================>进件回调,创建店铺开始,商户编号mno为:{}<=====================", auditResult.getString("mno"));
log.info("===================>(餐饮商超)进件回调,创建店铺开始,商户编号mno为:{}<=====================", auditResult.getString("mno"));
self.createStore(mcs);
} catch (Exception e) {
e.printStackTrace();
@@ -119,6 +125,7 @@ public class SxfMerAuditHandler {
.setChannel(1)
.setApplicationId(auditResult.getString("applicationId"))
.setMerchantId(auditResult.getString("mno"));
System.out.println(ParametersUtil.url);
merchantChannelStatus = mcsMapper.selectOne(new QueryWrapper<>(merchantChannelStatus));
String taskStatus = auditResult.getString("taskStatus");
@@ -344,44 +351,59 @@ public class SxfMerAuditHandler {
UserInfo userInfo = userInfoMapper.selectById(userApp.getUserId());
log.info("==============>当前需要同步的用户进件数据为::{}<===================", JSONObject.toJSONString(merchantChannelStatus));
if (userInfo != null) {
MerchantStore merchantStore = new MerchantStore().setMerchantCode(merchantChannelStatus.getMerchantCode());
merchantStore = merchantStoreMapper.selectOne(new QueryWrapper<>(merchantStore));
// MerchantStore merchantStore = new MerchantStore().setMerchantCode(merchantChannelStatus.getMerchantCode());
QueryWrapper storQueryWrapper= new QueryWrapper<>();
storQueryWrapper.eq("merchantCode",merchantChannelStatus.getMerchantCode());
MerchantStore merchantStore = merchantStoreMapper.selectOne(storQueryWrapper);
MerchantBaseInfo merchantBaseInfo = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(merchantChannelStatus.getMerchantCode());
QueryWrapper<MerchantImage> queryWrapper = new QueryWrapper<MerchantImage>()
.eq("merchantCode", merchantChannelStatus.getMerchantCode()).eq("photoType", "06");
MerchantImage merchantImage = merchantImageMapper.selectOne(queryWrapper);
//String baseUrl = "https://life.sxczgkj.cn/web/wmerchant.php?c=site&a=entry&ctrl=store&ac=oauth&op=add_merchan&do=web&m=we7_wmall&i=1";
String baseUrl = "https://kysh.sxczgkj.cn/javaApi/java-api/add-store";
StringBuilder sb = new StringBuilder(baseUrl);
sb.append("?title=").append(merchantBaseInfo.getAlias());
sb.append("&password=").append(userInfo.getPassword().toLowerCase());
sb.append("&mobile=").append(userInfo.getLoginName());
sb.append("&syb_m_id=").append(merchantStore.getId());
sb.append("&addressNo=").append(merchantBaseInfo.getAddressNo());
String address = merchantBaseInfo.getProvince() + merchantBaseInfo.getCity() + merchantBaseInfo.getDistrict() + merchantBaseInfo.getAddress();
String area = merchantBaseInfo.getProvince() +"-"+ merchantBaseInfo.getCity() +"-"+ merchantBaseInfo.getDistrict();
try {
String decodeAddress = URLEncoder.encode(address, "UTF-8");
sb.append("&address=").append(decodeAddress);
String decodeArea = URLEncoder.encode(area, "UTF-8");
sb.append("&area=").append(decodeArea);
String logo = URLEncoder.encode(merchantImage.getPicUrl(), "GBK");
sb.append("&logo=").append(logo);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
log.error("=============>请求生成店铺logo门头照转码异常,异常信息:{}<===============", e.getMessage());
}
Map<String, String> lnxMap = IpUtils.getLocationByAddress(address);
if (lnxMap != null) {
sb.append("&location_x=").append(lnxMap.get("x"));
sb.append("&location_y=").append(lnxMap.get("y"));
}
// 请求生成店铺j
String result = restTemplate.getForObject(sb.toString(), String.class);
log.info("=============>请求生成店铺URL{},请求响应返回的参数为:{}<===============", sb.toString(), result);
List<String> mccList = ParametersUtil.url;
if(ObjectUtil.isEmpty(mccList)||mccList.size()<=0){
log.error("没有配置对应的通之地址");
return;
}
mccList.stream().parallel().forEach(it->{
String baseUrl = it.toString();
StringBuilder sb = new StringBuilder(baseUrl);
sb.append("?title=").append(merchantBaseInfo.getAlias());
sb.append("?mcc=").append(merchantBaseInfo.getMcc());
sb.append("?mccName=").append(merchantBaseInfo.getMccName());
sb.append("&password=").append(userInfo.getPassword().toLowerCase());
sb.append("&mobile=").append(userInfo.getLoginName());
sb.append("&syb_m_id=").append(merchantStore.getId());
sb.append("&addressNo=").append(merchantBaseInfo.getAddressNo());
String address = merchantBaseInfo.getProvince() + merchantBaseInfo.getCity() + merchantBaseInfo.getDistrict() + merchantBaseInfo.getAddress();
String area = merchantBaseInfo.getProvince() +"-"+ merchantBaseInfo.getCity() +"-"+ merchantBaseInfo.getDistrict();
try {
String decodeAddress = URLEncoder.encode(address, "UTF-8");
sb.append("&address=").append(decodeAddress);
String decodeArea = URLEncoder.encode(area, "UTF-8");
sb.append("&area=").append(decodeArea);
String logo = URLEncoder.encode(merchantImage.getPicUrl(), "GBK");
sb.append("&logo=").append(logo);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
log.error("=============>请求生成店铺logo门头照转码异常,异常信息:{}<===============", e.getMessage());
}
Map<String, String> lnxMap = IpUtils.getLocationByAddress(address);
if (lnxMap != null) {
sb.append("&location_x=").append(lnxMap.get("x"));
sb.append("&location_y=").append(lnxMap.get("y"));
}
// 请求生成店铺j
String result = restTemplate.getForObject(sb.toString(), String.class);
log.info("=============>请求生成店铺URL{},请求响应返回的参数为:{}<===============", sb.toString(), result);
});
}
}
/**
* 商户信息修改回调
*