|
@@ -11,6 +11,7 @@ import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.BusinessOpportunityService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -40,6 +42,8 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
@Resource
|
|
|
private BusinessOpportunityMapper bOMapper;
|
|
|
@Resource
|
|
|
+ private TaskMapper taskMapper;
|
|
|
+ @Resource
|
|
|
private ActionLogMapper actionLogMapper;
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
@@ -47,6 +51,8 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
private BusinessItemProductMapper biMapper;
|
|
|
@Autowired
|
|
|
private SysFormMapper sysFormMapper;
|
|
|
+ @Autowired
|
|
|
+ private UploadFileMapper uploadFileMapper;
|
|
|
|
|
|
@Override
|
|
|
public List<BusinessOpportunity> getAll(BusinessOpportunity bo) {
|
|
@@ -61,8 +67,27 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
@Override
|
|
|
public BusinessOpportunity getInfo(BusinessOpportunity bo, User user) {
|
|
|
BusinessOpportunity businessOpportunity = bOMapper.selectById(bo.getId());
|
|
|
- businessOpportunity.setBusinessItemProductList(biMapper.selectListToBoId(bo.getId()));
|
|
|
businessOpportunity.setActionLogList(actionLogMapper.selectList(new QueryWrapper<ActionLog>().eq("item_id", bo.getId()).eq("code", "business")));
|
|
|
+ businessOpportunity.setUploadFilePList(uploadFileMapper.selectByInfoList("business",bo.getId()));
|
|
|
+ businessOpportunity.setTaskList(taskMapper.selectList(new QueryWrapper<Task>().eq("business_opportunity_id",bo.getId())));
|
|
|
+ List<BusinessItemProduct> businessItemProducts = biMapper.selectListToBoId(bo.getId());
|
|
|
+ businessOpportunity.setBusinessItemProductList(businessItemProducts);
|
|
|
+ if (businessItemProducts.size() > 0){
|
|
|
+ BigDecimal finalPrice = new BigDecimal(0);
|
|
|
+ BigDecimal discountedPrice = new BigDecimal(0);
|
|
|
+ for (BusinessItemProduct businessItemProduct : businessItemProducts) {
|
|
|
+ BigDecimal price = businessItemProduct.getPrice();
|
|
|
+ // 原价
|
|
|
+ finalPrice = finalPrice.add(price.multiply(new BigDecimal(businessItemProduct.getQuantity())));
|
|
|
+ //折扣率
|
|
|
+ BigDecimal divide = new BigDecimal(businessItemProduct.getDiscount()).divide(new BigDecimal(100));
|
|
|
+ // 折后价格
|
|
|
+ discountedPrice = discountedPrice.add(price.multiply(divide));
|
|
|
+ }
|
|
|
+ BigDecimal divide = discountedPrice.divide(finalPrice);
|
|
|
+ // 整单折扣率
|
|
|
+ businessOpportunity.setFinalPrice(divide.multiply(new BigDecimal(100)));
|
|
|
+ }
|
|
|
return businessOpportunity;
|
|
|
}
|
|
|
|
|
@@ -179,6 +204,26 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, fileName, dataList, path);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpRespMsg saveProduct(BusinessOpportunity bo, User user) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setMsg("操作成功");
|
|
|
+ biMapper.delete(new QueryWrapper<BusinessItemProduct>().eq("business_id",bo.getId()));
|
|
|
+ List<BusinessItemProduct> businessItemProductList = bo.getBusinessItemProductList();
|
|
|
+// biMapper.saveBatch()
|
|
|
+ for (BusinessItemProduct businessItemProduct : businessItemProductList) {
|
|
|
+ biMapper.insert(businessItemProduct);
|
|
|
+ }
|
|
|
+ ActionLog al = new ActionLog();
|
|
|
+ al.setCode("business");
|
|
|
+ al.setName("编辑了产品");
|
|
|
+ al.setUserId(user.getId());
|
|
|
+ al.setItemId(bo.getId());
|
|
|
+ actionLogMapper.insert(al);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
private BusinessOpportunity setNull(BusinessOpportunity bo) {
|
|
|
if (bo.getPlate1() == "") {
|
|
|
bo.setPlate1(null);
|