|
@@ -1,11 +1,23 @@
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.SalePlanInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.SalePlanInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.SalePlanInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.SalePlanInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISalePlanInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISalePlanInfoService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.util.GeTuiUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 记录销售计划 服务实现类
|
|
* 记录销售计划 服务实现类
|
|
@@ -16,5 +28,178 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class SalePlanInfoServiceImpl extends ServiceImpl<SalePlanInfoMapper, SalePlanInfo> implements ISalePlanInfoService {
|
|
public class SalePlanInfoServiceImpl extends ServiceImpl<SalePlanInfoMapper, SalePlanInfo> implements ISalePlanInfoService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonBillOperateHisService billOperateHisService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GeTuiUtils geTuiUtils;
|
|
|
|
+ /**
|
|
|
|
+ * 查看销售计划
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public SalePlanInfo getSalePlanInfo(String id) {
|
|
|
|
+ //查看销售计划信息
|
|
|
|
+ SalePlanInfo salePlanInfo = this.selectById(id);
|
|
|
|
+ return salePlanInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 编辑销售计划
|
|
|
|
+ * @param salePlanInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String editSalePlanInfo(SalePlanInfo salePlanInfo) {
|
|
|
|
+ //状态改为待审核
|
|
|
|
+ salePlanInfo.setStatus(StatusEnum.ORDER_REVIEWED.getName());
|
|
|
|
+ salePlanInfo.setStatusFlag(StatusEnum.ORDER_REVIEWED.getFlag());
|
|
|
|
+ boolean one = this.updateById(salePlanInfo);
|
|
|
|
+ if (one) {
|
|
|
|
+ return "OK";
|
|
|
|
+ } else {
|
|
|
|
+ return "NG";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除销售计划
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteSalePlanInfo(String id) {
|
|
|
|
+ //查询销售计划信息
|
|
|
|
+ SalePlanInfo salePlanInfo = this.selectById(id);
|
|
|
|
+ if(salePlanInfo != null){
|
|
|
|
+ //删除销售计划信息
|
|
|
|
+ this.deleteById(salePlanInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 销售计划列表
|
|
|
|
+ * @param salePlanInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<SalePlanInfo> selectSalePlanInfo(SalePlanInfo salePlanInfo) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (salePlanInfo.getCurrentPage() - 1)
|
|
|
|
+ * salePlanInfo.getPageSize());
|
|
|
|
+ //公司id
|
|
|
|
+ pageView.put("compId",salePlanInfo.getCompId());
|
|
|
|
+ pageView.put("commonId",salePlanInfo.getCommonId());
|
|
|
|
+ pageView.put("searchKeyWord",salePlanInfo.getSearchKeyWord());
|
|
|
|
+ pageView.put("searchType", salePlanInfo.getSearchType());
|
|
|
|
+ pageView.put("pcFlag",salePlanInfo.getPcFlag());
|
|
|
|
+ pageView.put("showFlag",salePlanInfo.getShowFlag());
|
|
|
|
+ pageView.put("sendPrivate",salePlanInfo.getSendPrivate());
|
|
|
|
+ pageView.put("pageSize",salePlanInfo.getPageSize());
|
|
|
|
+ pageView.put("currentPage",salePlanInfo.getCurrentPage());
|
|
|
|
+ // 查询销售订单总数
|
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
|
+ List<SalePlanInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ Page<SalePlanInfo> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(salePlanInfo.getCurrentPage());
|
|
|
|
+ page.setSize(salePlanInfo.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加销售计划
|
|
|
|
+ * @param salePlanInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String insertSalePlanInfo(SalePlanInfo salePlanInfo) {
|
|
|
|
+ //新增主键id
|
|
|
|
+ salePlanInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ salePlanInfo.setStatus(StatusEnum.ORDER_REVIEWED.getName());
|
|
|
|
+ salePlanInfo.setStatusFlag(StatusEnum.ORDER_REVIEWED.getFlag());
|
|
|
|
+ salePlanInfo.setShowFlag(StatusEnum.PURCHASE_SHOW.getFlag());
|
|
|
|
+ // 操作主表数据
|
|
|
|
+ this.insert(salePlanInfo);
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ String staffName = this.billOperateHisService.getStaffAndName();
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ this.billOperateHisService.saveBillOperateHis(salePlanInfo.getId(), NumberConstant.CONSTANT_PURCHASE, staffName, null,
|
|
|
|
+ salePlanInfo.getStatus(), null, "");
|
|
|
|
+ return salePlanInfo.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更改状态
|
|
|
|
+ * @param salePlanInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String editStatus(SalePlanInfo salePlanInfo) {
|
|
|
|
+ //查询销售计划列表
|
|
|
|
+ SalePlanInfo salePlanInfo1=this.selectById(salePlanInfo.getId());
|
|
|
|
+ if (salePlanInfo1 != null ){
|
|
|
|
+ //更改状态
|
|
|
|
+ if(salePlanInfo.getFlag() == 0) {
|
|
|
|
+ if (StatusEnum.PURCHASE_HIDE.getFlag().equals(salePlanInfo1.getShowFlag())) {
|
|
|
|
+ salePlanInfo1.setShowFlag(StatusEnum.PURCHASE_SHOW.getFlag());
|
|
|
|
+ } else {
|
|
|
|
+ salePlanInfo1.setShowFlag(StatusEnum.PURCHASE_HIDE.getFlag());
|
|
|
|
+ }
|
|
|
|
+ //更改销售计划信息
|
|
|
|
+ this.updateById(salePlanInfo1);
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ String staffName = this.billOperateHisService.getStaffAndName();
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ this.billOperateHisService.saveBillOperateHis(salePlanInfo1.getId(), NumberConstant.CONSTANT_PURCHASE, staffName, null,
|
|
|
|
+ salePlanInfo1.getStatus(), null, "");
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+ //更改基差
|
|
|
|
+ else if(salePlanInfo.getFlag()==1){
|
|
|
|
+ salePlanInfo1.setBasisPrice(salePlanInfo.getBasisPrice());
|
|
|
|
+ //更改销售计划信息
|
|
|
|
+ this.updateById(salePlanInfo1);
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+ //更改单价
|
|
|
|
+ else {
|
|
|
|
+ salePlanInfo1.setUnitPrice(salePlanInfo.getUnitPrice());
|
|
|
|
+ //更改销售计划信息
|
|
|
|
+ this.updateById(salePlanInfo1);
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "NG";
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 审核
|
|
|
|
+ * @param salePlanInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String examine(SalePlanInfo salePlanInfo) {
|
|
|
|
+ //查询销售计划列表
|
|
|
|
+ SalePlanInfo salePlanInfo1=this.selectById(salePlanInfo.getId());
|
|
|
|
+ if (salePlanInfo1 != null ){
|
|
|
|
+ //通过
|
|
|
|
+ if(salePlanInfo.getFlag()==1){
|
|
|
|
+ salePlanInfo1.setStatusFlag(StatusEnum.ORDER_PASSED.getFlag());
|
|
|
|
+ salePlanInfo1.setStatus(StatusEnum.ORDER_PASSED.getName());
|
|
|
|
+ geTuiUtils.pushByCid("审核通知","您申请的交易已审核通过",salePlanInfo1.getCommonId());
|
|
|
|
+ }
|
|
|
|
+ //驳回
|
|
|
|
+ else{
|
|
|
|
+ salePlanInfo1.setStatusFlag(StatusEnum.ORDER_REJECTED.getFlag());
|
|
|
|
+ salePlanInfo1.setStatus(StatusEnum.ORDER_REJECTED.getName());
|
|
|
|
+ geTuiUtils.pushByCid("审核通知","您申请的交易已被驳回",salePlanInfo1.getCommonId());
|
|
|
|
+ }
|
|
|
|
+ //更改销售计划信息
|
|
|
|
+ this.updateById(salePlanInfo1);
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+ return "NG";
|
|
|
|
+ }
|
|
}
|
|
}
|