|
|
@@ -40,15 +40,21 @@ import com.uas.platform.b2c.logistics.dao.AddressDao;
|
|
|
import com.uas.platform.b2c.logistics.dao.InvoiceFOrderDao;
|
|
|
import com.uas.platform.b2c.logistics.dao.InvoiceFPurchaseDao;
|
|
|
import com.uas.platform.b2c.logistics.dao.PickUpAddressDao;
|
|
|
-import com.uas.platform.b2c.logistics.model.*;
|
|
|
+import com.uas.platform.b2c.logistics.model.Address;
|
|
|
+import com.uas.platform.b2c.logistics.model.InvoiceFOrder;
|
|
|
+import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
|
|
|
+import com.uas.platform.b2c.logistics.model.PickUpAddress;
|
|
|
+import com.uas.platform.b2c.logistics.service.InvoiceFOrderService;
|
|
|
import com.uas.platform.b2c.logistics.service.InvoiceFPurchaseService;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.CommodityInOutboundService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.InOutboundDetailService;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
|
|
|
import com.uas.platform.b2c.prod.product.component.modal.Component;
|
|
|
@@ -219,8 +225,17 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Autowired
|
|
|
private MessageNotifyPersonalManagementService messageNotifyPersonalManagementService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InOutboundDetailService inOutboundDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommodityInOutboundService commodityInOutboundService;
|
|
|
+
|
|
|
private final BoundedExecutor executor;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InvoiceFOrderService invoiceFOrderService;
|
|
|
+
|
|
|
@Autowired
|
|
|
public OrderServiceImpl(OrderDao orderDao) {
|
|
|
this.orderDao = orderDao;
|
|
|
@@ -696,12 +711,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
Order order = (Order) resultMap1.getData();
|
|
|
|
|
|
- /*
|
|
|
- * 核心逻辑放在这里,其余逻辑放到外部,避免对核心业务逻辑的干扰
|
|
|
- */
|
|
|
-// if (order.getOrderDetails().size() == 0) {
|
|
|
-// throw new IllegalOperatorException("你没有商品需要确认订单,请返回购物车选择要购买的商品");
|
|
|
-// }
|
|
|
// 设置发票信息
|
|
|
setBillInfo(order);
|
|
|
// 设置订单信息
|
|
|
@@ -742,11 +751,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
assert logger != null;
|
|
|
String changeLog = TradeLogUtil.changeStatusLog(Status.TOBECONFIRMED.toString(), Status.TOBEPAID.toString());
|
|
|
logger.log(or, TradeLog.VoucherOperation.BUYER_ENSURE_ORDER, changeLog);
|
|
|
-
|
|
|
-// OrderMessage orderMessage = new OrderMessage();
|
|
|
-// orderMessage.setOrder(order);
|
|
|
-// orderMessage.setEncodeOrderId(EncryptionFilter.encode(order.getOrderid()));
|
|
|
-// internalMessageService.messageToBuyer(orderMessage, "velocity/orderMessage.vm", "订单信息", null);
|
|
|
}
|
|
|
return ResultMap.success(orderList);
|
|
|
}
|
|
|
@@ -1366,7 +1370,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
Order order = orderDao.findOne(orid);
|
|
|
Long uu = SystemSession.getUser().getUserUU();
|
|
|
order.setStatusInBound(uu);
|
|
|
- order.setInid(inid);
|
|
|
+ order.addInInds(inid);
|
|
|
return orderDao.save(order);
|
|
|
}
|
|
|
|
|
|
@@ -1736,140 +1740,128 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return bankTransfer;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 客户确认订单收货
|
|
|
+ *
|
|
|
+ * @param id 客户订单
|
|
|
+ * @param invoiceId 出货单号
|
|
|
+ * @return ResultMap
|
|
|
+ */
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
- public OrderSimpleInfo ensureOrderAccept(String ids) {
|
|
|
- String[] idArray = ids.split(SplitChar.HYPHEN);
|
|
|
- OrderSimpleInfo simple = null;
|
|
|
- //统计每个器件的购买数量
|
|
|
- Map<String, Double> mapQty = new HashMap<String, Double>();
|
|
|
- //统计每个器件的下单数
|
|
|
- Map<String, Integer> mapNum = new HashMap<String, Integer>();
|
|
|
- Set<String> uuids = null;
|
|
|
-
|
|
|
- for (String id : idArray) {
|
|
|
- uuids = new HashSet<String>();
|
|
|
- Order order = orderDao.findOne(Long.parseLong(id));
|
|
|
- if (order.getStatus().intValue() != Status.INBOUND.value()) {
|
|
|
- throw new IllegalOperatorException("当前订单不在待收货状态,不能收货!");
|
|
|
- }
|
|
|
- Long uu = null;
|
|
|
- if (SystemSession.getUser() == null) {//有可能是自动定时任务执行当前代码
|
|
|
- uu = sysConf.getAdminUU();
|
|
|
- } else {
|
|
|
- uu = SystemSession.getUser().getUserUU();
|
|
|
- }
|
|
|
- List<Purchase> purchases = purchaseDao.findByOrderid(order.getOrderid());
|
|
|
-
|
|
|
- //如果是优软代售
|
|
|
- if (order.getStoreid().equals(sysConf.getStoreid())) {
|
|
|
- // 2 出货单设置成已收货
|
|
|
- InvoiceFOrder invoiceFOrder = invoiceFOrderDao.findByInvoiceid(order.getInid());
|
|
|
- if (invoiceFOrder == null) {
|
|
|
- throw new IllegalOperatorException("没有传入有效的订单信息");
|
|
|
- }
|
|
|
- invoiceFOrder.setStatusReceived(uu);
|
|
|
- Set<InvoiceFOrderDetail> invoiceFOrderDetails = invoiceFOrder.getInvoiceFOrderDetails();
|
|
|
- for (InvoiceFOrderDetail invoiceFOrderDetail : invoiceFOrderDetails) {
|
|
|
- if (invoiceFOrderDetail.getStatus().intValue() == Status.INBOUND.value()) {
|
|
|
- invoiceFOrderDetail.setStatus(Status.RECEIVED.value());
|
|
|
- }
|
|
|
- }
|
|
|
- invoiceFOrderDao.save(invoiceFOrder);
|
|
|
-
|
|
|
- // 3.关联采购单设置成待付款
|
|
|
- for (Purchase purchase2 : purchases) {
|
|
|
- if (purchase2.getStatus().intValue() != Status.RECEIVED.value()) {
|
|
|
- throw new IllegalOperatorException("订单关联的采购单:" + purchase2.getPurchaseid() + ",状态异常:"
|
|
|
- + Status.valueOf(purchase2.getStatus()).getPhrase());
|
|
|
- }
|
|
|
- Set<PurchaseDetail> purchaseDetails = purchase2.getPurchaseDetails();
|
|
|
- for (PurchaseDetail purchaseDetail : purchaseDetails) {
|
|
|
- if (purchaseDetail.getStatus().intValue() == Status.RECEIVED.value()) {
|
|
|
- purchaseDetail.setStatusToBePaid(uu);
|
|
|
- }
|
|
|
- }
|
|
|
- purchase2.setTobepaid(uu);
|
|
|
- purchaseDao.save(purchase2);
|
|
|
+ public ResultMap ensureOrderAccept(Long id, String invoiceId) {
|
|
|
+ if (id == null) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "订单信息缺失");
|
|
|
+ }
|
|
|
+ Order order = orderDao.findOne(id);
|
|
|
+ if (order == null) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "订单信息错误,找不到对应订单信息");
|
|
|
+ }
|
|
|
+ // 第一步 对发货单确认收货, 采购入库
|
|
|
+ if (!StringUtils.isEmpty(invoiceId)) {
|
|
|
+ invoiceSignReceive(order, invoiceId);
|
|
|
+ } else {
|
|
|
+ String inIds = order.getInIds();
|
|
|
+ if (StringUtils.isEmpty(inIds)) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "关联的发货单缺失");
|
|
|
+ }
|
|
|
+ String[] invoiceids = inIds.split(SplitChar.COMMA);
|
|
|
+ for (String inid : invoiceids) {
|
|
|
+ invoiceSignReceive(order, inid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (NumberUtil.compare(order.getQty(), order.getShipQty()) > 0) {
|
|
|
+ return ResultMap.success(null);
|
|
|
+ }
|
|
|
+ //如果已经全部发货 (order.getQty() < order.getShipQty())
|
|
|
+ String inIds = order.getInIds();
|
|
|
+ String[] invoiceids = inIds.split(SplitChar.COMMA);
|
|
|
+ Boolean selfSell = true, allReceive = true;
|
|
|
+ if (sysConf.getStoreid().equals(order.getStoreid())) {
|
|
|
+ selfSell = false;
|
|
|
+ }
|
|
|
+ for (String inId : invoiceids) {
|
|
|
+ if (selfSell) {
|
|
|
+ InvoiceFPurchase fPurchase = invoiceFPService.findByInvoiceid(inId);
|
|
|
+ if (fPurchase.getStatus().intValue() != Status.RECEIVED.value()) {
|
|
|
+ allReceive = false;
|
|
|
+ break;
|
|
|
}
|
|
|
- } else {//不是优软代售
|
|
|
- for (Purchase purchase : purchases) {
|
|
|
- String inid = purchase.getInid();
|
|
|
- InvoiceFPurchase invoice = invoiceFPurchaseDao.findByInvoiceid(inid);
|
|
|
- invoice.setStatusReceived(uu);
|
|
|
- for (InvoiceFPurchaseDetail detail : invoice.getInvoiceFPurchaseDetails()) {
|
|
|
- if (detail.getStatus().intValue() == Status.INBOUND.value()) {
|
|
|
- detail.setStatus(Status.RECEIVED.value());
|
|
|
- }
|
|
|
- }
|
|
|
- invoiceFPurchaseDao.save(invoice);
|
|
|
-
|
|
|
- if (purchase.getStatus().intValue() != Status.INBOUND.value()) {
|
|
|
- throw new IllegalOperatorException("订单关联的采购单:" + purchase.getPurchaseid() + ",状态异常:"
|
|
|
- + Status.valueOf(purchase.getStatus()).getPhrase());
|
|
|
- }
|
|
|
-
|
|
|
- for (PurchaseDetail detail : purchase.getPurchaseDetails()) {
|
|
|
- if (detail.getStatus().intValue() == Status.INBOUND.value()) {
|
|
|
- detail.setStatusToBePaid(uu);
|
|
|
- }
|
|
|
- }
|
|
|
- purchase.setTobepaid(uu);
|
|
|
- purchaseDao.save(purchase);
|
|
|
+ } else {
|
|
|
+ InvoiceFOrder invoiceFOrder = invoiceFOrderService.findByInvoiceid(inId);
|
|
|
+ if (invoiceFOrder.getStatus().intValue() != Status.RECEIVED.value()) {
|
|
|
+ allReceive = false;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ //如果未全部收货
|
|
|
+ if (!allReceive) {
|
|
|
+ return ResultMap.success(null);
|
|
|
+ }
|
|
|
+ //如果已全部收货
|
|
|
+ Long uu = null;
|
|
|
+ if (SystemSession.getUser() == null) {//有可能是自动定时任务执行当前代码
|
|
|
+ uu = sysConf.getAdminUU();
|
|
|
+ } else {
|
|
|
+ uu = SystemSession.getUser().getUserUU();
|
|
|
+ }
|
|
|
+ List<Purchase> purchases = purchaseDao.findByOrderid(order.getOrderid());
|
|
|
+ //不是优软代售
|
|
|
+ for (Purchase purchase : purchases) {
|
|
|
+ if ((purchase.getStatus().intValue() != Status.INBOUND.value()) && (purchase.getStatus().intValue() != Status.RECEIVED.value())) {
|
|
|
+ throw new IllegalOperatorException("订单关联的采购单:" + purchase.getPurchaseid() + ",状态异常:"
|
|
|
+ + Status.valueOf(purchase.getStatus()).getPhrase());
|
|
|
+ }
|
|
|
|
|
|
- // 1 订单设置成已收货
|
|
|
- order.setStatusReceived(uu);
|
|
|
- order.setReciptTime(new Date());
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(order.getReciptTime());
|
|
|
- // TODO huxz 计算订单自动完成时间
|
|
|
- calendar.add(Calendar.MILLISECOND, 1);
|
|
|
- //calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + ORDER_COMPLETE_DAYS);
|
|
|
- order.setAutoCompleteTime(calendar.getTime());
|
|
|
-
|
|
|
- // TODO huxz 二次签收直接变更状态为已完成状态
|
|
|
- // 设置明细的状态
|
|
|
- Set<OrderDetail> orderDetails = order.getOrderDetails();
|
|
|
- for (OrderDetail orderDetail : orderDetails) {
|
|
|
- if (orderDetail.getStatus().intValue() == Status.INBOUND.value()) {
|
|
|
- orderDetail.setStatusReceived(uu);
|
|
|
-
|
|
|
- //统计器件的购买的数量
|
|
|
- String uuid = orderDetail.getUuid();
|
|
|
- if (!StringUtils.isEmpty(uuid)) {
|
|
|
- Double num = mapQty.get(uuid);
|
|
|
- num = num == null ? 0 : num;
|
|
|
- num = num + orderDetail.getNumber();
|
|
|
- uuids.add(uuid);
|
|
|
- mapQty.put(uuid, num);
|
|
|
- }
|
|
|
-
|
|
|
+ for (PurchaseDetail detail : purchase.getPurchaseDetails()) {
|
|
|
+ if (detail.getStatus().intValue() == Status.INBOUND.value() || (detail.getStatus().intValue() == Status.RECEIVED.value())) {
|
|
|
+ detail.setStatusToBePaid(uu);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //统计每个器件的下单数量
|
|
|
- for (String uuid : uuids) {
|
|
|
- Integer num = mapNum.get(uuid);
|
|
|
- num = num == null ? 0 : num;
|
|
|
- num++;
|
|
|
- mapNum.put(uuid, num);
|
|
|
+ purchase.setTobepaid(uu);
|
|
|
+ purchaseDao.save(purchase);
|
|
|
+ }
|
|
|
+ // 1 订单设置成已收货
|
|
|
+ order.setStatusReceived(uu);
|
|
|
+ order.setReciptTime(new Date());
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(order.getReciptTime());
|
|
|
+ // TODO huxz 计算订单自动完成时间
|
|
|
+ calendar.add(Calendar.MILLISECOND, 1);
|
|
|
+ //calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + ORDER_COMPLETE_DAYS);
|
|
|
+ order.setAutoCompleteTime(calendar.getTime());
|
|
|
+
|
|
|
+ // TODO huxz 二次签收直接变更状态为已完成状态
|
|
|
+ // 设置明细的状态
|
|
|
+ Set<OrderDetail> orderDetails = order.getOrderDetails();
|
|
|
+ for (OrderDetail orderDetail : orderDetails) {
|
|
|
+ if (orderDetail.getStatus().intValue() == Status.INBOUND.value()) {
|
|
|
+ orderDetail.setStatusReceived(uu);
|
|
|
}
|
|
|
+ }
|
|
|
+ orderDao.save(order);
|
|
|
+ return ResultMap.success(null);
|
|
|
+ }
|
|
|
|
|
|
- order = orderDao.save(order);
|
|
|
- simple = new OrderSimpleInfo(order);
|
|
|
+ /**
|
|
|
+ * 对发货单确认收货
|
|
|
+ * @param order 订单
|
|
|
+ * @param invoiceid 出货单
|
|
|
+ * @return 返回结果
|
|
|
+ */
|
|
|
+ private ResultMap invoiceSignReceive(Order order, String invoiceid) {
|
|
|
+ if (order == null) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "订单信息为空");
|
|
|
}
|
|
|
- Set<String> keySet = mapQty.keySet();
|
|
|
- for (String uuid : keySet) {
|
|
|
- Component component = componentDao.findByUuid(uuid);
|
|
|
- if (component != null) {
|
|
|
- component.setOrderNumber((component.getOrderNumber() == null ? 0 : component.getOrderNumber()) - 1);
|
|
|
- component.setOrderQty((component.getOrderQty() == null ? 0 : component.getOrderQty()) - mapQty.get(uuid));
|
|
|
- componentDao.save(component);
|
|
|
- }
|
|
|
+ if (StringUtils.isEmpty(invoiceid)) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "发货单信息缺失");
|
|
|
+ }
|
|
|
+ if (sysConf.getStoreid().equals(order.getStoreid())) {
|
|
|
+ invoiceFOrderService.signReceive(invoiceid, order);
|
|
|
+ } else {
|
|
|
+ invoiceFPService.signReceive(invoiceid,order);
|
|
|
}
|
|
|
- return simple;
|
|
|
+ return ResultMap.success(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -2450,20 +2442,30 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
OrderRelationInfo info = new OrderRelationInfo();
|
|
|
// 获取平台
|
|
|
- if (order.getInid() != null) {
|
|
|
- InvoiceFOrder inFOrder = invoiceFOrderDao.findByInvoiceid(order.getInid());
|
|
|
- info.setInForderid(inFOrder.getInvoiceid());
|
|
|
- String b2cLogistic = inFOrder.getLogistics() == null ? null : inFOrder.getLogistics().getNumber();
|
|
|
- info.setB2cLogistic(b2cLogistic);
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(order.getInIds())) {
|
|
|
+ String inIds = order.getInIds();
|
|
|
+ String[] invoiceids = inIds.split(SplitChar.COMMA);
|
|
|
+ for (String invoiceid : invoiceids) {
|
|
|
+ InvoiceFOrder inFOrder = invoiceFOrderDao.findByInvoiceid(invoiceid);
|
|
|
+ info.setInForderid(inFOrder.getInvoiceid());
|
|
|
+ String b2cLogistic = inFOrder.getLogistics() == null ? null : inFOrder.getLogistics().getNumber();
|
|
|
+ info.addB2cLogistic(b2cLogistic);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
List<Purchase> purchases = purchaseDao.findByOrderid(order.getOrderid());
|
|
|
for (Purchase purc : purchases) {
|
|
|
info.setPurchaseid(purc.getPurchaseid() + "-");
|
|
|
- InvoiceFPurchase invoiceFPurchase = invoiceFPurchaseDao.findByInvoiceid(purc.getInid());
|
|
|
- info.setInFpurcid(invoiceFPurchase.getInvoiceid() + "-");
|
|
|
- String vendLogistic = invoiceFPurchase.getLogistics() == null ? null
|
|
|
- : invoiceFPurchase.getLogistics().getNumber();
|
|
|
- info.setVendLogistic(vendLogistic + "-");
|
|
|
+ String inids = purc.getInids();
|
|
|
+ String[] split = inids.split(SplitChar.COMMA);
|
|
|
+ for (String invoiceid : split) {
|
|
|
+ InvoiceFPurchase invoiceFPurchase = invoiceFPurchaseDao.findByInvoiceid(invoiceid);
|
|
|
+ info.setInFpurcid(invoiceFPurchase.getInvoiceid() + "-");
|
|
|
+ String vendLogistic = invoiceFPurchase.getLogistics() == null ? null
|
|
|
+ : invoiceFPurchase.getLogistics().getNumber();
|
|
|
+ info.setVendLogistic(vendLogistic + "-");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
// 删除最后一个-
|
|
|
info.setPurchaseid(info.getPurchaseid().substring(0, info.getPurchaseid().length() - 1));
|