|
@@ -0,0 +1,63 @@
|
|
|
+package com.fjhx.sale.flow;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fjhx.file.entity.ObsFile;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.flow.core.FlowDelegate;
|
|
|
+import com.fjhx.sale.entity.quotation.dto.QuotationProductDto;
|
|
|
+import com.fjhx.sale.entity.quotation.po.QuotationProduct;
|
|
|
+import com.fjhx.sale.entity.sale.dto.SaleQuotationDto;
|
|
|
+import com.fjhx.sale.service.quotation.QuotationProductService;
|
|
|
+import com.fjhx.sale.service.sale.SaleQuotationService;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class DiscussPriceFlow extends FlowDelegate {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SaleQuotationService saleQuotationService;
|
|
|
+ @Autowired
|
|
|
+ private QuotationProductService quotationProductService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getFlowKey() {
|
|
|
+ return "discuss_price_flow";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long start(Long flowId, JSONObject submitData) {
|
|
|
+ SaleQuotationDto saleQuotationDto = submitData.toJavaObject(SaleQuotationDto.class);
|
|
|
+ List<QuotationProductDto> quotationProductList = saleQuotationDto.getQuotationProductList();
|
|
|
+ for (QuotationProductDto quotationProductDto : quotationProductList) {
|
|
|
+ //复制议价格信息
|
|
|
+ quotationProductDto.setDiscussPrice(quotationProductDto.getPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ //议价附件
|
|
|
+ List<ObsFile> discussFileList = saleQuotationDto.getDiscussFileList();
|
|
|
+ ObsFileUtil.editFile(discussFileList, saleQuotationDto.getId(), 10);
|
|
|
+
|
|
|
+ saleQuotationService.updateById(saleQuotationDto);
|
|
|
+ quotationProductService.updateBatchById(BeanUtil.copyToList(quotationProductList, QuotationProduct.class));
|
|
|
+
|
|
|
+ return saleQuotationDto.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
+ quotationProductService.update(q -> q
|
|
|
+ .eq(QuotationProduct::getSaleQuotationId, businessId)
|
|
|
+ .setSql("price = discuss_price")
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+}
|