Authored by chenchao

add notice

@@ -93,9 +93,6 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -93,9 +93,6 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
93 private TradeBillsService tradeBillsService; 93 private TradeBillsService tradeBillsService;
94 94
95 @Autowired 95 @Autowired
96 - private DepositService depositService;  
97 -  
98 - @Autowired  
99 private AppraiseService appraiseService; 96 private AppraiseService appraiseService;
100 97
101 private boolean isDepositWithQuickDeliverGoods(int uid, long orderCode, Integer oa){ 98 private boolean isDepositWithQuickDeliverGoods(int uid, long orderCode, Integer oa){
@@ -157,17 +154,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -157,17 +154,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
157 } 154 }
158 155
159 private void processDepositOrderOfQuickDeliverGoods(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){ 156 private void processDepositOrderOfQuickDeliverGoods(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
160 - Integer sellerUid = null;  
161 - Integer buyerUid = null;  
162 - Long orderCode = null;  
163 - Integer skup = null;  
164 - try {  
165 - depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),  
166 - orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid(), true);  
167 - }catch (Exception ex){  
168 - logger.warn("pay successful, processDepositOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",  
169 - sellerUid, buyerUid, orderCode, skup);  
170 - } 157 + Integer buyerUid = buyerOrder.getUid();
  158 + Long orderCode = buyerOrder.getOrderCode();
  159 + inBoxFacade.noticeWhenDepositOrderOfQuickDeliverGoodsPaid(buyerUid, orderCode, sellerOrderGoods);
171 } 160 }
172 161
173 private void processDepositOrderOfInstockGoods(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){ 162 private void processDepositOrderOfInstockGoods(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
@@ -238,22 +227,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -238,22 +227,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
238 } 227 }
239 228
240 private void processQuickDeliverOrder(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){ 229 private void processQuickDeliverOrder(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
241 - //寄存订单 & 闪购商品  
242 - if (SkupType.QUICK_DELIVER.getCode() == sellerOrderGoods.getAttributes()){  
243 - Integer sellerUid = null;  
244 - Integer buyerUid = null;  
245 - Long orderCode = null;  
246 - Integer skup = null;  
247 - try {  
248 - depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),  
249 - orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid(), false);  
250 - }catch (Exception ex){  
251 - logger.warn("pay successful, processQuickDeliverOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",  
252 - sellerUid, buyerUid, orderCode, skup);  
253 - }  
254 230
255 - }  
256 - //todo notice 231 + // notice
  232 + inBoxFacade.noticeWhenQuickDeliverOrderPaid(buyerOrder.getUid(), buyerOrder.getOrderCode(), sellerOrderGoods);
257 } 233 }
258 234
259 @Override 235 @Override
@@ -603,7 +603,7 @@ public class AppraiseService { @@ -603,7 +603,7 @@ public class AppraiseService {
603 orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS); 603 orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS);
604 //TODO 发消息 瑕疵接收,只给卖家发消息 604 //TODO 发消息 瑕疵接收,只给卖家发消息
605 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null); 605 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
606 - inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product); 606 + inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods);
607 } else { 607 } else {
608 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改 608 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
609 } 609 }
@@ -1268,7 +1268,7 @@ public class AppraiseService { @@ -1268,7 +1268,7 @@ public class AppraiseService {
1268 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode()); 1268 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
1269 //TODO 鉴定通过, 1269 //TODO 鉴定通过,
1270 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null); 1270 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
1271 - inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product); 1271 + inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods);
1272 } catch (Exception ex) { 1272 } catch (Exception ex) {
1273 LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex); 1273 LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
1274 String content = "后台鉴定通过商品,订单" + orderCode + "退还保证金失败"; 1274 String content = "后台鉴定通过商品,订单" + orderCode + "退还保证金失败";
@@ -1413,8 +1413,8 @@ public class AppraiseService { @@ -1413,8 +1413,8 @@ public class AppraiseService {
1413 1413
1414 //平台已发货给买家 1414 //平台已发货给买家
1415 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null); 1415 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
1416 - inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods, product);  
1417 - inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product); 1416 + inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods);
  1417 + inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods);
1418 } catch (Exception ex) { 1418 } catch (Exception ex) {
1419 LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex); 1419 LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
1420 String content = "鉴定通过时,订单" + orderCode + "退还保证金失败"; 1420 String content = "鉴定通过时,订单" + orderCode + "退还保证金失败";
@@ -1571,12 +1571,20 @@ public class AppraiseService { @@ -1571,12 +1571,20 @@ public class AppraiseService {
1571 public void processQuickDeliverOrderAfterPaid(long orderCode,int uid, boolean isDeposit){ 1571 public void processQuickDeliverOrderAfterPaid(long orderCode,int uid, boolean isDeposit){
1572 BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode); 1572 BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
1573 BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode); 1573 BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
  1574 + Integer sellerUid = pbo.getSellerUid();
  1575 + Integer skup = pbog.getSkup();
1574 try { 1576 try {
1575 - transferGoodsMoneyWhenPass(pbo.getSellerUid(), pbog.getSkup(), orderCode); 1577 + transferGoodsMoneyWhenPass(sellerUid, skup, orderCode);
1576 }catch (Exception ex){ 1578 }catch (Exception ex){
1577 LOGGER.warn("in processQuickDeliverOrderAfterPaid transferGoodsMoneyWhenPass fail orderCode {} uid {}", 1579 LOGGER.warn("in processQuickDeliverOrderAfterPaid transferGoodsMoneyWhenPass fail orderCode {} uid {}",
1578 orderCode, uid, ex); 1580 orderCode, uid, ex);
1579 } 1581 }
1580 - depositService.changeOwner(pbo.getSellerUid(), pbog.getSkup(), orderCode,uid, isDeposit); 1582 + try {
  1583 + depositService.changeOwner(sellerUid, skup, orderCode,uid, isDeposit);
  1584 + }catch (Exception ex){
  1585 + LOGGER.warn("pay successful, processQuickDeliverOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
  1586 + sellerUid, uid, orderCode, skup);
  1587 + }
  1588 +
1581 } 1589 }
1582 } 1590 }
@@ -117,6 +117,8 @@ public class InBoxFacade { @@ -117,6 +117,8 @@ public class InBoxFacade {
117 } 117 }
118 } 118 }
119 119
  120 +
  121 +
120 /** 122 /**
121 * 卖家发货后 123 * 卖家发货后
122 * @param buyerUid 124 * @param buyerUid
@@ -218,17 +220,18 @@ public class InBoxFacade { @@ -218,17 +220,18 @@ public class InBoxFacade {
218 * 220 *
219 * @return 221 * @return
220 */ 222 */
221 - public void appraisePassNoticeBuyer(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) { 223 + public void appraisePassNoticeBuyer(int buyerUid, long orderCode, SellerOrderGoods psog) {
222 224
223 executorService.execute(()->{ 225 executorService.execute(()->{
224 226
225 try { 227 try {
226 - logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",  
227 - buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product)); 228 + logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} ",
  229 + buyerUid, orderCode, psog, JSON.toJSONString(psog));
  230 + Product product = productMapper.selectByPrimaryKey(psog.getProductId());
  231 + String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
228 String skupTypeText=SkupType.getSkupType(psog.getAttributes()).attrName(); 232 String skupTypeText=SkupType.getSkupType(psog.getAttributes()).attrName();
229 String prdName = psog.getProductName(); 233 String prdName = psog.getProductName();
230 String sizeName = psog.getSizeName(); 234 String sizeName = psog.getSizeName();
231 - String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");  
232 InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.PURCHASE_SENDED; 235 InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.PURCHASE_SENDED;
233 String params = buildParams(orderCode); 236 String params = buildParams(orderCode);
234 InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt); 237 InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
@@ -256,14 +259,15 @@ public class InBoxFacade { @@ -256,14 +259,15 @@ public class InBoxFacade {
256 259
257 } 260 }
258 261
259 - public void appraisePassNoticeSeller(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) { 262 + public void appraisePassNoticeSeller(int buyerUid, long orderCode, SellerOrderGoods psog) {
260 263
261 executorService.execute(()->{ 264 executorService.execute(()->{
262 265
263 try { 266 try {
264 logger.info("record appraisePassNoticeSeller inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}", 267 logger.info("record appraisePassNoticeSeller inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",
265 - buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product)); 268 + buyerUid, orderCode, psog, JSON.toJSONString(psog));
266 String prdName = psog.getProductName(); 269 String prdName = psog.getProductName();
  270 + Product product = productMapper.selectByPrimaryKey(psog.getProductId());
267 String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse(""); 271 String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
268 272
269 //seller notice 273 //seller notice
@@ -1755,38 +1759,117 @@ public class InBoxFacade { @@ -1755,38 +1759,117 @@ public class InBoxFacade {
1755 } 1759 }
1756 } 1760 }
1757 1761
  1762 + private void execute(Runnable task, String logModule, Object[] logParms){
  1763 + try{
  1764 + executorService.execute(task);
  1765 + }catch (Exception ex){
  1766 +
  1767 + logger.warn(logModule, logParms, ex);
  1768 + }
  1769 + }
  1770 +
1758 public void noticeWhenBuyerBlownCustomsClearance(int buyerUid, long orderCode, SellerOrderGoods sog){ 1771 public void noticeWhenBuyerBlownCustomsClearance(int buyerUid, long orderCode, SellerOrderGoods sog){
1759 String prdName = sog.getProductName(); 1772 String prdName = sog.getProductName();
1760 String sizeName = sog.getSizeName(); 1773 String sizeName = sog.getSizeName();
1761 - try {  
1762 - executorService.execute(()->{  
1763 - InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.BUYER_BLOWN_CUSTOMS_CLEARANCE;  
1764 - String params = buildParams(orderCode);  
1765 - InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);  
1766 1774
1767 - InBoxResponse resp = inBoxSDK.addInbox(req);  
1768 - logger.info("record noticeWhenBuyerBlownCustomsClearance to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",  
1769 - buyerUid, orderCode,prdName, resp); 1775 + Runnable task = ()->{
  1776 + InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.BUYER_BLOWN_CUSTOMS_CLEARANCE;
  1777 + String params = buildParams(orderCode);
  1778 + InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
1770 1779
1771 - //短信  
1772 - String phone = userProxyService.getMobile(buyerUid);  
1773 - if (StringUtils.isBlank(phone)){  
1774 - logger.warn("in noticeWhenBuyerBlownCustomsClearance sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);  
1775 - return;  
1776 - }  
1777 - List<String> mobileList = Arrays.asList(phone); 1780 + InBoxResponse resp = inBoxSDK.addInbox(req);
  1781 + logger.info("record noticeWhenBuyerBlownCustomsClearance to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
  1782 + buyerUid, orderCode,prdName, resp);
1778 1783
1779 - InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_BUYER_BLOWN_CUSTOMS_CLEARANCE; 1784 + //短信
  1785 + String phone = userProxyService.getMobile(buyerUid);
  1786 + if (StringUtils.isBlank(phone)){
  1787 + logger.warn("in noticeWhenBuyerBlownCustomsClearance sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
  1788 + return;
  1789 + }
  1790 + List<String> mobileList = Arrays.asList(phone);
1780 1791
1781 - String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);  
1782 - sendSmsService.smsSendByMobile(content,mobileList);  
1783 - logger.info("record noticeWhenBuyerBlownCustomsClearance inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",  
1784 - buyerUid, orderCode, prdName,sizeName);  
1785 - });  
1786 - } catch (Exception e) {  
1787 - logger.warn("InBoxFacade noticeWhenBuyerBlownCustomsClearance error inbox msg, buyerUid {}, orderCode {} ,prdName {}",  
1788 - buyerUid, orderCode, prdName, e);  
1789 - } 1792 + InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_BUYER_BLOWN_CUSTOMS_CLEARANCE;
  1793 +
  1794 + String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
  1795 + sendSmsService.smsSendByMobile(content,mobileList);
  1796 + logger.info("record noticeWhenBuyerBlownCustomsClearance inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
  1797 + buyerUid, orderCode, prdName,sizeName);
  1798 + };
  1799 + String logModule = "InBoxFacade noticeWhenBuyerBlownCustomsClearance error inbox msg, buyerUid {}, orderCode {} ,prdName {}";
  1800 + Object[] logparams = new Object[]{buyerUid, orderCode, prdName};
  1801 +
  1802 + execute(task, logModule, logparams);
  1803 + }
  1804 +
  1805 + public void noticeWhenQuickDeliverOrderPaid(int buyerUid, long orderCode, SellerOrderGoods sog){
  1806 + String prdName = sog.getProductName();
  1807 + String sizeName = sog.getSizeName();
  1808 +
  1809 + Runnable task = ()->{
  1810 + InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_QUICK_DELIVER_ORDER_PAID;
  1811 + String params = buildParams(orderCode);
  1812 + InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
  1813 +
  1814 + InBoxResponse resp = inBoxSDK.addInbox(req);
  1815 + logger.info("record noticeWhenQuickDeliverOrderPaid to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
  1816 + buyerUid, orderCode,prdName, resp);
  1817 +
  1818 + //短信
  1819 + String phone = userProxyService.getMobile(buyerUid);
  1820 + if (StringUtils.isBlank(phone)){
  1821 + logger.warn("in noticeWhenQuickDeliverOrderPaid sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
  1822 + return;
  1823 + }
  1824 + List<String> mobileList = Arrays.asList(phone);
  1825 +
  1826 + InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_QUICK_DELIVER_ORDER_PAID;
  1827 +
  1828 + String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
  1829 + sendSmsService.smsSendByMobile(content,mobileList);
  1830 + logger.info("record noticeWhenQuickDeliverOrderPaid inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
  1831 + buyerUid, orderCode, prdName,sizeName);
  1832 + };
  1833 + String logModule = "InBoxFacade noticeWhenQuickDeliverOrderPaid error inbox msg, buyerUid {}, orderCode {} ,prdName {}";
  1834 + Object[] logparams = new Object[]{buyerUid, orderCode, prdName};
  1835 +
  1836 + execute(task, logModule, logparams);
  1837 + appraisePassNoticeSeller(buyerUid,orderCode, sog);
  1838 + }
  1839 +
  1840 + public void noticeWhenDepositOrderOfQuickDeliverGoodsPaid(int buyerUid, long orderCode, SellerOrderGoods sog){
  1841 + String prdName = sog.getProductName();
  1842 + String sizeName = sog.getSizeName();
  1843 +
  1844 + Runnable task = ()->{
  1845 + InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_DEPOSIT_ORDER_OF_QUICK_DELIVER_PAID;
  1846 + String params = buildParams(orderCode);
  1847 + InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
  1848 +
  1849 + InBoxResponse resp = inBoxSDK.addInbox(req);
  1850 + logger.info("record noticeWhenDepositOrderOfPaid to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
  1851 + buyerUid, orderCode,prdName, resp);
  1852 +
  1853 + //短信
  1854 + String phone = userProxyService.getMobile(buyerUid);
  1855 + if (StringUtils.isBlank(phone)){
  1856 + logger.warn("in noticeWhenDepositOrderOfPaid sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
  1857 + return;
  1858 + }
  1859 + List<String> mobileList = Arrays.asList(phone);
  1860 +
  1861 + InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_DEPOSIT_ORDER_OF_QUICK_DELIVER_PAID;
  1862 +
  1863 + String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
  1864 + sendSmsService.smsSendByMobile(content,mobileList);
  1865 + logger.info("record noticeWhenDepositOrderOfPaid inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
  1866 + buyerUid, orderCode, prdName,sizeName);
  1867 + };
  1868 + String logModule = "InBoxFacade noticeWhenDepositOrderOfPaid error inbox msg, buyerUid {}, orderCode {} ,prdName {}";
  1869 + Object[] logparams = new Object[]{buyerUid, orderCode, prdName};
  1870 + execute(task, logModule, logparams);
  1871 + //
  1872 + appraisePassNoticeSeller(buyerUid,orderCode, sog);
1790 } 1873 }
1791 1874
1792 public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) { 1875 public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) {