瀏覽代碼

1、倍力优查看物流信息

yfh 9 小時之前
父節點
當前提交
dc63f21d62
共有 1 個文件被更改,包括 17 次插入14 次删除
  1. 17 14
      fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

+ 17 - 14
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -4,6 +4,7 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.fs.common.core.domain.R;
@@ -414,29 +415,31 @@ public class CompanyServiceImpl implements ICompanyService
     @Override
     @Transactional
     public void addCompanyMoney(FsStoreOrderScrm order) {
-        if(order.getCompanyId()!=null&&order.getCompanyId()>0){
+        if(ObjectUtil.isNotEmpty(order.getCompanyId())&&order.getCompanyId()>0){
             Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
             if(company!=null){
-                FsStoreOrder orderMap=new FsStoreOrder();
-                orderMap.setOrderId(order.getId());
+                FsStoreOrderScrm orderMap=new FsStoreOrderScrm();
+                orderMap.setId(order.getId());
                 orderMap.setTuiMoneyStatus(1);
-                storeOrderMapper.updateFsStoreOrder(orderMap);
-                BigDecimal money = order.getPayMoney().add(order.getPayRemain());
-                company.setMoney(company.getMoney().add(money));
+                storeOrderScrmMapper.updateFsStoreOrder(orderMap);
+                String json =configService.selectConfigByKey("store.config");
+                StoreConfig config= JSONUtil.toBean(json, StoreConfig.class);
+                //支付金额-(订单金额*rate%)
+                Double rate=config.getTuiMoneyRate()/100d;
+                BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
+                company.setMoney(company.getMoney().add(tuiMoney));
                 companyMapper.updateCompany(company);
+                //companyMapper.updateCompanyMoney(company.getCompanyId(),tuiMoney);
+                //写入日志
                 CompanyMoneyLogs log=new CompanyMoneyLogs();
-                log.setCompanyId(company.getCompanyId());
-                log.setRemark("佣金入账");
-                log.setMoney(money);
-                log.setLogsType(3);
+                log.setCompanyId(order.getCompanyId());
+                log.setRemark("订单佣金入帐");
+                log.setMoney(tuiMoney);
+                log.setLogsType(4);
                 log.setBalance(company.getMoney());
                 log.setCreateTime(new Date());
                 log.setBusinessId(order.getId().toString());
                 moneyLogsMapper.insertCompanyMoneyLogs(log);
-                FsStoreOrderScrm fsStoreOrder = new FsStoreOrderScrm();
-                fsStoreOrder.setId(order.getId());
-                fsStoreOrder.setTuiMoneyStatus(1);
-                storeOrderScrmMapper.updateFsStoreOrder(fsStoreOrder);
             }
         }
     }