添加部分退款接口
This commit is contained in:
@@ -49,7 +49,7 @@ public class LaKaLaUtility {
|
||||
|
||||
public static void main(String[] args){
|
||||
String key="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCHB7j7gG3ioLnnr7bsuEXTAh/8YSxSp4lQIYGW9gX0Ikgz9JqARdg4iEnU6tgNirxA6Jdg0AWgLJQxQBEZMkwyK2ZfYgesYhlJkv6WVC8v5OkOrhA9NSQ3iS6JsYegsZO0GJSTtLQaTOF8WobPYe5NI+eWU1fRz2ZyxlWlKshBeQIDAQAB";
|
||||
String data="KdXIXByDVSGVtrX7E3Py2Nbw9c8Dy2qqC0oDgsEtdDMwBjCxCpsjwn+MNivA9wTQdHby36WSVQBbO1jylec8Y4EWXJbtEeW16/DpMSuuCvXunnvYaHmHGxp4/iq6ZSCTtFFoXzTVnLN9iSnKFt11aEsjHn+yTId//8SgVzzRriMpaKSkI6eVHZUKYHTw1JDK1z3NGw+WV0gdK7jiLVGB1vIz8YHgl7b/lYLUr5wwJIANGTSd9XJMUlkZ6kgRf0BQ7qBAaZH11F8h3YovmlHxvGAnS8bmKcSPg7j5+9eRxBG+yR6BvCdjBK146Fc6uQU/wKt6pYY9++5sEVoDUcVPImdOLpyq8g2R4R/Q9DvDDjxl/VJx+QkvMn+riaYnhUl13qUJx15R/9H7Aqs1KQW97vpHS5NbsKDsksfqJhj/Xxt6zmlVWrXbLaQ6kgOCwLKZ8Qve2oKm6mHSo6jZ0Cy4OvOQJt6KHWF6Mz34oaqRhJvcGexAVlWKkJlXLvceM9abFDoHmXK/Oosd3QK6afDJqKLkk7qRGgtZafAfVP3A2kRUPA9EeGqB7r2Dhffipwx49ewRCekWsuwtdtwq21BYuRmWweIA9cs2GYLWQykZ2eBmUQJiPN4fj+qAlgPgRZadBsgoouQDPJNMY0Jh0hXIcMac3k3pLmVRLqUhVDv6paA=";
|
||||
String data="dPSiEm1MkN0mLs7boHPYscix5W8CpiwTssJe9eXyof+JrExCmSYJVCdqgIZfz/YZb58nYp9CxaOzYM3YgLfsUC226myZHrVDvzRIVm5C5Z14QBiy+RYrbC7WTQTRqtdJtl/C7zW7nZw2aTFnU7gxeXFOnwLgTMzrow83v39BQfCGW+mtjfXxxR5CJq79GSwLF3CiLB4Q2AVuDRlM0DN5HHtbfzktDm3QxyQ+mG/T/nqVH/DGgQTT8Rr5DK5wA2grybZXy9lcx0qJsqpKlpSCBzVKw6AQZ+bVa+qdzuCoswDAljDdaUEDFy5p081J7pMbpUoYsMRJyZ9zskLg02z9SA==";
|
||||
System.out.println(LaKaLaUtility.decrypt(key,data));
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ public class LkLPayServiceImpl implements PayService {
|
||||
|
||||
|
||||
String req_time = DateUtils.getSdfTimes();
|
||||
Long order_amt = changeY2F(order.getConsumeFee());
|
||||
Long order_amt = changeY2F(order.getRefundAmt().doubleValue());
|
||||
|
||||
|
||||
String refundNo = "LKLR" + StringUtil.getBillno();
|
||||
|
||||
@@ -101,16 +101,12 @@ public class LklPayService {
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
String response = req(body, "api/v2/iot/cloud/device/activate");
|
||||
if (ObjectUtil.isNotEmpty(response)) {
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
if (object.containsKey("retCode") && "000000".equals(object.getString("retCode"))) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -700,17 +696,17 @@ public class LklPayService {
|
||||
// "}\n";
|
||||
// mothod="api/v2/saas/query/wx_openid_query";
|
||||
|
||||
|
||||
//
|
||||
String body="{\n" +
|
||||
" \"ver\":\"1.0.0\",\n" +
|
||||
" \"timestamp\":\""+req_time+"\",\n" +
|
||||
" \"reqId\":\""+req_time+"\",\n" +
|
||||
" \"reqData\":{\n" +
|
||||
" \"merId\":\"8227910729806KN\",\n" +
|
||||
" \"termId\":\"F2131334\",\n" +
|
||||
" \"merId\":\"82279105094089M\",\n" +
|
||||
" \"termId\":\"E6260896\",\n" +
|
||||
" \"sn\":\"QR939000089076\",\n" +
|
||||
" \"businessType\":\"1\",\n" +
|
||||
" \"shopName\":\"爱吃樱桃小的丸子\",\n" +
|
||||
" \"shopName\":\"小汪的专属小店\",\n" +
|
||||
" \"source\":\"LOAP\",\n" +
|
||||
" \"merOrgNo\":\"966805\"\n" +
|
||||
" }\n" +
|
||||
@@ -724,8 +720,8 @@ public class LklPayService {
|
||||
// " \"timestamp\":\""+req_time+"\",\n" +
|
||||
// " \"reqId\":\""+req_time+"\",\n" +
|
||||
// " \"reqData\":{\n" +
|
||||
// " \"merId\":\"8227910729806KN\",\n" +
|
||||
// " \"termId\":\"F2131334\",\n" +
|
||||
// " \"merId\":\"82279105094088V\",\n" +
|
||||
// " \"termId\":\"E6435787\",\n" +
|
||||
// " \"sn\":\"QR939000089076\",\n" +
|
||||
// " \"source\":\"KSAAS\"\n" +
|
||||
// " }\n" +
|
||||
|
||||
@@ -295,6 +295,10 @@ public interface MerchantOrderService extends IService<MerchantOrder> {
|
||||
*/
|
||||
void apiReturnOrderV2(String orderNumber,String refundReason,String type, String noticeCode, String payPassword);
|
||||
|
||||
JSONObject apiReturnOrderV3(String orderNumber,BigDecimal amount, String mercRefundNo,String notifyUrl,String noticeCode, String payPassword,String refundReason,String type);
|
||||
|
||||
|
||||
JSONObject apiReturnOrderV4(String orderNumber,BigDecimal amount,String mercRefundNo,String notifyUrl, String noticeCode, String refundReason,String type);
|
||||
|
||||
void setMemberRechargeOrder(MemberRechargeDTO dto, MerchantMenber menber, MemberOrder memberOrder,MerchantMenberRecharge recharge,MerchantOrder order);
|
||||
|
||||
|
||||
@@ -1631,6 +1631,122 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
returnOrder(orderNumber, refundReason, type, noticeCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject apiReturnOrderV3(String orderNumber,BigDecimal amount, String mercRefundNo,String notifyUrl,String noticeCode, String payPassword,String refundReason,String type) {
|
||||
|
||||
if (StringUtils.isEmpty(payPassword)) {
|
||||
throw new MsgException("缺少支付密码");
|
||||
}
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
UserInfo userInfo = new UserInfo().setId(userApp.getUserId());
|
||||
userInfo = userInfoService.getOne(new QueryWrapper<>(userInfo));
|
||||
|
||||
String psdMd5 = SecureUtil.md5(payPassword);
|
||||
if (!psdMd5.equals(userInfo.getPayPassword())) {
|
||||
throw new MsgException("支付密码错误");
|
||||
}
|
||||
|
||||
return apiReturnOrderV4(orderNumber,amount,mercRefundNo,notifyUrl,noticeCode,type,refundReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject apiReturnOrderV4(String orderNumber, BigDecimal amount,String mercRefundNo,String notifyUrl, String noticeCode,String type,String refundReason) {
|
||||
// 更新通知的处理状态
|
||||
if (StringUtil.isNotEmpty(noticeCode)) {
|
||||
Notice queryNotice = new Notice();
|
||||
queryNotice.setNoticeCode(noticeCode);
|
||||
List<Notice> queryNoticeList = noticeService.queryNoticeList(queryNotice);
|
||||
if (queryNoticeList != null && queryNoticeList.size() > 0) {
|
||||
queryNotice = queryNoticeList.get(0);
|
||||
queryNotice.setIsDeal(1);
|
||||
queryNotice.setIsApply(1);
|
||||
noticeService.updateNotice(queryNotice);
|
||||
}
|
||||
}
|
||||
|
||||
MerchantOrderVO order=checkRefundOrderParams(orderNumber,amount);
|
||||
order.setRemark(refundReason);
|
||||
MerchantChannelStatus channel = null;
|
||||
if("2".equals(order.getAisleSwitch())){
|
||||
channel = merchantChannelStatusService.getByMerchantCode(order.getMerchantCode(), 1);
|
||||
}else{
|
||||
channel = merchantChannelStatusService.getByMerchantCode(order.getMerchantCode(), Integer.valueOf(order.getAisleSwitch()));
|
||||
}
|
||||
MsgException.checkNull(channel,"订单通道获取异常");
|
||||
MsgException.check("7".equals(channel.getStatus()),"实时到账审核中,请耐心等待或者联系客服!");
|
||||
MsgException.check(!channel.isPayment(),"当前进件状态未通过,请耐心等待或联系客服!");
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
MerchantRefundOrder refundOrder = new MerchantRefundOrder();
|
||||
|
||||
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") + "");
|
||||
}
|
||||
MerchantOrder update = new MerchantOrder();
|
||||
if(StringUtil.isNotEmpty(order.getMarketAmt()) && order.getMarketAmt().doubleValue() > 0){
|
||||
update.setId(order.getId());
|
||||
update.setMarketAmt(BigDecimal.ZERO);
|
||||
}
|
||||
update.setRefundAmt(BigDecimal.valueOf(order.getConsumeFee()));
|
||||
merchantOrderMapper.updateById(update);
|
||||
refundOrder.convert(order, resultMap,channel.getMerchantId(),order.getRefundAmt(),mercRefundNo,notifyUrl);
|
||||
order.setId(null);
|
||||
order.setUpdateTime(new Date());
|
||||
if(order.getRefundType()==2){
|
||||
order.setStatus("2");
|
||||
}
|
||||
|
||||
if(order.getRefundType()==6){
|
||||
order.setStatus("6");
|
||||
}
|
||||
order.setMarketAmt(BigDecimal.ZERO);
|
||||
order.setRefundAmt(BigDecimal.valueOf(order.getConsumeFee()));
|
||||
merchantOrderMapper.insert(order);
|
||||
realFansService.removeProfit(order.getOrderNumber());
|
||||
merchantRefundOrderMapper.insert(refundOrder);
|
||||
if("app".equals(type)){
|
||||
//向小程序后台推送退款消息
|
||||
String url = "https://shop.shouyinbei.net/addons/we7_wmall/payment/refund/notify.php";
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("orderNumber",orderNumber);
|
||||
try {
|
||||
String result = HttpUtil.doPostJson(url, params.toJSONString());
|
||||
log.info("================>【app退款】消息通知结果:{}<================",result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info("================>【app退款】消息通知异常,异常信息:{}<================",e.getMessage());
|
||||
}
|
||||
}else{
|
||||
pushService.pushMsg(String.valueOf(order.getUserId()), PushService.REFUND_ORDER);
|
||||
}
|
||||
|
||||
|
||||
JSONObject object=new JSONObject();
|
||||
object.put("orderNumber",orderNumber);
|
||||
object.put("refundOrderNumber",refundOrder.getRefundNo());
|
||||
object.put("amount",refundOrder.getRefundAmt());
|
||||
object.put("refundTime",refundOrder.getRefundTime());
|
||||
object.put("status",refundOrder.getStatus());
|
||||
object.put("mercRefundNo",mercRefundNo);
|
||||
object.put("notifyUrl",notifyUrl);
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查退款订单参数
|
||||
*
|
||||
@@ -1668,6 +1784,55 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
return queryMerchantOrder;
|
||||
}
|
||||
|
||||
|
||||
private MerchantOrderVO checkRefundOrderParams(String orderNumber,BigDecimal amount) {
|
||||
MerchantOrderVO queryMerchantOrder = (MerchantOrderVO) new MerchantOrderVO().setOrderNumber(orderNumber);
|
||||
List<MerchantOrderVO> queryMerchantOrderList = merchantOrderVOMapper.selectList(new QueryWrapper<>(queryMerchantOrder));
|
||||
if (queryMerchantOrderList.isEmpty()) {
|
||||
MsgException.throwException("该订单不存在");
|
||||
}
|
||||
queryMerchantOrder = queryMerchantOrderList.get(0);
|
||||
|
||||
UserApp queryUserApp = new UserApp();
|
||||
queryUserApp.setMerchantCode(queryMerchantOrder.getMerchantCode());
|
||||
queryUserApp.setUserType("promoter");
|
||||
List<UserApp> queryUserAppList = userAppMapper.queryUserAppList(queryUserApp);
|
||||
if (queryUserAppList.isEmpty()) {
|
||||
MsgException.throwException("无商户信息");
|
||||
}
|
||||
queryUserApp = queryUserAppList.get(0);
|
||||
|
||||
QueryWrapper<MerchantBaseInfo> merchantQuery = new QueryWrapper<MerchantBaseInfo>().eq("merchantCode", queryMerchantOrder.getMerchantCode());
|
||||
MerchantBaseInfo merchantInfo = merchantBaseInfoService.getOne(merchantQuery);
|
||||
if (merchantInfo != null) {
|
||||
queryMerchantOrder.setAlias(merchantInfo.getAlias());
|
||||
}
|
||||
|
||||
|
||||
BigDecimal returnAmount=merchantRefundOrderMapper.selectOrderByOrderNumber(orderNumber);
|
||||
if(N.egt(returnAmount,new BigDecimal(queryMerchantOrder.getConsumeFee()))){
|
||||
MsgException.check(true, "订单已全额退款,请勿重复操作!");
|
||||
}
|
||||
|
||||
if(N.gt(returnAmount.add(amount),new BigDecimal(queryMerchantOrder.getConsumeFee()))){
|
||||
MsgException.check(true, "退款金额超限,请输入正确的退款金额!");
|
||||
}
|
||||
|
||||
if(N.eq(returnAmount.add(amount),new BigDecimal(queryMerchantOrder.getConsumeFee()))){
|
||||
queryMerchantOrder.setRefundType(2);
|
||||
queryMerchantOrder.setRefundAmt(new BigDecimal(queryMerchantOrder.getConsumeFee()));
|
||||
}
|
||||
|
||||
if(N.gt(new BigDecimal(queryMerchantOrder.getConsumeFee()),returnAmount.add(amount))){
|
||||
queryMerchantOrder.setRefundType(6);
|
||||
queryMerchantOrder.setRefundAmt(returnAmount.add(amount));
|
||||
}
|
||||
|
||||
queryMerchantOrder.setUserId(queryUserApp.getUserId().intValue());
|
||||
return queryMerchantOrder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单补单操作
|
||||
*
|
||||
|
||||
@@ -320,34 +320,33 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
||||
// }
|
||||
|
||||
if("MC".equals(userPromotion.getTypeCode())){
|
||||
if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
|
||||
BigDecimal profitRate = BigDecimal.ZERO;
|
||||
|
||||
if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
|
||||
profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
|
||||
nowRate = new BigDecimal(userPromotion.getCurrentFee());
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UserApp nowUserApp = userAppMapper.selectByUserId(userId);
|
||||
if(ObjectUtil.isEmpty(nowUserApp)){
|
||||
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
||||
return;
|
||||
}
|
||||
log.info("userId:{},rate:{},amount:{}",nowUserApp.getUserId(),profitRate,order.getConsumeFee());
|
||||
|
||||
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
||||
MerchantProfit profit = new MerchantProfit(nowUserApp, nowUserApp, order, profitAmt, profitRate, "5", "1");
|
||||
profits.add(profit);
|
||||
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
|
||||
}else {
|
||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
}
|
||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
// if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
|
||||
// BigDecimal profitRate = BigDecimal.ZERO;
|
||||
//
|
||||
// if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
|
||||
// profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
|
||||
// nowRate = new BigDecimal(userPromotion.getCurrentFee());
|
||||
// }else {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// UserApp nowUserApp = userAppMapper.selectByUserId(userId);
|
||||
// if(ObjectUtil.isEmpty(nowUserApp)){
|
||||
// log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// log.info("userId:{},rate:{},amount:{}",nowUserApp.getUserId(),profitRate,order.getConsumeFee());
|
||||
// BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
||||
// MerchantProfit profit = new MerchantProfit(nowUserApp, nowUserApp, order, profitAmt, profitRate, "5", "1");
|
||||
// profits.add(profit);
|
||||
// sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
||||
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
//
|
||||
// }else {
|
||||
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
// }
|
||||
}else {
|
||||
BigDecimal profitRate = BigDecimal.ZERO;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.pluss.platform.realFans.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.fans.FansService;
|
||||
import cn.pluss.platform.mapper.*;
|
||||
@@ -20,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@@ -36,37 +38,135 @@ public class RealFansServiceImpl extends ServiceImpl<RealFansMapper, RealFans> i
|
||||
private final MerchantProfitService merchantProfitService;
|
||||
private final UserIntegralService userIntegralService;
|
||||
|
||||
@Resource
|
||||
private UserAppMapper userAppMapper;
|
||||
|
||||
@Autowired
|
||||
private GeneralPushUtil generalPushUtil;
|
||||
|
||||
@Override
|
||||
public void removeProfit(String orderNumber) {
|
||||
log.info("去除分润开始,订单编号:{}<==========================",orderNumber);
|
||||
//TODO 去除推广分润
|
||||
QueryWrapper<MerchantProfit> queryWrapper = new QueryWrapper<MerchantProfit>();
|
||||
queryWrapper.eq("orderNumber",orderNumber);
|
||||
merchantProfitService.remove(queryWrapper);
|
||||
//TODO 去除粉丝分润
|
||||
Fans fans = new Fans();
|
||||
fans.setOrderNumber(orderNumber);
|
||||
List<Fans> fansList = fansService.queryFansList(fans);
|
||||
if(!fansList.isEmpty()){
|
||||
Fans fansInfo = fansList.get(0);
|
||||
fansInfo.setShareMoney("0.00");
|
||||
fansService.updateFans(fansInfo);
|
||||
|
||||
MerchantOrder order= merchantOrderService.queryMerchantOrder(new MerchantOrder().setOrderNumber(orderNumber));
|
||||
if(ObjectUtil.isEmpty(order)){
|
||||
log.error("订单信息不存在:{}",orderNumber);
|
||||
return;
|
||||
}
|
||||
UpdateWrapper<MerchantOrder> updateWrapper = new UpdateWrapper<MerchantOrder>()
|
||||
.set("fansShareMoney",0)
|
||||
.set("profitShareMoney",0)
|
||||
.eq("orderNumber",orderNumber);
|
||||
merchantOrderService.update(updateWrapper);
|
||||
//删除积分
|
||||
QueryWrapper<UserIntegral> integralWrapper = new QueryWrapper<UserIntegral>();
|
||||
integralWrapper.eq("orderNumber",orderNumber);
|
||||
userIntegralService.remove(integralWrapper);
|
||||
log.info("======================>去除分润分润结束<==========================");
|
||||
|
||||
cancelUserProfitV2(order);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void cancelUserProfitV2(MerchantOrder order) {
|
||||
Vector<MerchantProfit> profitList = new Vector<MerchantProfit>();
|
||||
|
||||
UserPromotion userPromotion= userPromotionMapper.selectByUserId(order.getUserId().toString());
|
||||
if(ObjectUtil.isEmpty(userPromotion)){
|
||||
log.error("订单号:{},用户信息不存在",order.getOrderNumber());
|
||||
return;
|
||||
}
|
||||
|
||||
if("SO".equals(userPromotion.getTypeCode())||"FO".equals(userPromotion.getTypeCode())||"MG".equals(userPromotion.getTypeCode())){
|
||||
log.error("此为系统用户不参与分润");
|
||||
return;
|
||||
}
|
||||
|
||||
createUserV3Profit(order,userPromotion.getParentUserId(),profitList,order.getRate().divide(BigDecimal.valueOf(100)));
|
||||
|
||||
if (!profitList.isEmpty()) {
|
||||
log.info("【去除分润计算完成】开始批量插入分润数据,生成分润的订单编号:{},分润条数:{}", order.getOrderNumber(), profitList.size());
|
||||
try {
|
||||
merchantProfitService.batchInsert(profitList);
|
||||
log.info("【去除分润插入】插入分润成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info("【去除分润插入】插入分润异常,异常信息:{}", e.getMessage());
|
||||
}
|
||||
//累计生成分润的总额
|
||||
BigDecimal sumProfitMoney = BigDecimal.ZERO;
|
||||
for (MerchantProfit p : profitList) {
|
||||
sumProfitMoney = sumProfitMoney.add(new BigDecimal(String.valueOf(p.getPrice())));
|
||||
}
|
||||
order.setProfitShareMoney(sumProfitMoney.abs().negate().setScale(4, BigDecimal.ROUND_DOWN).doubleValue());
|
||||
log.info("【去除分润结算结束】订单号:{}产生的分润总额:{}", order.getOrderNumber(), sumProfitMoney);
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
UserPromotionMapper userPromotionMapper;
|
||||
|
||||
private void createUserV3Profit(MerchantOrder order,String userId,Vector<MerchantProfit> profits,BigDecimal nowRate){
|
||||
UserPromotion userPromotion= userPromotionMapper.selectByUserId(userId);
|
||||
if(ObjectUtil.isEmpty(userPromotion)){
|
||||
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
||||
return;
|
||||
}
|
||||
|
||||
// if("0".equals(userPromotion.getParentUserId())){
|
||||
// log.error("订单号:{} 父级为:{},父级类型:{},分润结束,获取分润数为:{},",order.getOrderNumber(),userPromotion.getParentUserId(),userPromotion.getTypeCode(),profits.size());
|
||||
// return;
|
||||
// }
|
||||
|
||||
if("MC".equals(userPromotion.getTypeCode())){
|
||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
// if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
|
||||
// BigDecimal profitRate = BigDecimal.ZERO;
|
||||
//
|
||||
// if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
|
||||
// profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
|
||||
// nowRate = new BigDecimal(userPromotion.getCurrentFee());
|
||||
// }else {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// UserApp nowUserApp = userAppMapper.selectByUserId(userId);
|
||||
// if(ObjectUtil.isEmpty(nowUserApp)){
|
||||
// log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// log.info("userId:{},rate:{},amount:{}",nowUserApp.getUserId(),profitRate,order.getConsumeFee());
|
||||
// BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
||||
// MerchantProfit profit = new MerchantProfit(nowUserApp, nowUserApp, order, profitAmt, profitRate, "5", "1");
|
||||
// profits.add(profit);
|
||||
//// sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
||||
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
//
|
||||
// }else {
|
||||
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
// }
|
||||
}else {
|
||||
BigDecimal profitRate = BigDecimal.ZERO;
|
||||
|
||||
if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
|
||||
profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
|
||||
nowRate = new BigDecimal(userPromotion.getCurrentFee());
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UserApp nowUserApp = userAppMapper.selectByUserId(userId);
|
||||
if(ObjectUtil.isEmpty(nowUserApp)){
|
||||
log.error("订单号:{},去除分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
||||
return;
|
||||
}
|
||||
log.info("userId:{},rate:{},amount:{}",nowUserApp.getUserId(),profitRate,order.getConsumeFee());
|
||||
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
||||
MerchantProfit profit = new MerchantProfit(nowUserApp,nowUserApp , order, profitAmt.abs().negate(), profitRate, "5", "1");
|
||||
profits.add(profit);
|
||||
// sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeProfit(MerchantOrder order, BigDecimal refundAmt,BigDecimal useRefundAmt) {
|
||||
BigDecimal consumeFee = BigDecimal.valueOf(order.getConsumeFee());
|
||||
|
||||
@@ -98,7 +98,6 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountMapper, UserA
|
||||
flow.setBalance(userAccount.getBalance());
|
||||
flow.setCreateTime(new Date());
|
||||
userAccountFlowMapper.insert(flow);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user