|
@@ -1,10 +1,28 @@
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
+import com.alipay.sofa.runtime.api.annotation.SofaReference;
|
|
|
|
+import com.alipay.sofa.runtime.api.annotation.SofaReference;
|
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.winsea.svc.base.base.entity.CommonRoleResource;
|
|
|
|
+import com.winsea.svc.base.base.service.ICommonRoleResourceService;
|
|
|
|
+import com.winsea.svc.base.security.entity.User;
|
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.SalesClosingReport;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.SalesClosingReport;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.SalesClosingReportMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.SalesClosingReportMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISalesClosingReportService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISalesClosingReportService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import com.yh.saas.toolkit.workflow.service.IWorkflowService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -17,4 +35,133 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class SalesClosingReportServiceImpl extends ServiceImpl<SalesClosingReportMapper, SalesClosingReport> implements ISalesClosingReportService {
|
|
public class SalesClosingReportServiceImpl extends ServiceImpl<SalesClosingReportMapper, SalesClosingReport> implements ISalesClosingReportService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWorkflowService workflowService;
|
|
|
|
+
|
|
|
|
+ @SofaReference
|
|
|
|
+ private ICommonRoleResourceService roleResourceService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 销售平仓统计列表
|
|
|
|
+ *
|
|
|
|
+ * @param salesClosingReport
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<SalesClosingReport> selectSalesClosingOrder(SalesClosingReport salesClosingReport) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (salesClosingReport.getCurrentPage() - 1)
|
|
|
|
+ * salesClosingReport.getPageSize());
|
|
|
|
+ List<String> businessKeys = null;
|
|
|
|
+ businessKeys = workflowService.getTaskBusinessKeysByCode("PURCHASE-CLOSE-REPORT");
|
|
|
|
+ List<String> statusSet = new ArrayList<>();
|
|
|
|
+ List<String> resourceIdList = this.getResourceIdList();
|
|
|
|
+ if (resourceIdList.contains("PURCHAS")) { // 填写,提交 权限做完以后替换
|
|
|
|
+ List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
|
|
|
|
+ statusSet.addAll(statusList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //公司id
|
|
|
|
+ pageView.put("compId", salesClosingReport.getCompId());
|
|
|
|
+ pageView.put("searchKeyWord", salesClosingReport.getSearchKeyWord());
|
|
|
|
+ pageView.put("searchType", salesClosingReport.getSearchType());
|
|
|
|
+ pageView.put("pageSize", salesClosingReport.getPageSize());
|
|
|
|
+ pageView.put("currentPage", salesClosingReport.getCurrentPage());
|
|
|
|
+ pageView.put("contractNo", salesClosingReport.getContractNo());
|
|
|
|
+ pageView.put("businessKeys", businessKeys);
|
|
|
|
+ pageView.put("statusSet", statusSet);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 查询销售订单总数
|
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
|
+ List<SalesClosingReport> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ Page<SalesClosingReport> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(salesClosingReport.getCurrentPage());
|
|
|
|
+ page.setSize(salesClosingReport.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 出纳付款
|
|
|
|
+ * @param salesClosingReport
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String payMoney(SalesClosingReport salesClosingReport) {
|
|
|
|
+ List<SalesClosingReport> salesClosingReportList=salesClosingReport.getSalesClosingReportList();
|
|
|
|
+ Float money = salesClosingReport.getMoney();
|
|
|
|
+ //付款多条
|
|
|
|
+ if (!CollectionUtils.isEmpty(salesClosingReportList)) {
|
|
|
|
+ for (SalesClosingReport salesClosingReport1 : salesClosingReportList) {
|
|
|
|
+ //付款金额大于本次循环未付金额
|
|
|
|
+ if (money >= salesClosingReport1.getAmountNotPayable()) {
|
|
|
|
+ money = money - salesClosingReport1.getAmountNotPayable();
|
|
|
|
+ //全部付款
|
|
|
|
+ salesClosingReport1.setStatus(StatusEnum.PUR_PAYaLL.getName());
|
|
|
|
+ salesClosingReport1.setStatusFlag(StatusEnum.PUR_PAYaLL.getFlag());
|
|
|
|
+ salesClosingReport1.setAmountEdPayable(salesClosingReport1.getAmountEdPayable() + salesClosingReport1.getAmountNotPayable());
|
|
|
|
+ salesClosingReport1.setAmountNotPayable(0.0f);
|
|
|
|
+ this.updateById(salesClosingReport1);
|
|
|
|
+ } else if (money > 0) {
|
|
|
|
+ Float moneyTmp = money - salesClosingReport1.getAmountNotPayable();
|
|
|
|
+ //部分付款
|
|
|
|
+ salesClosingReport1.setStatus(StatusEnum.PUR_PAY.getName());
|
|
|
|
+ salesClosingReport1.setStatusFlag(StatusEnum.PUR_PAY.getFlag());
|
|
|
|
+ salesClosingReport1.setAmountEdPayable(salesClosingReport1.getAmountEdPayable() + money);
|
|
|
|
+ salesClosingReport1.setAmountNotPayable(salesClosingReport1.getAmountNotPayable() - money);
|
|
|
|
+ this.updateById(salesClosingReport1);
|
|
|
|
+ money = moneyTmp;
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 出纳收款
|
|
|
|
+ * @param salesClosingReport
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String collectMoney(SalesClosingReport salesClosingReport) {
|
|
|
|
+ List<SalesClosingReport> salesClosingReportList=salesClosingReport.getSalesClosingReportList();
|
|
|
|
+ Float money = salesClosingReport.getMoney();
|
|
|
|
+ //收款多条
|
|
|
|
+ if (!CollectionUtils.isEmpty(salesClosingReportList)) {
|
|
|
|
+ for (SalesClosingReport salesClosingReport1 : salesClosingReportList) {
|
|
|
|
+ //收款金额大于本次循环未收金额
|
|
|
|
+ if (money >= salesClosingReport1.getCollectionNotPayable()) {
|
|
|
|
+ money = money - salesClosingReport1.getCollectionNotPayable();
|
|
|
|
+ //全部收款
|
|
|
|
+ salesClosingReport1.setStatus(StatusEnum.PUR_COLLECTaLL.getName());
|
|
|
|
+ salesClosingReport1.setStatusFlag(StatusEnum.PUR_COLLECTaLL.getFlag());
|
|
|
|
+ salesClosingReport1.setCollectionEdPayable(salesClosingReport1.getCollectionEdPayable() + salesClosingReport1.getCollectionNotPayable());
|
|
|
|
+ salesClosingReport1.setCollectionNotPayable(0.0f);
|
|
|
|
+ this.updateById(salesClosingReport1);
|
|
|
|
+ } else if (money > 0) {
|
|
|
|
+ Float moneyTmp = money - salesClosingReport1.getCollectionNotPayable();
|
|
|
|
+ //部分收款
|
|
|
|
+ salesClosingReport1.setStatus(StatusEnum.PUR_COLLECT.getName());
|
|
|
|
+ salesClosingReport1.setStatusFlag(StatusEnum.PUR_COLLECT.getFlag());
|
|
|
|
+ salesClosingReport1.setCollectionEdPayable(salesClosingReport1.getCollectionEdPayable() + money);
|
|
|
|
+ salesClosingReport1.setCollectionNotPayable(salesClosingReport1.getCollectionNotPayable() - money);
|
|
|
|
+ this.updateById(salesClosingReport1);
|
|
|
|
+ money = moneyTmp;
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+ private List<String> getResourceIdList() {
|
|
|
|
+ User currentUser = AuthSecurityUtils.getCurrentUserInfo();
|
|
|
|
+ // 当前登录人主要角色
|
|
|
|
+ return roleResourceService.getBindResourcesByUserId(currentUser.getUserId()).stream()
|
|
|
|
+ .map(CommonRoleResource::getResourceId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|