Showing
8 changed files
with
266 additions
and
18 deletions
@@ -32,5 +32,21 @@ | @@ -32,5 +32,21 @@ | ||
32 | <groupId>org.apache.commons</groupId> | 32 | <groupId>org.apache.commons</groupId> |
33 | <artifactId>commons-lang3</artifactId> | 33 | <artifactId>commons-lang3</artifactId> |
34 | </dependency> | 34 | </dependency> |
35 | + | ||
36 | + <dependency> | ||
37 | + <groupId>com.yohoufo.fore</groupId> | ||
38 | + <artifactId>yohoufo-fore-common</artifactId> | ||
39 | + </dependency> | ||
40 | + | ||
41 | + <dependency> | ||
42 | + <groupId>com.yoho.core</groupId> | ||
43 | + <artifactId>yoho-core-rest-client-simple</artifactId> | ||
44 | + </dependency> | ||
45 | + | ||
46 | + <dependency> | ||
47 | + <groupId>com.yoho.service.model</groupId> | ||
48 | + <artifactId>message-service-model</artifactId> | ||
49 | + </dependency> | ||
50 | + | ||
35 | </dependencies> | 51 | </dependencies> |
36 | </project> | 52 | </project> |
1 | +package com.yohoufo.inboxclient.sdk; | ||
2 | + | ||
3 | +import com.yoho.core.rest.client.ServiceCaller; | ||
4 | +import com.yoho.service.model.msgcenter.sms.McSmsByMobileBO; | ||
5 | +import com.yoho.service.model.sms.response.CommonRspBO; | ||
6 | +import org.apache.commons.collections.CollectionUtils; | ||
7 | +import org.apache.commons.lang3.StringUtils; | ||
8 | +import org.slf4j.Logger; | ||
9 | +import org.slf4j.LoggerFactory; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | +import org.springframework.beans.factory.annotation.Value; | ||
12 | +import org.springframework.stereotype.Service; | ||
13 | + | ||
14 | +import java.util.List; | ||
15 | + | ||
16 | +/** | ||
17 | + * Created by chenchao on 2018/10/19. | ||
18 | + */ | ||
19 | +@Service | ||
20 | +public class InBoxSendSmsService { | ||
21 | + | ||
22 | + | ||
23 | + private static Logger log = LoggerFactory.getLogger(InBoxSendSmsService.class); | ||
24 | + | ||
25 | + @Autowired | ||
26 | + private ServiceCaller serviceCaller; | ||
27 | + | ||
28 | + @Value("${yoho.message.controller.url}") | ||
29 | + private String messageUrl; | ||
30 | + | ||
31 | + public void smsSendByMobile(String content, List<String> mobileList) { | ||
32 | + log.info("InBoxSendSmsService smsSendByMobile start, content {}, mobileList {}", content, mobileList); | ||
33 | + if(StringUtils.isEmpty(content) || CollectionUtils.isEmpty(mobileList)) { | ||
34 | + log.warn("InBoxSendSmsService smsSendByMobile fail! content is null or mobileList is empty"); | ||
35 | + return; | ||
36 | + } | ||
37 | + McSmsByMobileBO[] boArray = new McSmsByMobileBO[mobileList.size()]; | ||
38 | + for(int i=0; i<mobileList.size(); i++) { | ||
39 | + McSmsByMobileBO smsBo = new McSmsByMobileBO(); | ||
40 | + smsBo.setMobile(mobileList.get(i)); | ||
41 | + smsBo.setContent(content); | ||
42 | + //"smsProviderCode" : "3" | ||
43 | + smsBo.setSmsProviderCode("3"); | ||
44 | + smsBo.setIsNoDisturb(0);//是否免打扰, 1-是 0-否 | ||
45 | + boArray[i] = smsBo; | ||
46 | + } | ||
47 | + | ||
48 | + String url = messageUrl + "/mcSMS/smsSendByMobile"; | ||
49 | + log.info("InBoxSendSmsService sendMessage url is {}", url); | ||
50 | + serviceCaller.post("message.sendMessage", url, boArray, CommonRspBO.class, null); | ||
51 | + } | ||
52 | + | ||
53 | +} |
1 | +package com.yohoufo.inboxclient.sdk; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.google.common.collect.Maps; | ||
5 | +import com.yoho.core.rest.client.ServiceCaller; | ||
6 | +import com.yoho.error.ServiceError; | ||
7 | +import com.yoho.error.exception.ServiceException; | ||
8 | +import com.yohoufo.common.ApiResponse; | ||
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 | + | ||
16 | +import java.util.Map; | ||
17 | +import java.util.concurrent.TimeUnit; | ||
18 | + | ||
19 | +/** | ||
20 | + * Created by chenchao on 2018/9/18. | ||
21 | + */ | ||
22 | +@Service | ||
23 | +public class InboxUserProxyService { | ||
24 | + | ||
25 | + | ||
26 | + private Logger logger = LoggerFactory.getLogger(getClass()); | ||
27 | + | ||
28 | + @Autowired | ||
29 | + ServiceCaller serviceCaller; | ||
30 | + | ||
31 | + @Value("${erp-gateway.url}") | ||
32 | + private String erpGatewayUrl; | ||
33 | + | ||
34 | + @Value("${uic.url:http://uic.yohoops.org/uic}") | ||
35 | + private String uicUrl; | ||
36 | + | ||
37 | + | ||
38 | + /** | ||
39 | + * http://java-yoho-uic.test3.ingress.dev.yohocorp.com/uic | ||
40 | + * //profile/getProfile?uid=600032978 | ||
41 | + * @param uid | ||
42 | + * @return | ||
43 | + */ | ||
44 | + public static final String PRFILE_API = "/profile/getProfile"; | ||
45 | + public String getMobile(int uid){ | ||
46 | + String url = uicUrl + PRFILE_API; | ||
47 | + Map<String,Object> params = Maps.newHashMap(); | ||
48 | + params.put("uid", uid); | ||
49 | + | ||
50 | + logger.info("InboxUserProxyService in getMobile enter, uid {}", uid); | ||
51 | + | ||
52 | + ApiResponse userInfo ; | ||
53 | + try { | ||
54 | + userInfo = serviceCaller.get("users.getAddress", url, params, | ||
55 | + ApiResponse.class, null).get(500, TimeUnit.MILLISECONDS); | ||
56 | + | ||
57 | + }catch (Exception ex){ | ||
58 | + logger.warn("InboxUserProxyService in getMobile fail, uid {}", uid, ex); | ||
59 | + throw new ServiceException(ServiceError.USER_IS_NOT_EXIST); | ||
60 | + } | ||
61 | + | ||
62 | + JSONObject jsonObject; | ||
63 | + String mobile; | ||
64 | + if (userInfo == null || (jsonObject = (JSONObject)userInfo.getData()) == null | ||
65 | + || StringUtils.isBlank(mobile = jsonObject.getString("mobile_phone"))){ | ||
66 | + logger.warn("InboxUserProxyService in getMobile fail, uid {}, userInfo {}", uid, userInfo); | ||
67 | + throw new ServiceException(ServiceError.PROFILE_IS_NULL); | ||
68 | + } | ||
69 | + return mobile; | ||
70 | + } | ||
71 | + | ||
72 | +} |
@@ -7,6 +7,7 @@ import com.yohoufo.inboxclient.sdk.InBoxSDK; | @@ -7,6 +7,7 @@ import com.yohoufo.inboxclient.sdk.InBoxSDK; | ||
7 | import org.apache.commons.lang3.StringUtils; | 7 | import org.apache.commons.lang3.StringUtils; |
8 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
10 | +import org.slf4j.helpers.MessageFormatter; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
12 | 13 | ||
@@ -104,8 +105,9 @@ public class InBoxFacade { | @@ -104,8 +105,9 @@ public class InBoxFacade { | ||
104 | //短信 | 105 | //短信 |
105 | //InboxBusinessTypeEnum smsIbt = InboxBusinessTypeEnum.SMS_SEND; | 106 | //InboxBusinessTypeEnum smsIbt = InboxBusinessTypeEnum.SMS_SEND; |
106 | //String smsparams = buildParams(orderCode); | 107 | //String smsparams = buildParams(orderCode); |
107 | - SmsContentEnum smsIbt=SmsContentEnum.SMS_SEND; | ||
108 | - String content=smsIbt.getReplacedContent(prdName); | 108 | + //SmsContentEnum smsIbt=SmsContentEnum.SMS_SEND; |
109 | + //String content=smsIbt.getReplacedContent(prdName); | ||
110 | + String content=getReplacedContent(InboxBusinessTypeEnum.SMS_SEND.getContent(),prdName); | ||
109 | 111 | ||
110 | String phone = userProxyService.getMobile(buyerUid); | 112 | String phone = userProxyService.getMobile(buyerUid); |
111 | if (StringUtils.isBlank(phone)){ | 113 | if (StringUtils.isBlank(phone)){ |
@@ -124,6 +126,10 @@ public class InBoxFacade { | @@ -124,6 +126,10 @@ public class InBoxFacade { | ||
124 | 126 | ||
125 | } | 127 | } |
126 | 128 | ||
129 | + private String getReplacedContent(String content ,Object... params) { | ||
130 | + return MessageFormatter.arrayFormat(content, params).getMessage(); | ||
131 | + } | ||
132 | + | ||
127 | /** | 133 | /** |
128 | * 订单生成,卖家取消售卖 | 134 | * 订单生成,卖家取消售卖 |
129 | * | 135 | * |
@@ -147,8 +153,11 @@ public class InBoxFacade { | @@ -147,8 +153,11 @@ public class InBoxFacade { | ||
147 | return; | 153 | return; |
148 | } | 154 | } |
149 | List<String> mobileList = Arrays.asList(phone); | 155 | List<String> mobileList = Arrays.asList(phone); |
150 | - SmsContentEnum smsIbt=SmsContentEnum.SMS_CLOSED_SELLER; | ||
151 | - String content=smsIbt.getReplacedContent(prdName); | 156 | + |
157 | + //SmsContentEnum smsIbt=SmsContentEnum.SMS_CLOSED_SELLER; | ||
158 | + //String content=smsIbt.getReplacedContent(prdName); | ||
159 | + String content=getReplacedContent(InboxBusinessTypeEnum.SMS_CLOSED_SELLER.getContent(),prdName); | ||
160 | + | ||
152 | sendSmsService.smsSendByMobile(content,mobileList); | 161 | sendSmsService.smsSendByMobile(content,mobileList); |
153 | logger.info("record noticeBuyerWhenSellerCancelAfterPaid inbox sms msg, buyerUid {}, orderCode {},prdName {}", | 162 | logger.info("record noticeBuyerWhenSellerCancelAfterPaid inbox sms msg, buyerUid {}, orderCode {},prdName {}", |
154 | buyerUid, orderCode,prdName); | 163 | buyerUid, orderCode,prdName); |
@@ -203,8 +212,10 @@ public class InBoxFacade { | @@ -203,8 +212,10 @@ public class InBoxFacade { | ||
203 | return; | 212 | return; |
204 | } | 213 | } |
205 | List<String> mobileList = Arrays.asList(phone); | 214 | List<String> mobileList = Arrays.asList(phone); |
206 | - SmsContentEnum smsIbt=SmsContentEnum.SMS_CLOSED_PLATFORM; | ||
207 | - String content=smsIbt.getReplacedContent(prdName); | 215 | + //SmsContentEnum smsIbt=SmsContentEnum.SMS_CLOSED_PLATFORM; |
216 | + //String content=smsIbt.getReplacedContent(prdName); | ||
217 | + | ||
218 | + String content=getReplacedContent(InboxBusinessTypeEnum.SMS_CLOSED_PLATFORM.getContent(),prdName); | ||
208 | sendSmsService.smsSendByMobile(content,mobileList); | 219 | sendSmsService.smsSendByMobile(content,mobileList); |
209 | logger.info("record buyerGetEarnestMoneyWhenAppraiseFail inbox sms msg, buyerUid {}, orderCode {},prdName {}", | 220 | logger.info("record buyerGetEarnestMoneyWhenAppraiseFail inbox sms msg, buyerUid {}, orderCode {},prdName {}", |
210 | buyerUid, orderCode,prdName); | 221 | buyerUid, orderCode,prdName); |
@@ -339,8 +350,9 @@ public class InBoxFacade { | @@ -339,8 +350,9 @@ public class InBoxFacade { | ||
339 | return; | 350 | return; |
340 | } | 351 | } |
341 | List<String> mobileList = Arrays.asList(phone); | 352 | List<String> mobileList = Arrays.asList(phone); |
342 | - SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_SEND; | ||
343 | - String content = smsIbt.getReplacedContent(prdName); | 353 | + //SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_SEND; |
354 | + //String content = smsIbt.getReplacedContent(prdName); | ||
355 | + String content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFIED_SEND.getContent(),prdName); | ||
344 | sendSmsService.smsSendByMobile(content, mobileList); | 356 | sendSmsService.smsSendByMobile(content, mobileList); |
345 | logger.info("record sellerSkupPaidByBuyer inbox sms msg,sellerUid {}, prdName {}", | 357 | logger.info("record sellerSkupPaidByBuyer inbox sms msg,sellerUid {}, prdName {}", |
346 | sellerUid, prdName); | 358 | sellerUid, prdName); |
@@ -465,8 +477,9 @@ public class InBoxFacade { | @@ -465,8 +477,9 @@ public class InBoxFacade { | ||
465 | return; | 477 | return; |
466 | } | 478 | } |
467 | List<String> mobileList = Arrays.asList(phone); | 479 | List<String> mobileList = Arrays.asList(phone); |
468 | - SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_UNSHELF; | ||
469 | - String content = smsIbt.getReplacedContent(prdName); | 480 | + //SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_UNSHELF; |
481 | + //String content = smsIbt.getReplacedContent(prdName); | ||
482 | + String content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFIED_UNSHELF.getContent(),prdName); | ||
470 | sendSmsService.smsSendByMobile(content, mobileList); | 483 | sendSmsService.smsSendByMobile(content, mobileList); |
471 | logger.info("record notifyUnshelfCauseBySpecialReason inbox sms msg,sellerUid {}, prdName {}, resp {}", | 484 | logger.info("record notifyUnshelfCauseBySpecialReason inbox sms msg,sellerUid {}, prdName {}, resp {}", |
472 | sellerUid, prdName); | 485 | sellerUid, prdName); |
@@ -498,8 +511,10 @@ public class InBoxFacade { | @@ -498,8 +511,10 @@ public class InBoxFacade { | ||
498 | List<String> mobileList = Arrays.asList(phone); | 511 | List<String> mobileList = Arrays.asList(phone); |
499 | if (times == 2) { | 512 | if (times == 2) { |
500 | 513 | ||
501 | - SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_SEND_SECOND; | ||
502 | - String content = smsIbt.getReplacedContent(prdName); | 514 | + //SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_SEND_SECOND; |
515 | + //String content = smsIbt.getReplacedContent(prdName); | ||
516 | + String content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_SECOND.getContent(),prdName); | ||
517 | + | ||
503 | sendSmsService.smsSendByMobile(content, mobileList); | 518 | sendSmsService.smsSendByMobile(content, mobileList); |
504 | logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {},resp {}", | 519 | logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {},resp {}", |
505 | sellerUid, prdName, times); | 520 | sellerUid, prdName, times); |
@@ -508,8 +523,9 @@ public class InBoxFacade { | @@ -508,8 +523,9 @@ public class InBoxFacade { | ||
508 | if (times == 3) { | 523 | if (times == 3) { |
509 | 524 | ||
510 | 525 | ||
511 | - SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_SEND_FAILED; | ||
512 | - String content = smsIbt.getReplacedContent(prdName); | 526 | + //SmsContentEnum smsIbt = SmsContentEnum.SMS_NOTIFIED_SEND_FAILED; |
527 | + //String content = smsIbt.getReplacedContent(prdName); | ||
528 | + String content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_FAILED.getContent(),prdName); | ||
513 | sendSmsService.smsSendByMobile(content, mobileList); | 529 | sendSmsService.smsSendByMobile(content, mobileList); |
514 | logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {},resp {}", | 530 | logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {},resp {}", |
515 | sellerUid, prdName, times); | 531 | sellerUid, prdName, times); |
@@ -2,8 +2,12 @@ package com.yohoufo.order.service.proxy; | @@ -2,8 +2,12 @@ package com.yohoufo.order.service.proxy; | ||
2 | 2 | ||
3 | import org.slf4j.helpers.MessageFormatter; | 3 | import org.slf4j.helpers.MessageFormatter; |
4 | 4 | ||
5 | +/** | ||
6 | + * 这个不再使用,短信相关的配置参考 InboxBusinessTypeEnum | ||
7 | + */ | ||
5 | public enum SmsContentEnum { | 8 | public enum SmsContentEnum { |
6 | // 买家 | 9 | // 买家 |
10 | + /** | ||
7 | SMS_SEND("您购买的商品{}已由平台发货。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-购买]。"), | 11 | SMS_SEND("您购买的商品{}已由平台发货。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-购买]。"), |
8 | SMS_CLOSED_SELLER("卖家取消{}出售,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-购买]。"), | 12 | SMS_CLOSED_SELLER("卖家取消{}出售,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-购买]。"), |
9 | SMS_CLOSED_PLATFORM("鉴定不通过:您购买的商品{}未通过平台鉴定,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-购买]。"), | 13 | SMS_CLOSED_PLATFORM("鉴定不通过:您购买的商品{}未通过平台鉴定,您已获得卖家赔偿,将于1-3个工作日内转至您绑定的银行卡。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-购买]。"), |
@@ -16,9 +20,10 @@ public enum SmsContentEnum { | @@ -16,9 +20,10 @@ public enum SmsContentEnum { | ||
16 | SMS_NOTIFIED_UNSHELF("因为特殊原因,您的商品{}暂停售卖,您支付的保证金将于1个工作日内退回您的支付账户。"), | 20 | SMS_NOTIFIED_UNSHELF("因为特殊原因,您的商品{}暂停售卖,您支付的保证金将于1个工作日内退回您的支付账户。"), |
17 | 21 | ||
18 | //给卖家发通知 ,当买家取消订单(付款后取消,卖家发货后取消,卖家商品已经被平台签收) | 22 | //给卖家发通知 ,当买家取消订单(付款后取消,卖家发货后取消,卖家商品已经被平台签收) |
19 | - SMS_CANCELED_BY_BUYER_AFTER_PAID("买家已取消订单,您的商品「商品名称」已下架,更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-出售]。"), | 23 | + SMS_CANCELED_BY_BUYER_AFTER_PAID("买家已取消订单,您的商品{}已下架,更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-出售]。"), |
20 | SMS_CANCELED_BY_BUYER_AFTER_DELIVERY("买家已取消订单,请自行召回货品,如有其他疑问,请联系Yoho!Buy有货APP人工客服。"), | 24 | SMS_CANCELED_BY_BUYER_AFTER_DELIVERY("买家已取消订单,请自行召回货品,如有其他疑问,请联系Yoho!Buy有货APP人工客服。"), |
21 | SMS_CANCELED_BY_BUYER_AFTER_RECEIVED("您的商品已顺丰到付退回,快递单号{},请注意查收。"), | 25 | SMS_CANCELED_BY_BUYER_AFTER_RECEIVED("您的商品已顺丰到付退回,快递单号{},请注意查收。"), |
26 | + **/ | ||
22 | ; | 27 | ; |
23 | 28 | ||
24 | private String content; | 29 | private String content; |
@@ -28,6 +28,11 @@ | @@ -28,6 +28,11 @@ | ||
28 | </dependency> | 28 | </dependency> |
29 | 29 | ||
30 | <dependency> | 30 | <dependency> |
31 | + <groupId>com.yohoufo.fore</groupId> | ||
32 | + <artifactId>yohoufo-fore-inboxclient</artifactId> | ||
33 | + </dependency> | ||
34 | + | ||
35 | + <dependency> | ||
31 | <groupId>javax.servlet</groupId> | 36 | <groupId>javax.servlet</groupId> |
32 | <artifactId>javax.servlet-api</artifactId> | 37 | <artifactId>javax.servlet-api</artifactId> |
33 | </dependency> | 38 | </dependency> |
@@ -5,10 +5,7 @@ import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse; | @@ -5,10 +5,7 @@ import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse; | ||
5 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | import com.yoho.tools.common.beans.ApiResponse; | 6 | import com.yoho.tools.common.beans.ApiResponse; |
7 | import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO; | 7 | import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO; |
8 | - | ||
9 | -import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO; | ||
10 | import com.yohoufo.common.utils.UserInfoHiddenHelper; | 8 | import com.yohoufo.common.utils.UserInfoHiddenHelper; |
11 | - | ||
12 | import com.yohoufo.dal.user.IUserAuthorizeInfoDao; | 9 | import com.yohoufo.dal.user.IUserAuthorizeInfoDao; |
13 | import com.yohoufo.dal.user.IZhiMaCertDao; | 10 | import com.yohoufo.dal.user.IZhiMaCertDao; |
14 | import com.yohoufo.dal.user.model.UserAuthorizeInfo; | 11 | import com.yohoufo.dal.user.model.UserAuthorizeInfo; |
1 | package com.yohoufo.user.service.impl; | 1 | package com.yohoufo.user.service.impl; |
2 | 2 | ||
3 | import com.yoho.error.exception.ServiceException; | 3 | import com.yoho.error.exception.ServiceException; |
4 | +import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum; | ||
4 | import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; | 5 | import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; |
5 | import com.yohoufo.common.caller.UfoServiceCaller; | 6 | import com.yohoufo.common.caller.UfoServiceCaller; |
6 | import com.yohoufo.dal.user.IStoredSellerDao; | 7 | import com.yohoufo.dal.user.IStoredSellerDao; |
7 | import com.yohoufo.dal.user.model.StoredSeller; | 8 | import com.yohoufo.dal.user.model.StoredSeller; |
8 | import com.yohoufo.dal.user.model.ZhiMaCert; | 9 | import com.yohoufo.dal.user.model.ZhiMaCert; |
10 | +import com.yohoufo.inboxclient.model.InBoxResponse; | ||
11 | +import com.yohoufo.inboxclient.model.InboxReqVO; | ||
12 | +import com.yohoufo.inboxclient.sdk.InBoxSDK; | ||
13 | +import com.yohoufo.inboxclient.sdk.InBoxSendSmsService; | ||
14 | +import com.yohoufo.inboxclient.sdk.InboxUserProxyService; | ||
9 | import com.yohoufo.user.cache.CacheService; | 15 | import com.yohoufo.user.cache.CacheService; |
10 | import com.yohoufo.user.service.IRealNameAuthorizeService; | 16 | import com.yohoufo.user.service.IRealNameAuthorizeService; |
11 | import com.yohoufo.user.service.IStoredSellerService; | 17 | import com.yohoufo.user.service.IStoredSellerService; |
18 | +import org.apache.commons.lang3.StringUtils; | ||
12 | import org.slf4j.Logger; | 19 | import org.slf4j.Logger; |
13 | import org.slf4j.LoggerFactory; | 20 | import org.slf4j.LoggerFactory; |
14 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -16,6 +23,8 @@ import org.springframework.stereotype.Service; | @@ -16,6 +23,8 @@ import org.springframework.stereotype.Service; | ||
16 | 23 | ||
17 | import java.time.LocalDateTime; | 24 | import java.time.LocalDateTime; |
18 | import java.time.ZoneOffset; | 25 | import java.time.ZoneOffset; |
26 | +import java.util.Arrays; | ||
27 | +import java.util.List; | ||
19 | 28 | ||
20 | @Service | 29 | @Service |
21 | public class StoredSellerServiceImpl implements IStoredSellerService { | 30 | public class StoredSellerServiceImpl implements IStoredSellerService { |
@@ -34,6 +43,15 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -34,6 +43,15 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
34 | @Autowired | 43 | @Autowired |
35 | private UfoServiceCaller ufoServiceCaller; | 44 | private UfoServiceCaller ufoServiceCaller; |
36 | 45 | ||
46 | + @Autowired | ||
47 | + private InBoxSDK inBoxSDK; | ||
48 | + | ||
49 | + @Autowired | ||
50 | + private InBoxSendSmsService inBoxSendSmsService; | ||
51 | + | ||
52 | + @Autowired | ||
53 | + private InboxUserProxyService inboxUserProxyService; | ||
54 | + | ||
37 | 55 | ||
38 | /*@Override | 56 | /*@Override |
39 | public void applyQuitStoredSeller(Integer uid){ | 57 | public void applyQuitStoredSeller(Integer uid){ |
@@ -125,7 +143,38 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -125,7 +143,38 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
125 | //保存到redis | 143 | //保存到redis |
126 | cacheService.setStoredSeller( storedSeller); | 144 | cacheService.setStoredSeller( storedSeller); |
127 | 145 | ||
146 | + //发送消息 | ||
147 | + sendMsg4enty(uid); | ||
148 | + | ||
149 | + } | ||
150 | + | ||
151 | + private void sendMsg4enty(Integer uid){ | ||
152 | + logger.info("sendMsg4enty inbox msg, uid {}",uid); | ||
153 | + //采用异步方式新增消息 | ||
154 | + Runnable runnable = new Runnable() { | ||
155 | + @Override | ||
156 | + public void run() { | ||
157 | + // 发送消息 | ||
158 | + InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.SYSTEM_ENTER_SETTLED; | ||
159 | + InboxReqVO inBoxReq = buildInboxReqVO(uid, null, ibt); | ||
160 | + | ||
161 | + InBoxResponse resp = inBoxSDK.addInbox(inBoxReq); | ||
162 | + logger.info("sendMsg4enty inbox msg, uid {}, resp {}", | ||
163 | + uid, resp); | ||
164 | + } | ||
165 | + }; | ||
166 | + Thread thread = new Thread(runnable); | ||
167 | + thread.start(); | ||
168 | + } | ||
128 | 169 | ||
170 | + private InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) { | ||
171 | + InboxReqVO req = new InboxReqVO(); | ||
172 | + req.setType(ibt.getType()); | ||
173 | + req.setBusinessType(ibt.getBusinessType()); | ||
174 | + // | ||
175 | + req.setUid(uid); | ||
176 | + req.setParams(params); | ||
177 | + return req; | ||
129 | } | 178 | } |
130 | 179 | ||
131 | @Override | 180 | @Override |
@@ -157,6 +206,41 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -157,6 +206,41 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
157 | cacheService.removeStoredSeller(uid); | 206 | cacheService.removeStoredSeller(uid); |
158 | 207 | ||
159 | logger.info("StoredSellerServiceImpl updateStoredSellerQuitStatus end ,uid is {} ,update num {}",uid,num); | 208 | logger.info("StoredSellerServiceImpl updateStoredSellerQuitStatus end ,uid is {} ,update num {}",uid,num); |
209 | + | ||
210 | + | ||
160 | return num; | 211 | return num; |
161 | } | 212 | } |
213 | + | ||
214 | + private void sendMsg4quit(Integer uid){ | ||
215 | + logger.info("sendMsg4quit inbox msg, uid {}",uid); | ||
216 | + //采用异步方式新增消息 | ||
217 | + Runnable runnable = new Runnable() { | ||
218 | + @Override | ||
219 | + public void run() { | ||
220 | + // 发送消息 | ||
221 | + InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.SYSTEM_EXIT_SETTLED; | ||
222 | + InboxReqVO inBoxReq = buildInboxReqVO(uid, null, ibt); | ||
223 | + | ||
224 | + InBoxResponse resp = inBoxSDK.addInbox(inBoxReq); | ||
225 | + logger.info("sendMsg4quit inbox msg, uid {}, resp {}", | ||
226 | + uid, resp); | ||
227 | + | ||
228 | + // 发送短信 | ||
229 | + String content=InboxBusinessTypeEnum.SMS_EXIT_SETTLED.getContent(); | ||
230 | + String phone=inboxUserProxyService.getMobile(uid); | ||
231 | + logger.info("sendMsg4quit inbox sms, uid {}, phone {}", | ||
232 | + uid, phone); | ||
233 | + if (StringUtils.isBlank(phone)){ | ||
234 | + logger.warn("endMsg4quit inbox sms fail cause of phone is empty, uid {} ", uid); | ||
235 | + return; | ||
236 | + } | ||
237 | + List<String> mobileList = Arrays.asList(phone); | ||
238 | + inBoxSendSmsService.smsSendByMobile(content,mobileList); | ||
239 | + logger.info("sendMsg4quit inbox sms send end, uid {}, phone {}", | ||
240 | + uid, phone); | ||
241 | + } | ||
242 | + }; | ||
243 | + Thread thread = new Thread(runnable); | ||
244 | + thread.start(); | ||
245 | + } | ||
162 | } | 246 | } |
-
Please register or login to post a comment