|
|
@@ -4,6 +4,8 @@ import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
|
|
|
import com.uas.platform.b2c.common.account.dao.UserBaseInfoDao;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.UserBaseInfo;
|
|
|
+import com.uas.platform.b2c.common.message.model.MessageModel;
|
|
|
+import com.uas.platform.b2c.common.psmessage.service.MessageService;
|
|
|
import com.uas.platform.b2c.core.constant.Status;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductAttachSubmitDao;
|
|
|
@@ -31,7 +33,18 @@ import com.uas.platform.core.persistence.criteria.CriterionExpression.Operator;
|
|
|
import com.uas.platform.core.persistence.criteria.LogicalExpression;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.platform.core.persistence.criteria.SimpleExpression;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
@@ -40,12 +53,6 @@ import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
/**
|
|
|
* Created by wangyc on 2018/6/26.
|
|
|
*
|
|
|
@@ -72,12 +79,19 @@ public class ProductAttachServiceImpl implements ProductAttachService {
|
|
|
|
|
|
private final UserBaseInfoDao userBaseInfoDao;
|
|
|
|
|
|
+ private final MessageService messageService;
|
|
|
+
|
|
|
+ private final String AUDIT_MESSAGE = "您提交的关于品牌“%s” 型号“%s” 的规格书,%s。原因:%s";
|
|
|
+
|
|
|
+ private final String AUDIT_FAILED = "审核不通过";
|
|
|
+
|
|
|
+ private final Logger LOGGER = Logger.getLogger(getClass());
|
|
|
+
|
|
|
@Autowired
|
|
|
private ProductService productService;
|
|
|
|
|
|
@Autowired
|
|
|
- public ProductAttachServiceImpl(ProductDao productDao, ProductAttachSubmitDao productAttachSubmitDao,
|
|
|
- ComponentDao componentDao, BrandInfoDao brandInfoDao, KindInfoDao kindInfoDao, ComponentService componentService, KindDao kindDao, EnterpriseDao enterpriseDao, UserBaseInfoDao userBaseInfoDao) {
|
|
|
+ public ProductAttachServiceImpl(ProductDao productDao, ProductAttachSubmitDao productAttachSubmitDao,ComponentDao componentDao, BrandInfoDao brandInfoDao, KindInfoDao kindInfoDao, ComponentService componentService, KindDao kindDao, EnterpriseDao enterpriseDao, UserBaseInfoDao userBaseInfoDao,MessageService messageService) {
|
|
|
this.productDao = productDao;
|
|
|
this.productAttachSubmitDao = productAttachSubmitDao;
|
|
|
this.componentDao = componentDao;
|
|
|
@@ -87,6 +101,7 @@ public class ProductAttachServiceImpl implements ProductAttachService {
|
|
|
this.kindDao = kindDao;
|
|
|
this.enterpriseDao = enterpriseDao;
|
|
|
this.userBaseInfoDao = userBaseInfoDao;
|
|
|
+ this.messageService = messageService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -392,11 +407,49 @@ public class ProductAttachServiceImpl implements ProductAttachService {
|
|
|
submit.setReason(reason);
|
|
|
submit = productAttachSubmitDao.save(submit);
|
|
|
|
|
|
+ // 发送消息给提交人
|
|
|
+ sendMessage(submit, false);
|
|
|
+
|
|
|
return ResultMap.success(submit);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发送审核消息
|
|
|
+ * @param submit 申请
|
|
|
+ * @param success 是否成功
|
|
|
+ */
|
|
|
+ private void sendMessage(ProductAttachSubmit submit, Boolean success) {
|
|
|
+ List<MessageModel> messageModels = new ArrayList<>();
|
|
|
+ // 审核失败
|
|
|
+ if (!success && submit.getProductId() != null) {
|
|
|
+ Product product = productDao.findOne(submit.getProductId());
|
|
|
+ String result = "";
|
|
|
+ if (product != null) {
|
|
|
+ submit.setProduct(product);
|
|
|
+ MessageModel model = new MessageModel();
|
|
|
+ model.setType("规格书申请");
|
|
|
+ model.setConsumerApp("MALL");
|
|
|
+ model.setContent(String.format(AUDIT_MESSAGE, submit.getProduct().getBrand() != null ? submit.getProduct().getBrand() : "-", submit.getProduct().getPcmpcode() != null ? submit.getProduct().getPcmpcode() : "-", AUDIT_FAILED, submit.getReason()));
|
|
|
+ model.setCreateTime(new Date());
|
|
|
+ model.setProducerApp("MALL");
|
|
|
+ model.setReceiverEnuu(submit.getSubmitEnuu());
|
|
|
+ model.setReceiverUu(submit.getSubmitUu());
|
|
|
+ model.setSenderEnuu(submit.getAuditEnuu());
|
|
|
+ model.setSenderUu(submit.getAuditUu());
|
|
|
+ model.setSmsType("DONT_SEND");
|
|
|
+ messageModels.add(model);
|
|
|
+
|
|
|
+ result = messageService.sendMessage(messageModels);
|
|
|
+ LOGGER.info("物料规格书审核:审核发送消息:" + result);
|
|
|
+ } else {
|
|
|
+ result = "物料不存在,物料id为" + submit.getProductId();
|
|
|
+ LOGGER.info("物料规格书审核:审核发送消息失败" + result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ResultMap chooseAttach(String attach, ProductAttachSubmit submit) {
|
|
|
ResultMap map = validateSubmit(submit);
|