Authored by caoyan

自助尺码

package com.yoho.ufo.service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.request.UserAddressReqBO;
import com.yoho.service.model.response.ProfileInfoRsp;
import com.yoho.ufo.convert.AddressInfoConvertor;
import com.yohobuy.ufo.model.common.ApiResponse;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* Created by chenchao on 2018/9/18.
... ... @@ -38,6 +43,9 @@ public class UserProxyService {
@Value("${uic.url:http://uic.yohoops.org/uic}")
private String uicUrl;
@Value("${ip.port.uic.server}")
private String uicServerIpAndPort;
/**
* 获取用户信息
... ... @@ -110,6 +118,8 @@ public class UserProxyService {
* @return
*/
public static final String PRFILE_API = "/profile/getProfile";
public static final String GET_USER_PROFILES_BY_UIDS = "/profile/getUserProfilesByUids";
public String getMobile(int uid){
String url = uicUrl + PRFILE_API;
Map<String,Object> params = Maps.newHashMap();
... ... @@ -134,5 +144,29 @@ public class UserProxyService {
}
return mobile;
}
public List<String> queryMobilesByUids(List<Integer> uidList) {
String url = uicUrl + GET_USER_PROFILES_BY_UIDS;
String uids = getUidStrs(uidList);
List<ProfileInfoRsp> result = Lists.newArrayList();
try {
result = serviceCaller.post("uic.getUserProfilesByUids", url, uids, List.class, null).get(5);
} catch (Exception e) {
logger.error("call"+ url + " fail!!! uids is {}", uids);
}
logger.info("result is {}", result);
return result.stream().map(ProfileInfoRsp::getMobile).collect(Collectors.toList());
}
private String getUidStrs(List<Integer> uidList) {
List<String> uidStrList = Lists.newArrayList();
for(Integer uid : uidList) {
uidStrList.add(String.valueOf(uid));
}
return String.join(",", uidStrList);
}
}
... ...
... ... @@ -36,6 +36,8 @@ import com.yoho.ufo.model.commoditybasicrole.size.Size;
import com.yoho.ufo.service.ISelfSizeService;
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
... ... @@ -209,23 +211,30 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
record.setSizeId(selfSize.getSizeId());
record.setStorageNum(0);
record.setCreateTime(DateUtil.getCurrentTimeSecond());
int num = storageMapper.insert(record);
if(num == 0) {
return num;
}
// int num = storageMapper.insert(record);
// if(num == 0) {
// return num;
// }
UserHelper userInfo = new UserHelper();
num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId());
int num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId());
if(num > 0 && req.getStatus().intValue() == 1) {//审核通过
Product product = productMapper.selectByPrimaryKey(selfSize.getProductId());
Size size = ufoSizeMapper.selectOneById(selfSize.getSizeId());
//发送站内信
// 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);
//发送短信
SmsMessageReq smsReq = new SmsMessageReq();
//获取手机号
List<Integer> uidList = selfSizeUidMapper.selectUidByProductIdAndSizeId(selfSize.getProductId(), selfSize.getSizeId());
List<String> mobileList = userProxyService.queryMobilesByUids(uidList);
if(!CollectionUtils.isEmpty(mobileList)) {
smsReq.setMobileList(Lists.newArrayList(mobileList));
smsReq.setContent(getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_SELF_SIZE_AUDIT_PASS.getContent(),
product.getProductName(), size.getSizeName()));
inboxService.sendSmsMessage(smsReq);
}
}
return num;
}
... ...