Kaynağa Gözat

fix:佣金提现

ct 23 saat önce
ebeveyn
işleme
1d6de6765b

+ 9 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -245,6 +245,8 @@ public class Task {
 
     @Autowired
     private IFsConsecutiveWithdrawRecordService fsConsecutiveWithdrawRecordService;
+    @Autowired
+    private IFsIntegralRedPacketLogService fsIntegralRedPacketLogService;
 
 
     /**
@@ -1995,4 +1997,11 @@ public class Task {
     public void checkConsecutiveWithdrawUsers(){
         fsConsecutiveWithdrawRecordService.checkConsecutiveWithdrawUsers();
     }
+
+    /**
+     * 同步微信商家转账状态
+     */
+    public void synchronizationWxMerchantPayStatus(){
+        fsIntegralRedPacketLogService.synchronizationWxMerchantPayStatus();
+    }
 }

+ 7 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsIntegralRedPacketLogServiceImpl.java

@@ -85,11 +85,12 @@ public class FsIntegralRedPacketLogServiceImpl extends ServiceImpl<FsIntegralRed
         //1.
         List<FsIntegralRedPacketLog> list = baseMapper.selectFsIntegralRedPacketLogList(fsIntegralRedPacketLog);
         if(list!=null && !list.isEmpty()){
-            String json = configService.selectConfigByKey("his.integral");
-            IntegralConfig config = JSONUtil.toBean(json, IntegralConfig.class);
+            String json = configService.selectConfigByKey("app.config");
+            AppConfig config = JSONUtil.toBean(json, AppConfig.class);
 
             WxPayConfig payConfig = new WxPayConfig();
             BeanUtils.copyProperties(config, payConfig);
+            payConfig.setNotifyUrl(config.getWithdrawalNotifyUrl());
             WxPayService wxPayService = new WxPayServiceImpl();
             wxPayService.setConfig(payConfig);
             TransferService transferService = wxPayService.getTransferService();
@@ -340,6 +341,7 @@ public class FsIntegralRedPacketLogServiceImpl extends ServiceImpl<FsIntegralRed
 
             WxPayConfig payConfig = new WxPayConfig();
             BeanUtils.copyProperties(config, payConfig);
+            payConfig.setNotifyUrl(config.getWithdrawalNotifyUrl());
             WxPayService wxPayService = new WxPayServiceImpl();
             wxPayService.setConfig(payConfig);
             TransferService transferService = wxPayService.getTransferService();
@@ -360,11 +362,12 @@ public class FsIntegralRedPacketLogServiceImpl extends ServiceImpl<FsIntegralRed
         queryParam.setStatus("0");
         List<FsIntegralRedPacketLog> list = baseMapper.selectFsIntegralRedPacketLogList(queryParam);
         if (list!=null&& !list.isEmpty()){
-            String json = configService.selectConfigByKey("his.integral");
-            IntegralConfig config = JSONUtil.toBean(json, IntegralConfig.class);
+            String json = configService.selectConfigByKey("app.config");
+            AppConfig config = JSONUtil.toBean(json, AppConfig.class);
 
             WxPayConfig payConfig = new WxPayConfig();
             BeanUtils.copyProperties(config, payConfig);
+            payConfig.setNotifyUrl(config.getWithdrawalNotifyUrl());
             WxPayService wxPayService = new WxPayServiceImpl();
             wxPayService.setConfig(payConfig);
             TransferService transferService = wxPayService.getTransferService();

+ 21 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsUserIntegralLogsServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.his.config.AppConfig;
 import com.fs.his.config.IntegralConfig;
 import com.fs.his.domain.AdProfitDetail;
 import com.fs.his.domain.FsUser;
@@ -31,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.util.*;
 
@@ -578,7 +580,25 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
         } else {
             //积分兑换佣金
             if (Objects.equals(value, FsUserIntegralLogTypeEnum.TYPE_32.getValue())){
-                userMap.setWithdrawIntegral(fsUser.getWithdrawIntegral()==null?integralNum:(fsUser.getWithdrawIntegral()+integralNum));
+                long absIntegralNum = Math.abs(integralNum);
+                Long withdrawIntegral = fsUser.getWithdrawIntegral();
+                if (withdrawIntegral == null){
+                    withdrawIntegral = 0l;
+                }
+                if (withdrawIntegral < 0 || withdrawIntegral < absIntegralNum){
+                    return R.error("积分不足");
+                }
+                String json =configService.selectConfigByKey("app.config");
+                AppConfig config= JSONUtil.toBean(json,AppConfig.class);
+                Integer withdrawRatio = config.getWithdrawRatio();
+                if (withdrawRatio==null){
+                    withdrawRatio = 1000;
+                }
+                BigDecimal ratio = BigDecimal.valueOf(withdrawRatio).divide(new BigDecimal(100)); //单位分:元*100
+                BigDecimal commission = new BigDecimal(absIntegralNum).divide(ratio,2, RoundingMode.DOWN);
+                userMap.setWithdrawIntegral(withdrawIntegral+integralNum);
+                userMap.setTotalCommission(fsUser.getTotalCommission().add(commission));
+                userMap.setMayWithdraw(fsUser.getMayWithdraw()==null?BigDecimal.ZERO.add(commission):fsUser.getMayWithdraw().add(commission));
             }
         }
 

+ 28 - 12
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -1840,7 +1840,7 @@ public class FsUserServiceImpl implements IFsUserService {
         }
 
         // 积分转金额  1元=1000积分   库里存储的是单位是分:÷10
-        BigDecimal commission = new BigDecimal(withdrawIntegral ).divide(BigDecimal.valueOf(10),2,RoundingMode.DOWN);
+//        BigDecimal commission = new BigDecimal(withdrawIntegral ).divide(BigDecimal.valueOf(10),2,RoundingMode.DOWN);
         // 更新用户积分 佣金
 //        FsUser user = new FsUser();
 //        user.setUserId(userId);
@@ -1850,13 +1850,13 @@ public class FsUserServiceImpl implements IFsUserService {
 //        user.setUpdateTime(new Date());
 //        user.setMayWithdraw(fsUser.getMayWithdraw().add(commission));
 //        fsUserMapper.updateFsUser(user);
-        FsIntegralExchange fsIntegralExchange = new FsIntegralExchange();
-        fsIntegralExchange.setUserId(userId);
-        fsIntegralExchange.setNickName(fsUser.getNickName());
-        fsIntegralExchange.setPhone(fsUser.getPhone());
-        fsIntegralExchange.setCreateTime(new Date());
-        fsIntegralExchange.setIntegral(-withdrawIntegral);
-        fsIntegralExchangeService.insertFsIntegralExchange(fsIntegralExchange);
+//        FsIntegralExchange fsIntegralExchange = new FsIntegralExchange();
+//        fsIntegralExchange.setUserId(userId);
+//        fsIntegralExchange.setNickName(fsUser.getNickName());
+//        fsIntegralExchange.setPhone(fsUser.getPhone());
+//        fsIntegralExchange.setCreateTime(new Date());
+//        fsIntegralExchange.setIntegral(-withdrawIntegral);
+//        fsIntegralExchangeService.insertFsIntegralExchange(fsIntegralExchange);
 //        //添加积分记录
 //        FsUserIntegralLogs logs = new FsUserIntegralLogs();
 //        logs.setUserId(userId);
@@ -1873,11 +1873,27 @@ public class FsUserServiceImpl implements IFsUserService {
         FsUserAddIntegralTemplateParam integralParam = new FsUserAddIntegralTemplateParam();
         integralParam.setUserId(userId);
         integralParam.setLogType(FsUserIntegralLogTypeEnum.TYPE_32);
-        if(fsIntegralExchange.getId() != null){
-            integralParam.setBusinessId(fsIntegralExchange.getId().toString());
-        }
         integralParam.setPoints(-withdrawIntegral); //默认获取配置
-        userIntegralLogsService.addIntegralTemplate(integralParam);
+        R r = userIntegralLogsService.addIntegralTemplate(integralParam);
+        if (r != null && "200".equals(r.get("code").toString())){
+            FsIntegralExchange fsIntegralExchange = new FsIntegralExchange();
+            fsIntegralExchange.setUserId(userId);
+            fsIntegralExchange.setNickName(fsUser.getNickName());
+            fsIntegralExchange.setPhone(fsUser.getPhone());
+            fsIntegralExchange.setCreateTime(new Date());
+            fsIntegralExchange.setIntegral(-withdrawIntegral);
+            fsIntegralExchangeService.insertFsIntegralExchange(fsIntegralExchange);
+            FsUserIntegralLogs fsUserIntegralLogs = new FsUserIntegralLogs();
+            Object logId = r.get("logId");
+            if (logId != null) {
+                fsUserIntegralLogs.setBusinessId(fsIntegralExchange.getId().toString());
+                fsUserIntegralLogs.setId(Long.valueOf(logId.toString()));
+                userIntegralLogsService.updateFsUserIntegralLogs(fsUserIntegralLogs);
+            } else {
+                log.info("userId:{},积分兑换佣金没有返回logId", userId);
+
+            }
+        }
         return R.ok("兑换成功");
     }
 

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/UserController.java

@@ -33,6 +33,7 @@ import com.fs.qw.service.IQwUserService;
 import com.fs.qw.vo.QwUserVO;
 import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.OSSFactory;
+import com.fs.system.service.ISysConfigService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
@@ -52,6 +53,7 @@ import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -129,6 +131,10 @@ public class UserController extends  AppBaseController {
             if (user.getPhone()!=null&&user.getPhone().length()>11&&!user.getPhone().matches("\\d+")){
                 user.setPhone(decryptPhoneMk(user.getPhone()));
             }
+            BigDecimal mayWithdraw = user.getMayWithdraw();
+            if (mayWithdraw!=null&&mayWithdraw.compareTo(BigDecimal.ZERO)>0){
+               user.setMayWithdraw(mayWithdraw.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN));
+            }
             Map<String,Object> map=new HashMap<>();
             map.put("user",user);
             return R.ok(map);