|
|
@@ -1,10 +1,13 @@
|
|
|
package com.usoftchina.saas.sale.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.inquiry.api.InquiryApi;
|
|
|
import com.usoftchina.inquiry.po.IPage;
|
|
|
import com.usoftchina.inquiry.po.InquiryEnRemind;
|
|
|
+import com.usoftchina.inquiry.po.InquiryRemind;
|
|
|
import com.usoftchina.saas.account.api.AccountApi;
|
|
|
import com.usoftchina.saas.account.api.CompanyApi;
|
|
|
import com.usoftchina.saas.base.Result;
|
|
|
@@ -35,6 +38,7 @@ import com.usoftchina.saas.storage.po.ProdInOut;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import com.usoftchina.saas.utils.CollectionUtils;
|
|
|
import com.usoftchina.saas.utils.DateUtils;
|
|
|
+import com.usoftchina.saas.utils.JsonUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -664,50 +668,97 @@ public class SaleServiceImpl implements SaleService{
|
|
|
|
|
|
/**
|
|
|
* 获取企业商机
|
|
|
- * @param enremindReqDTO
|
|
|
+ * @param remindReqDTO
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<EnremindRspDTO> getEnremind(EnremindReqDTO enremindReqDTO) {
|
|
|
- /*Long userUU = accountApi.getAccountById(BaseContextHolder.getUserId()).getData().getUu();
|
|
|
+ public IPage<RemindRspDTO> getEnremind(RemindReqDTO remindReqDTO) {
|
|
|
+ Long userUU = accountApi.getAccountById(BaseContextHolder.getUserId()).getData().getUu();
|
|
|
if (userUU == null){
|
|
|
userUU = 0L;
|
|
|
}
|
|
|
Long enUU = companyApi.getCompanyById(BaseContextHolder.getCompanyId()).getData().getUu();
|
|
|
- */
|
|
|
- Long userUU = 1000002503L, enUU = 10041559L;
|
|
|
- IPage<InquiryEnRemind> inquiryEnRemindIPage = inquiryApi.findEnRemind(userUU, enUU, enremindReqDTO.getPageNumber(),
|
|
|
- enremindReqDTO.getPageSize(), enremindReqDTO.getEnableOffer(), enremindReqDTO.getKeyword(), enremindReqDTO.getQuoted());
|
|
|
+ //Long userUU = 1000002503L, enUU = 10041559L;
|
|
|
+ IPage<InquiryEnRemind> inquiryEnRemindIPage = inquiryApi.findEnRemind(userUU, enUU, remindReqDTO.getPageNumber(),
|
|
|
+ remindReqDTO.getPageSize(), remindReqDTO.getEnableOffer(), remindReqDTO.getKeyword(), remindReqDTO.getQuoted(),
|
|
|
+ remindReqDTO.getFromDate(), remindReqDTO.getEndDate());
|
|
|
List<InquiryEnRemind> inquiryEnRemindList = inquiryEnRemindIPage.getContent();
|
|
|
if (CollectionUtils.isEmpty(inquiryEnRemindList)){
|
|
|
return null;
|
|
|
}
|
|
|
- List<EnremindRspDTO> enremindRspDTOList = convertToEnremindRspDTO(inquiryEnRemindList);
|
|
|
- return enremindRspDTOList;
|
|
|
+ List<RemindRspDTO> remindRspDTOList = convertToRemindRspDTO(JsonUtils.toJsonString(inquiryEnRemindList), "enterprise");
|
|
|
+ //转换成分页对象
|
|
|
+ IPage<RemindRspDTO> remindRspDTOIPage = new IPage<RemindRspDTO>(inquiryEnRemindIPage.getNumber(), inquiryEnRemindIPage.getSize(),
|
|
|
+ inquiryEnRemindIPage.getNumberOfElements(),remindRspDTOList, inquiryEnRemindIPage.isFirst(), inquiryEnRemindIPage.isLast(),
|
|
|
+ inquiryEnRemindIPage.getTotalElements());
|
|
|
+ return remindRspDTOIPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取个人商机
|
|
|
+ * @param remindReqDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<RemindRspDTO> findRemindByUserInfo(RemindReqDTO remindReqDTO) {
|
|
|
+ Long userUU = accountApi.getAccountById(BaseContextHolder.getUserId()).getData().getUu();
|
|
|
+ Long enUU = companyApi.getCompanyById(BaseContextHolder.getCompanyId()).getData().getUu();
|
|
|
+ IPage<InquiryRemind> inquiryRemindIpage = inquiryApi.findRemindByUserInfo(userUU, enUU, remindReqDTO.getPageNumber(), remindReqDTO.getPageSize(),
|
|
|
+ remindReqDTO.getEnableOffer(),remindReqDTO.getKeyword(), remindReqDTO.getQuoted(),
|
|
|
+ remindReqDTO.getFromDate(), remindReqDTO.getEndDate());
|
|
|
+ List<InquiryRemind> inquiryRemindList = inquiryRemindIpage.getContent();
|
|
|
+ if (CollectionUtils.isEmpty(inquiryRemindList)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<RemindRspDTO> remindRspDTOList = convertToRemindRspDTO(JsonUtils.toJsonString(inquiryRemindList), "personal");
|
|
|
+ //转换成分页对象
|
|
|
+ IPage<RemindRspDTO> remindRspDTOIPage = new IPage<RemindRspDTO>(inquiryRemindIpage.getNumber(), inquiryRemindIpage.getSize(),
|
|
|
+ inquiryRemindIpage.getNumberOfElements(),remindRspDTOList, inquiryRemindIpage.isFirst(), inquiryRemindIpage.isLast(),
|
|
|
+ inquiryRemindIpage.getTotalElements());
|
|
|
+ return remindRspDTOIPage;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将平台返回的结果集转成SAAS的传输对象
|
|
|
- * @param inquiryEnRemindList
|
|
|
+ * @param data
|
|
|
+ * @param type
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<EnremindRspDTO> convertToEnremindRspDTO(List<InquiryEnRemind> inquiryEnRemindList) {
|
|
|
- List<EnremindRspDTO> enremindRspDTOList = new ArrayList<EnremindRspDTO>();
|
|
|
- EnremindRspDTO enremindRspDTO = null;
|
|
|
- for (InquiryEnRemind inquiryEnRemind : inquiryEnRemindList){
|
|
|
- enremindRspDTO = new EnremindRspDTO();
|
|
|
- enremindRspDTO.setCustName(inquiryEnRemind.getEnName());
|
|
|
- enremindRspDTO.setProdBrand(inquiryEnRemind.getInbrand());
|
|
|
- enremindRspDTO.setProdName(inquiryEnRemind.getProdTitle());
|
|
|
- enremindRspDTO.setProdOrispeccode(inquiryEnRemind.getCmpCode());
|
|
|
- enremindRspDTO.setProdSpec(inquiryEnRemind.getSpec());
|
|
|
- //enremindRspDTO.setProdUnit(inquiryEnRemind.get);
|
|
|
- enremindRspDTO.setNeedQty(inquiryEnRemind.getNeedQty());
|
|
|
- enremindRspDTO.setStartDate(inquiryEnRemind.getReDate());
|
|
|
- enremindRspDTO.setEndDate(inquiryEnRemind.getEndDate());
|
|
|
- enremindRspDTOList.add(enremindRspDTO);
|
|
|
- }
|
|
|
- return enremindRspDTOList;
|
|
|
+ private List<RemindRspDTO> convertToRemindRspDTO(String data, String type) {
|
|
|
+ List<RemindRspDTO> remindRspDTOList = new ArrayList<RemindRspDTO>();
|
|
|
+ RemindRspDTO remindRspDTO = null;
|
|
|
+ if ("enterprise".equals(type)){
|
|
|
+ List<InquiryEnRemind> inquiryEnRemindList = JsonUtils.fromJsonArray(data, InquiryEnRemind.class);
|
|
|
+ for (InquiryEnRemind inquiryEnRemind : inquiryEnRemindList){
|
|
|
+ remindRspDTO = new RemindRspDTO();
|
|
|
+ remindRspDTO.setCustName(inquiryEnRemind.getEnName());
|
|
|
+ remindRspDTO.setProdBrand(inquiryEnRemind.getInbrand());
|
|
|
+ remindRspDTO.setProdName(inquiryEnRemind.getProdTitle());
|
|
|
+ remindRspDTO.setProdOrispeccode(inquiryEnRemind.getCmpCode());
|
|
|
+ remindRspDTO.setProdSpec(inquiryEnRemind.getSpec());
|
|
|
+ remindRspDTO.setProdUnit("pcs");
|
|
|
+ remindRspDTO.setNeedQty(inquiryEnRemind.getNeedQty());
|
|
|
+ remindRspDTO.setStartDate(inquiryEnRemind.getReDate());
|
|
|
+ remindRspDTO.setEndDate(inquiryEnRemind.getEndDate());
|
|
|
+ remindRspDTOList.add(remindRspDTO);
|
|
|
+ }
|
|
|
+ }else if("personal".equals(type)){
|
|
|
+ List<InquiryRemind> inquiryRemindList = JsonUtils.fromJsonArray(data, InquiryRemind.class);
|
|
|
+ for (InquiryRemind inquiryRemind : inquiryRemindList){
|
|
|
+ remindRspDTO = new RemindRspDTO();
|
|
|
+ remindRspDTO.setCustName(inquiryRemind.getEnName());
|
|
|
+ remindRspDTO.setProdBrand(inquiryRemind.getInbrand());
|
|
|
+ remindRspDTO.setProdName(inquiryRemind.getProdTitle());
|
|
|
+ remindRspDTO.setProdOrispeccode(inquiryRemind.getCmpCode());
|
|
|
+ remindRspDTO.setProdSpec(inquiryRemind.getSpec());
|
|
|
+ remindRspDTO.setProdUnit("pcs");
|
|
|
+ remindRspDTO.setNeedQty(inquiryRemind.getNeedQty());
|
|
|
+ remindRspDTO.setStartDate(inquiryRemind.getReDate());
|
|
|
+ remindRspDTO.setEndDate(inquiryRemind.getEndDate());
|
|
|
+ remindRspDTOList.add(remindRspDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return remindRspDTOList;
|
|
|
}
|
|
|
|
|
|
//更新最新销售总额
|