|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.company.service.impl;
|
|
package com.fs.company.service.impl;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -20,6 +21,7 @@ import com.fs.company.mapper.*;
|
|
|
import com.fs.company.param.CompanyLiveShowParam;
|
|
import com.fs.company.param.CompanyLiveShowParam;
|
|
|
import com.fs.company.param.CompanyParam;
|
|
import com.fs.company.param.CompanyParam;
|
|
|
import com.fs.company.service.*;
|
|
import com.fs.company.service.*;
|
|
|
|
|
+import com.fs.company.util.CompanyTuiMoneyCalc;
|
|
|
import com.fs.company.vo.*;
|
|
import com.fs.company.vo.*;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.config.RedPacketConfig;
|
|
import com.fs.course.config.RedPacketConfig;
|
|
@@ -33,8 +35,10 @@ import com.fs.his.domain.FsStorePayment;
|
|
|
import com.fs.his.dto.InquiryConfigDTO;
|
|
import com.fs.his.dto.InquiryConfigDTO;
|
|
|
import com.fs.his.mapper.FsStoreOrderMapper;
|
|
import com.fs.his.mapper.FsStoreOrderMapper;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
|
|
+import com.fs.hisStore.domain.FsStoreAfterSalesScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
|
|
|
+import com.fs.hisStore.mapper.FsStoreAfterSalesScrmMapper;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.live.domain.LiveOrder;
|
|
import com.fs.live.domain.LiveOrder;
|
|
|
import com.fs.live.mapper.LiveOrderMapper;
|
|
import com.fs.live.mapper.LiveOrderMapper;
|
|
@@ -60,6 +64,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -143,6 +148,15 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
CompanyBindGatewayMapper companyBindGatewayMapper;
|
|
CompanyBindGatewayMapper companyBindGatewayMapper;
|
|
|
|
|
|
|
|
|
|
+ @Value("${cloud_host.company_name}")
|
|
|
|
|
+ private String companyName;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final BigDecimal BJZM_PARTIAL_REFUND_COMMISSION_RATE = new BigDecimal("0.20");
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreAfterSalesScrmMapper fsStoreAfterSalesScrmMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<CompanyVO> liveShowList(CompanyParam param) {
|
|
public List<CompanyVO> liveShowList(CompanyParam param) {
|
|
|
return companyMapper.liveShowList(param);
|
|
return companyMapper.liveShowList(param);
|
|
@@ -162,9 +176,12 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
if(company!=null){
|
|
if(company!=null){
|
|
|
String json =configService.selectConfigByKey("store.config");
|
|
String json =configService.selectConfigByKey("store.config");
|
|
|
com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
|
- //支付金额-(订单金额*rate%)
|
|
|
|
|
|
|
+ //(实付金额 - 运费)× 费率
|
|
|
Double rate=config.getTuiMoneyRate()/100d;
|
|
Double rate=config.getTuiMoneyRate()/100d;
|
|
|
- BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
|
|
|
|
|
|
|
+ BigDecimal base = CompanyTuiMoneyCalc.commissionBase(
|
|
|
|
|
+ CompanyTuiMoneyCalc.paidAmount(order),
|
|
|
|
|
+ CompanyTuiMoneyCalc.freight(order));
|
|
|
|
|
+ BigDecimal tuiMoney = CompanyTuiMoneyCalc.multiplyRate(base, rate);
|
|
|
logger.info("写入公司推广佣金:"+tuiMoney);
|
|
logger.info("写入公司推广佣金:"+tuiMoney);
|
|
|
company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
|
companyMapper.updateCompany(company);
|
|
companyMapper.updateCompany(company);
|
|
@@ -626,9 +643,12 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
if(company!=null){
|
|
if(company!=null){
|
|
|
String json =configService.selectConfigByKey("his.store");
|
|
String json =configService.selectConfigByKey("his.store");
|
|
|
StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
|
|
StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
|
|
|
- //支付金额-(订单金额*rate%)
|
|
|
|
|
|
|
+ //(实付金额 - 运费)× 费率
|
|
|
Double rate=config.getTuiMoneyRate()/100d;
|
|
Double rate=config.getTuiMoneyRate()/100d;
|
|
|
- BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
|
|
|
|
|
|
|
+ BigDecimal base = CompanyTuiMoneyCalc.commissionBase(
|
|
|
|
|
+ CompanyTuiMoneyCalc.paidAmount(order),
|
|
|
|
|
+ CompanyTuiMoneyCalc.freight(order));
|
|
|
|
|
+ BigDecimal tuiMoney = CompanyTuiMoneyCalc.multiplyRate(base, rate);
|
|
|
logger.info("写入公司推广佣金:"+tuiMoney);
|
|
logger.info("写入公司推广佣金:"+tuiMoney);
|
|
|
company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
|
companyMapper.updateCompany(company);
|
|
companyMapper.updateCompany(company);
|
|
@@ -648,10 +668,13 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
if(company!=null){
|
|
if(company!=null){
|
|
|
String json =configService.selectConfigByKey("his.store");
|
|
String json =configService.selectConfigByKey("his.store");
|
|
|
StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
|
|
StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
|
|
|
- //支付金额-(订单金额*rate%)
|
|
|
|
|
|
|
+ //(实付金额 - 运费)× 费率
|
|
|
if (config.getTuiMoneyRate()!=null){
|
|
if (config.getTuiMoneyRate()!=null){
|
|
|
Double rate=config.getTuiMoneyRate()/100d;
|
|
Double rate=config.getTuiMoneyRate()/100d;
|
|
|
- BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
|
|
|
|
|
|
|
+ BigDecimal base = CompanyTuiMoneyCalc.commissionBase(
|
|
|
|
|
+ CompanyTuiMoneyCalc.paidAmount(order),
|
|
|
|
|
+ CompanyTuiMoneyCalc.freight(order));
|
|
|
|
|
+ BigDecimal tuiMoney = CompanyTuiMoneyCalc.multiplyRate(base, rate);
|
|
|
logger.info("写入公司推广佣金:"+tuiMoney);
|
|
logger.info("写入公司推广佣金:"+tuiMoney);
|
|
|
company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
|
companyMapper.updateCompany(company);
|
|
companyMapper.updateCompany(company);
|
|
@@ -708,11 +731,14 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
// 卓美,按照润天进行百分比进行分佣
|
|
// 卓美,按照润天进行百分比进行分佣
|
|
|
String json =configService.selectConfigByKey("store.config");
|
|
String json =configService.selectConfigByKey("store.config");
|
|
|
com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
|
- //支付金额-(订单金额*rate%)
|
|
|
|
|
|
|
+ //(实付金额 - 运费)× 费率;未配置费率时仍为应付 payPrice
|
|
|
BigDecimal tuiMoney = BigDecimal.ZERO;
|
|
BigDecimal tuiMoney = BigDecimal.ZERO;
|
|
|
if (config != null && config.getTuiMoneyRate() != null) {
|
|
if (config != null && config.getTuiMoneyRate() != null) {
|
|
|
Double rate = config.getTuiMoneyRate() / 100d;
|
|
Double rate = config.getTuiMoneyRate() / 100d;
|
|
|
- tuiMoney = order.getTotalPrice().multiply(new BigDecimal(rate));
|
|
|
|
|
|
|
+ BigDecimal base = CompanyTuiMoneyCalc.commissionBase(
|
|
|
|
|
+ CompanyTuiMoneyCalc.paidAmount(order),
|
|
|
|
|
+ CompanyTuiMoneyCalc.freight(order));
|
|
|
|
|
+ tuiMoney = CompanyTuiMoneyCalc.multiplyRate(base, rate);
|
|
|
} else {
|
|
} else {
|
|
|
tuiMoney = order.getPayPrice();
|
|
tuiMoney = order.getPayPrice();
|
|
|
}
|
|
}
|
|
@@ -731,6 +757,7 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
FsStoreOrderScrm fsStoreOrder = new FsStoreOrderScrm();
|
|
FsStoreOrderScrm fsStoreOrder = new FsStoreOrderScrm();
|
|
|
fsStoreOrder.setId(order.getId());
|
|
fsStoreOrder.setId(order.getId());
|
|
|
fsStoreOrder.setTuiMoneyStatus(1);
|
|
fsStoreOrder.setTuiMoneyStatus(1);
|
|
|
|
|
+ fsStoreOrder.setTuiMoney(tuiMoney);
|
|
|
storeOrderScrmMapper.updateFsStoreOrder(fsStoreOrder);
|
|
storeOrderScrmMapper.updateFsStoreOrder(fsStoreOrder);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -744,11 +771,14 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
// 卓美,按照润天进行百分比进行分佣
|
|
// 卓美,按照润天进行百分比进行分佣
|
|
|
String json =configService.selectConfigByKey("store.config");
|
|
String json =configService.selectConfigByKey("store.config");
|
|
|
com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
|
- //支付金额-(订单金额*rate%)
|
|
|
|
|
|
|
+ //(实付金额 - 运费)× 费率;未配置费率时仍为 payPrice
|
|
|
BigDecimal tuiMoney = BigDecimal.ZERO;
|
|
BigDecimal tuiMoney = BigDecimal.ZERO;
|
|
|
if (config != null && config.getTuiMoneyRate() != null) {
|
|
if (config != null && config.getTuiMoneyRate() != null) {
|
|
|
double rate = config.getTuiMoneyRate() / 100d;
|
|
double rate = config.getTuiMoneyRate() / 100d;
|
|
|
- tuiMoney = order.getTotalPrice().multiply(new BigDecimal(rate));
|
|
|
|
|
|
|
+ BigDecimal base = CompanyTuiMoneyCalc.commissionBase(
|
|
|
|
|
+ CompanyTuiMoneyCalc.paidAmount(order),
|
|
|
|
|
+ CompanyTuiMoneyCalc.freight(order));
|
|
|
|
|
+ tuiMoney = CompanyTuiMoneyCalc.multiplyRate(base, rate);
|
|
|
} else {
|
|
} else {
|
|
|
tuiMoney = order.getPayPrice();
|
|
tuiMoney = order.getPayPrice();
|
|
|
}
|
|
}
|
|
@@ -806,14 +836,29 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
if(order.getCompanyId()>0){
|
|
if(order.getCompanyId()>0){
|
|
|
Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
|
|
Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
|
|
|
if(company!=null){
|
|
if(company!=null){
|
|
|
- company.setMoney(company.getMoney().subtract(order.getTuiMoney()));
|
|
|
|
|
- company.setTuiMoney(company.getTuiMoney().subtract(order.getTuiMoney()));
|
|
|
|
|
|
|
+ BigDecimal clawback = order.getTuiMoney();
|
|
|
|
|
+ BigDecimal logMoney = order.getTuiMoney().multiply(new BigDecimal(-1));
|
|
|
|
|
+
|
|
|
|
|
+ // 260415 卓美财务需求,希望部分退款:部分退款金额 * 20%
|
|
|
|
|
+ if ("北京卓美".equals(companyName)) {
|
|
|
|
|
+ FsStoreAfterSalesScrm after = fsStoreAfterSalesScrmMapper.selectFsStoreAfterSalesByOrderCode(order.getOrderCode());
|
|
|
|
|
+ BigDecimal payMoney = order.getPayMoney() != null ? order.getPayMoney() : BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal refundAmount = after != null && after.getRefundAmount() != null ? after.getRefundAmount() : null;
|
|
|
|
|
+ if (refundAmount != null && payMoney.compareTo(refundAmount) != 0) {
|
|
|
|
|
+ // 部分退款:公司扣回金额 / 日志金额 = -(退款金额 × 20%)
|
|
|
|
|
+ clawback = refundAmount.multiply(BJZM_PARTIAL_REFUND_COMMISSION_RATE).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
+ logMoney = clawback.negate();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ company.setMoney(company.getMoney().subtract(clawback));
|
|
|
|
|
+ company.setTuiMoney(company.getTuiMoney().subtract(clawback));
|
|
|
companyMapper.updateCompany(company);
|
|
companyMapper.updateCompany(company);
|
|
|
//写入日志
|
|
//写入日志
|
|
|
CompanyMoneyLogs log=new CompanyMoneyLogs();
|
|
CompanyMoneyLogs log=new CompanyMoneyLogs();
|
|
|
log.setCompanyId(order.getCompanyId());
|
|
log.setCompanyId(order.getCompanyId());
|
|
|
log.setRemark("订单佣金退款");
|
|
log.setRemark("订单佣金退款");
|
|
|
- log.setMoney(order.getTuiMoney().multiply(new BigDecimal(-1)));
|
|
|
|
|
|
|
+ log.setMoney(logMoney);
|
|
|
log.setLogsType(4);
|
|
log.setLogsType(4);
|
|
|
log.setBalance(company.getMoney());
|
|
log.setBalance(company.getMoney());
|
|
|
log.setCreateTime(new Date());
|
|
log.setCreateTime(new Date());
|