Authored by caoyan

自助尺码

1 package com.yoho.ufo.service; 1 package com.yoho.ufo.service;
2 2
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +import java.util.Objects;
  6 +import java.util.concurrent.TimeUnit;
  7 +import java.util.stream.Collectors;
  8 +
  9 +import org.apache.commons.lang3.StringUtils;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.beans.factory.annotation.Value;
  14 +import org.springframework.stereotype.Service;
  15 +
3 import com.alibaba.fastjson.JSONArray; 16 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject; 17 import com.alibaba.fastjson.JSONObject;
  18 +import com.google.common.collect.Lists;
5 import com.google.common.collect.Maps; 19 import com.google.common.collect.Maps;
6 import com.yoho.core.rest.client.ServiceCaller; 20 import com.yoho.core.rest.client.ServiceCaller;
7 import com.yoho.error.ServiceError; 21 import com.yoho.error.ServiceError;
8 import com.yoho.error.exception.ServiceException; 22 import com.yoho.error.exception.ServiceException;
9 import com.yoho.service.model.request.UserAddressReqBO; 23 import com.yoho.service.model.request.UserAddressReqBO;
  24 +import com.yoho.service.model.response.ProfileInfoRsp;
10 import com.yoho.ufo.convert.AddressInfoConvertor; 25 import com.yoho.ufo.convert.AddressInfoConvertor;
11 import com.yohobuy.ufo.model.common.ApiResponse; 26 import com.yohobuy.ufo.model.common.ApiResponse;
12 import com.yohobuy.ufo.model.order.vo.AddressInfo; 27 import com.yohobuy.ufo.model.order.vo.AddressInfo;
13 -import org.apache.commons.lang3.StringUtils;  
14 -import org.slf4j.Logger;  
15 -import org.slf4j.LoggerFactory;  
16 -import org.springframework.beans.factory.annotation.Autowired;  
17 -import org.springframework.beans.factory.annotation.Value;  
18 -import org.springframework.stereotype.Service;  
19 -  
20 -import java.util.Map;  
21 -import java.util.Objects;  
22 -import java.util.concurrent.TimeUnit;  
23 28
24 /** 29 /**
25 * Created by chenchao on 2018/9/18. 30 * Created by chenchao on 2018/9/18.
@@ -38,6 +43,9 @@ public class UserProxyService { @@ -38,6 +43,9 @@ public class UserProxyService {
38 43
39 @Value("${uic.url:http://uic.yohoops.org/uic}") 44 @Value("${uic.url:http://uic.yohoops.org/uic}")
40 private String uicUrl; 45 private String uicUrl;
  46 +
  47 + @Value("${ip.port.uic.server}")
  48 + private String uicServerIpAndPort;
41 49
42 /** 50 /**
43 * 获取用户信息 51 * 获取用户信息
@@ -110,6 +118,8 @@ public class UserProxyService { @@ -110,6 +118,8 @@ public class UserProxyService {
110 * @return 118 * @return
111 */ 119 */
112 public static final String PRFILE_API = "/profile/getProfile"; 120 public static final String PRFILE_API = "/profile/getProfile";
  121 +
  122 + public static final String GET_USER_PROFILES_BY_UIDS = "/profile/getUserProfilesByUids";
113 public String getMobile(int uid){ 123 public String getMobile(int uid){
114 String url = uicUrl + PRFILE_API; 124 String url = uicUrl + PRFILE_API;
115 Map<String,Object> params = Maps.newHashMap(); 125 Map<String,Object> params = Maps.newHashMap();
@@ -134,5 +144,29 @@ public class UserProxyService { @@ -134,5 +144,29 @@ public class UserProxyService {
134 } 144 }
135 return mobile; 145 return mobile;
136 } 146 }
  147 +
  148 + public List<String> queryMobilesByUids(List<Integer> uidList) {
  149 + String url = uicUrl + GET_USER_PROFILES_BY_UIDS;
  150 + String uids = getUidStrs(uidList);
  151 + List<ProfileInfoRsp> result = Lists.newArrayList();
  152 + try {
  153 + result = serviceCaller.post("uic.getUserProfilesByUids", url, uids, List.class, null).get(5);
  154 + } catch (Exception e) {
  155 + logger.error("call"+ url + " fail!!! uids is {}", uids);
  156 + }
  157 + logger.info("result is {}", result);
  158 +
  159 + return result.stream().map(ProfileInfoRsp::getMobile).collect(Collectors.toList());
  160 +
  161 + }
  162 +
  163 + private String getUidStrs(List<Integer> uidList) {
  164 + List<String> uidStrList = Lists.newArrayList();
  165 + for(Integer uid : uidList) {
  166 + uidStrList.add(String.valueOf(uid));
  167 + }
  168 +
  169 + return String.join(",", uidStrList);
  170 + }
137 171
138 } 172 }
@@ -36,6 +36,8 @@ import com.yoho.ufo.model.commoditybasicrole.size.Size; @@ -36,6 +36,8 @@ import com.yoho.ufo.model.commoditybasicrole.size.Size;
36 import com.yoho.ufo.service.ISelfSizeService; 36 import com.yoho.ufo.service.ISelfSizeService;
37 import com.yoho.ufo.service.UserProxyService; 37 import com.yoho.ufo.service.UserProxyService;
38 import com.yoho.ufo.service.model.PageResponseBO; 38 import com.yoho.ufo.service.model.PageResponseBO;
  39 +import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
  40 +import com.yohobuy.ufo.model.message.SmsMessageReq;
39 41
40 /** 42 /**
41 * @author caoyan 43 * @author caoyan
@@ -209,23 +211,30 @@ public class SelfSizeServiceImpl implements ISelfSizeService { @@ -209,23 +211,30 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
209 record.setSizeId(selfSize.getSizeId()); 211 record.setSizeId(selfSize.getSizeId());
210 record.setStorageNum(0); 212 record.setStorageNum(0);
211 record.setCreateTime(DateUtil.getCurrentTimeSecond()); 213 record.setCreateTime(DateUtil.getCurrentTimeSecond());
212 - int num = storageMapper.insert(record);  
213 - if(num == 0) {  
214 - return num;  
215 - } 214 +// int num = storageMapper.insert(record);
  215 +// if(num == 0) {
  216 +// return num;
  217 +// }
216 UserHelper userInfo = new UserHelper(); 218 UserHelper userInfo = new UserHelper();
217 - num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId()); 219 + int num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId());
218 if(num > 0 && req.getStatus().intValue() == 1) {//审核通过 220 if(num > 0 && req.getStatus().intValue() == 1) {//审核通过
  221 + Product product = productMapper.selectByPrimaryKey(selfSize.getProductId());
  222 + Size size = ufoSizeMapper.selectOneById(selfSize.getSizeId());
  223 +
219 //发送站内信 224 //发送站内信
220 // inboxService.addInboxForPlatform(pss.getUid(), InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getType(), 225 // inboxService.addInboxForPlatform(pss.getUid(), InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getType(),
221 // InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getBusinessType(), buildParams(pss.getBrand(), pss.getProductName(), pss.getProductCode())); 226 // InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getBusinessType(), buildParams(pss.getBrand(), pss.getProductName(), pss.getProductCode()));
222 -// //发送短信  
223 -// SmsMessageReq smsReq = new SmsMessageReq();  
224 -// //获取手机号  
225 -// String mobile = userProxyService.getMobile(pss.getUid());  
226 -// smsReq.setMobileList(Lists.newArrayList(mobile));  
227 -// smsReq.setContent(getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_SELF_SHELVES_AUDIT_PASS.getContent(), pss.getBrand(), pss.getProductName(), pss.getProductCode()));  
228 -// inboxService.sendSmsMessage(smsReq); 227 + //发送短信
  228 + SmsMessageReq smsReq = new SmsMessageReq();
  229 + //获取手机号
  230 + List<Integer> uidList = selfSizeUidMapper.selectUidByProductIdAndSizeId(selfSize.getProductId(), selfSize.getSizeId());
  231 + List<String> mobileList = userProxyService.queryMobilesByUids(uidList);
  232 + if(!CollectionUtils.isEmpty(mobileList)) {
  233 + smsReq.setMobileList(Lists.newArrayList(mobileList));
  234 + smsReq.setContent(getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_SELF_SIZE_AUDIT_PASS.getContent(),
  235 + product.getProductName(), size.getSizeName()));
  236 + inboxService.sendSmsMessage(smsReq);
  237 + }
229 } 238 }
230 return num; 239 return num;
231 } 240 }