|
|
@@ -35,6 +35,7 @@ import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.live.domain.LiveOrder;
|
|
|
+import com.fs.live.mapper.LiveOrderMapper;
|
|
|
import com.fs.live.service.ILiveService;
|
|
|
import com.fs.store.config.CompanyMenuConfig;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
@@ -52,6 +53,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.TransactionTemplate;
|
|
|
|
|
|
@@ -119,6 +121,8 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
|
|
|
@Autowired
|
|
|
private ILiveService liveService;
|
|
|
+ @Autowired
|
|
|
+ private LiveOrderMapper liveOrderMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -132,6 +136,51 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
liveService.asyncToCache();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void addCompanyTuiLiveMoney(LiveOrder order) {
|
|
|
+ if(order.getCompanyId()!=null&&order.getCompanyId()>0){
|
|
|
+ Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
|
|
|
+ if(company!=null){
|
|
|
+ String json =configService.selectConfigByKey("store.config");
|
|
|
+ com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
|
|
|
+ //支付金额-(订单金额*rate%)
|
|
|
+ Double rate=config.getTuiMoneyRate()/100d;
|
|
|
+ BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
|
|
|
+ logger.info("写入公司推广佣金:"+tuiMoney);
|
|
|
+ company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
|
|
|
+ companyMapper.updateCompany(company);
|
|
|
+ LiveOrder storeOrderMap=new LiveOrder();
|
|
|
+ storeOrderMap.setOrderId(order.getOrderId());
|
|
|
+ storeOrderMap.setTuiMoney(tuiMoney);
|
|
|
+ liveOrderMapper.updateLiveOrder(storeOrderMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
|
+ public void subLiveCompanyMoney(LiveOrder order) {
|
|
|
+ if(order.getCompanyId()>0){
|
|
|
+ Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
|
|
|
+ if(company!=null){
|
|
|
+ company.setMoney(company.getMoney().subtract(order.getTuiMoney()));
|
|
|
+ company.setTuiMoney(company.getTuiMoney().subtract(order.getTuiMoney()));
|
|
|
+ companyMapper.updateCompany(company);
|
|
|
+ //写入日志
|
|
|
+ CompanyMoneyLogs log=new CompanyMoneyLogs();
|
|
|
+ log.setCompanyId(order.getCompanyId());
|
|
|
+ log.setRemark("订单佣金退款");
|
|
|
+ log.setMoney(order.getTuiMoney().multiply(new BigDecimal(-1)));
|
|
|
+ log.setLogsType(5);
|
|
|
+ log.setBalance(company.getMoney());
|
|
|
+ log.setCreateTime(new Date());
|
|
|
+ log.setBusinessId(order.getOrderId().toString());
|
|
|
+ moneyLogsMapper.insertCompanyMoneyLogs(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<OptionsVO> selectAllCompanyList(Long deptId) {
|
|
|
return companyMapper.selectAllCompanyList(deptId);
|