Authored by caoyan

自助上架

package com.yoho.ufo.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.ufo.service.model.InboxReqVO;
import com.yohobuy.ufo.model.message.SmsMessageReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.ufo.service.model.InboxReqVO;
import com.yohobuy.ufo.model.message.SmsMessageReq;
/**
* Created by li.ma on 2019/3/19.
... ...
... ... @@ -3,8 +3,10 @@ package com.yoho.ufo.service.impl;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -18,7 +20,10 @@ import com.yoho.product.model.SelfShelvesReq;
import com.yoho.product.model.SelfShelvesRsp;
import com.yoho.ufo.exception.PlatformException;
import com.yoho.ufo.service.ISelfShelvesService;
import com.yoho.ufo.service.UserProxyService;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.message.SmsMessageReq;
/**
* @author caoyan
... ... @@ -35,6 +40,12 @@ public class SelfShelvesServiceImpl implements ISelfShelvesService {
@Autowired
private ProductSelfShelvesPicMapper productSelfShelvesPicMapper;
@Autowired
private InboxServiceImpl inboxService;
@Autowired
private UserProxyService userProxyService;
@Override
public PageResponseBO<SelfShelvesRsp> queryList(SelfShelvesReq req){
int total = selfShelvesMapper.selectTotalByCondition(req);
... ... @@ -96,8 +107,38 @@ public class SelfShelvesServiceImpl implements ISelfShelvesService {
if(null == pss) {
throw new PlatformException("记录不存在", 400);
}
return selfShelvesMapper.upadteAuditResult(req.getId(), req.getStatus());
int num = selfShelvesMapper.upadteAuditResult(req.getId(), req.getStatus());
if(num > 0 && req.getStatus().intValue() == 1) {//审核通过,通知发布者站内信和短信“您提交的「品牌」「商品名称」「货号」信息已审核通过,赶紧发布您的好货吧”
//发送站内信
inboxService.addInboxForPlatform(pss.getUid(), InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getType(),
InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getBusinessType(), buildParams(pss.getBrand(), pss.getProductName(), pss.getProductCode()));
//发送短信
SmsMessageReq smsReq = new SmsMessageReq();
//获取手机号
String mobile = userProxyService.getMobile(pss.getUid());
smsReq.setMobileList(Lists.newArrayList(mobile));
smsReq.setContent(getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getContent(), pss.getBrand(), pss.getProductName(), pss.getProductCode()));
inboxService.sendSmsMessage(smsReq);
}
return num;
}
private String getReplacedContent(String content ,Object... params) {
return MessageFormatter.arrayFormat(content, params).getMessage();
}
public static String buildParams(Object... objects) {
if (objects == null) {
return null;
}
if (objects.length == 1) {
return objects[0].toString();
}
String params = StringUtils.join(objects, ",");
return params;
}
private String getAuditStatusStr(int status) {
... ...