|
|
@@ -76,6 +76,7 @@ import com.uas.platform.b2c.trade.presale.dao.TradeBasicPropertiesDao;
|
|
|
import com.uas.platform.b2c.trade.seek.service.SeekPurchaseService;
|
|
|
import com.uas.platform.b2c.trade.support.CodeType;
|
|
|
import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
+import com.uas.platform.b2c.trade.util.BoundedExecutor;
|
|
|
import com.uas.platform.b2c.trade.util.Preconditions;
|
|
|
import com.uas.platform.b2c.trade.util.StatusChangeUtil;
|
|
|
import com.uas.platform.b2c.trade.util.TradeLogUtil;
|
|
|
@@ -114,6 +115,8 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
import static com.uas.platform.b2c.trade.aftersale.model.AfterSaleStatus.*;
|
|
|
import static com.uas.platform.b2c.trade.util.Preconditions.checkNotNull;
|
|
|
@@ -136,8 +139,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
private static final long billNoNeed = -1L;
|
|
|
private static final TradeBufferedLogger logger = BufferedLoggerManager
|
|
|
.getLogger(TradeBufferedLogger.class);
|
|
|
- @Autowired
|
|
|
- private OrderDao orderDao;
|
|
|
+ private final OrderDao orderDao;
|
|
|
@Autowired
|
|
|
private OrderDetailDao orderDetailDao;
|
|
|
@Autowired
|
|
|
@@ -215,6 +217,15 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Autowired
|
|
|
private MessageNotifyPersonalManagementService messageNotifyPersonalManagementService;
|
|
|
|
|
|
+ private final BoundedExecutor executor;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public OrderServiceImpl(OrderDao orderDao) {
|
|
|
+ this.orderDao = orderDao;
|
|
|
+ ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
+ executor = new BoundedExecutor(executorService, 1600);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存订单信息
|
|
|
*
|
|
|
@@ -1459,21 +1470,20 @@ public class OrderServiceImpl implements OrderService {
|
|
|
purchase.setSendstatus(Status.NOT_UPLOAD.value());
|
|
|
purchaseDao.save(purchase);
|
|
|
|
|
|
- // 如果买家需要开发票,则生成发票申请
|
|
|
- if (Type.Bill_No.value() != newOrder.getInvoicetype().intValue()) {
|
|
|
- billSubmitService.saveByAdmin(newOrder);
|
|
|
- }
|
|
|
-
|
|
|
//发送短信,异常不作处理
|
|
|
try {
|
|
|
sendMessage(purchase);
|
|
|
- }catch (RuntimeException e){}
|
|
|
+ } catch (RuntimeException e){}
|
|
|
} else if ((purchase.getStatus().intValue() != Status.UNAVAILABLE_DISAGREE.value())
|
|
|
&& (purchase.getStatus().intValue() != Status.UNAVAILABLE_PERSONAL.value())) { // 采购单不在用户取消状态
|
|
|
throw new IllegalOperatorException("采购单" + purchase.getPurchaseid() + ", 状态是"
|
|
|
+ Status.valueOf(purchase.getStatus()).getPhrase() + ",是异常状态");
|
|
|
}
|
|
|
}
|
|
|
+ // 如果买家需要开发票,则生成发票申请
|
|
|
+ if (Type.Bill_No.value() != newOrder.getInvoicetype().intValue()) {
|
|
|
+ billSubmitService.saveByAdmin(newOrder);
|
|
|
+ }
|
|
|
return newOrder;
|
|
|
}
|
|
|
|
|
|
@@ -1484,15 +1494,14 @@ public class OrderServiceImpl implements OrderService {
|
|
|
* @throws RuntimeException the runtime exception
|
|
|
*/
|
|
|
@Override
|
|
|
- public void sendMessage(Purchase purchase) throws RuntimeException{
|
|
|
+ public void sendMessage(final Purchase purchase) throws RuntimeException {
|
|
|
if (purchase == null) {
|
|
|
return;
|
|
|
}
|
|
|
/*-------------发送短信给卖方企业----------------*/
|
|
|
- int sum = 0;
|
|
|
try {
|
|
|
//获取502,406状态下的该卖家采购单总量
|
|
|
- sum = purchaseDao.getCountBySellerenuuAndStatus(purchase.getSellerenuu(), Status.CONFIRMED.value()) +
|
|
|
+ final int sum = purchaseDao.getCountBySellerenuuAndStatus(purchase.getSellerenuu(), Status.CONFIRMED.value()) +
|
|
|
purchaseDao.getCountBySellerenuuAndStatus(purchase.getSellerenuu(), Status.TOBESHIPPED.value());
|
|
|
|
|
|
/* 暂时取企业管理员的电话信息,这是商品上架人的信息
|
|
|
@@ -1509,15 +1518,27 @@ public class OrderServiceImpl implements OrderService {
|
|
|
if (en.getEnAdminuu() == null) {
|
|
|
return;
|
|
|
}
|
|
|
- User admin = userDao.findOne(en.getEnAdminuu());
|
|
|
+ List<User> userList = userDao.findUserByUserUU(en.getEnAdminuu());
|
|
|
+ if (CollectionUtils.isEmpty(userList)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ final User admin = userList.get(0);
|
|
|
if (admin == null || admin.getUserTel() == null || purchase.getSellername() == null) {
|
|
|
return;
|
|
|
}
|
|
|
- sendMessageService.sendMessageForOrderSucess(purchase.getSellername(), sum,
|
|
|
- admin.getUserTel(), MessageType.orderpay);
|
|
|
+ executor.submitTask(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ sendMessageService.sendMessageForOrderSucess(purchase.getSellername(), sum,
|
|
|
+ admin.getUserTel(), MessageType.orderpay);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
/*--------------------------------------------*/
|
|
|
- }catch (RuntimeException e){
|
|
|
+ }catch (RuntimeException e) {
|
|
|
throw e;
|
|
|
+ }catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1696,15 +1717,19 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderDetail.setWeight(component.getWeight());
|
|
|
}
|
|
|
} else {
|
|
|
- GoodsHistory goodsHistory = goodsHisDao.findByBatchCode(orderDetail.getBatchCode()).get(0);
|
|
|
- orderDetail.setReserve(goodsHistory.getReserve());
|
|
|
- Component component = null;
|
|
|
- if (goodsHistory.getUuid() != null){
|
|
|
- component = componentService.findByUuid(goodsHistory.getUuid());
|
|
|
- }
|
|
|
- if (component != null){
|
|
|
- orderDetail.setWeight(component.getWeight());
|
|
|
+ List<GoodsHistory> goodsHistories = goodsHisDao.findByBatchCode(orderDetail.getBatchCode());
|
|
|
+ if (!CollectionUtils.isEmpty(goodsHistories)) {
|
|
|
+ GoodsHistory goodsHistory = goodsHistories.get(0);
|
|
|
+ orderDetail.setReserve(goodsHistory.getReserve());
|
|
|
+ Component component = null;
|
|
|
+ if (goodsHistory.getUuid() != null){
|
|
|
+ component = componentService.findByUuid(goodsHistory.getUuid());
|
|
|
+ }
|
|
|
+ if (component != null){
|
|
|
+ orderDetail.setWeight(component.getWeight());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|