|
|
@@ -2,7 +2,6 @@ package com.gree.mall.miniapp.logic.order;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
@@ -11,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.gree.mall.miniapp.bean.PayDetail;
|
|
|
import com.gree.mall.miniapp.bean.coupon.UserCouponBean;
|
|
|
import com.gree.mall.miniapp.bean.goods.AckGoodsBean;
|
|
|
+import com.gree.mall.miniapp.bean.goods.GoodsMaterialStockDTO;
|
|
|
import com.gree.mall.miniapp.bean.order.*;
|
|
|
import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
|
|
|
import com.gree.mall.miniapp.bean.workorder.PgOrderSettleNormBean;
|
|
|
@@ -18,6 +18,7 @@ import com.gree.mall.miniapp.commonmapper.*;
|
|
|
import com.gree.mall.miniapp.constant.Constant;
|
|
|
import com.gree.mall.miniapp.enums.*;
|
|
|
import com.gree.mall.miniapp.enums.base.BaseEnum;
|
|
|
+import com.gree.mall.miniapp.enums.material.DirectFlagEnum;
|
|
|
import com.gree.mall.miniapp.enums.material.GoodsMaterialTypeEnum;
|
|
|
import com.gree.mall.miniapp.enums.workorder.SettleNormTypeEnum;
|
|
|
import com.gree.mall.miniapp.exception.RemoteServiceException;
|
|
|
@@ -28,6 +29,7 @@ import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
|
|
|
import com.gree.mall.miniapp.logic.coupon.CouponLogic;
|
|
|
import com.gree.mall.miniapp.logic.goods.GoodsCategoryLogic;
|
|
|
import com.gree.mall.miniapp.logic.goods.GoodsLogic;
|
|
|
+import com.gree.mall.miniapp.logic.goods.GoodsMaterialStockLogic;
|
|
|
import com.gree.mall.miniapp.logic.promotion.PromotionFullPieceLogic;
|
|
|
import com.gree.mall.miniapp.logic.promotion.PromotionGroupLogic;
|
|
|
import com.gree.mall.miniapp.logic.user.PayLogic;
|
|
|
@@ -37,7 +39,6 @@ import com.gree.mall.miniapp.plus.service.*;
|
|
|
import com.gree.mall.miniapp.utils.ArithUtils;
|
|
|
import com.gree.mall.miniapp.utils.CommonUtils;
|
|
|
import com.gree.mall.miniapp.utils.DateUtils;
|
|
|
-import com.gree.mall.miniapp.utils.IpUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -49,7 +50,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
@@ -153,6 +153,8 @@ public class OrderLogic {
|
|
|
StorageService storageService;
|
|
|
@Resource
|
|
|
OrderPickTimeConfigService orderPickTimeConfigService;
|
|
|
+ @Resource
|
|
|
+ GoodsMaterialStockLogic goodsMaterialStockLogic;
|
|
|
|
|
|
/**
|
|
|
* 立即购买
|
|
|
@@ -174,10 +176,9 @@ public class OrderLogic {
|
|
|
&& orderBuyBean.getTakeGoodsType().equals(TakeGoodsTypeEnum.Y.getKey())) {
|
|
|
throw new RemoteServiceException(1100, "请选择收货地址");
|
|
|
}
|
|
|
- if (orderBuyBean.getTakeGoodsType().equals(TakeGoodsTypeEnum.Z.getKey())
|
|
|
- && (Objects.isNull(orderBuyBean.getAppointmentPickStartTime())
|
|
|
- || Objects.isNull(orderBuyBean.getAppointmentPickEndTime()))) {
|
|
|
- throw new RemoteServiceException(1100, "请选择提货时间");
|
|
|
+ if (Objects.isNull(orderBuyBean.getAppointmentPickStartTime())
|
|
|
+ || Objects.isNull(orderBuyBean.getAppointmentPickEndTime())) {
|
|
|
+ throw new RemoteServiceException(1100, orderBuyBean.getTakeGoodsType().equals(TakeGoodsTypeEnum.Z.getKey()) ? "请选择提货时间" : "请选择配送时间");
|
|
|
}
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
|
|
|
|
|
|
@@ -421,6 +422,10 @@ public class OrderLogic {
|
|
|
payDetail.setIsPay(false);
|
|
|
}
|
|
|
|
|
|
+ if (!StringUtils.equals(orderBuyBean.getPayTypeId(), PayTypeEnum.ONLINE.getKey())) {
|
|
|
+ this.handleGoodsMaterialStock(orderInfo, orderDetails, currentCompanyWechat, DirectFlagEnum.SUB, "提交订单", "提交订单");
|
|
|
+ }
|
|
|
+
|
|
|
//不需要支付
|
|
|
if (!payDetail.getIsPay()) {
|
|
|
payLogic.payCall(payDetail.getId(), "", orderInfo.getPayAmount());
|
|
|
@@ -429,16 +434,48 @@ public class OrderLogic {
|
|
|
return payDetail;
|
|
|
}
|
|
|
|
|
|
- private OrderOldProductItem productCategoryItem(GoodsCategoryItem goodsCategoryItem) {
|
|
|
- OrderOldProductItem orderOldProductItem = BeanUtil.toBean(goodsCategoryItem, OrderOldProductItem.class);
|
|
|
- return orderOldProductItem;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param orderInfo
|
|
|
+ * @param orderDetailList
|
|
|
+ * @param currentCompanyWechat
|
|
|
+ * @param flagEnum
|
|
|
+ * @param refBillType
|
|
|
+ * @param remark
|
|
|
+ */
|
|
|
+ private void handleGoodsMaterialStock(OrderInfo orderInfo, List<OrderDetail> orderDetailList, CurrentCompanyWechat currentCompanyWechat,
|
|
|
+ DirectFlagEnum flagEnum, String refBillType, String remark) throws Exception {
|
|
|
+ List<GoodsMaterialStockDTO> dtoList = new ArrayList<>();
|
|
|
+ for (OrderDetail orderDetail : orderDetailList) {
|
|
|
+ GoodsMaterialStockDTO dto = new GoodsMaterialStockDTO();
|
|
|
+ dto.setDirectFlag(flagEnum.getKey())
|
|
|
+ .setRemindName(orderDetail.getGoodsMaterialName())
|
|
|
+ .setCompanyWechatId(orderInfo.getCompanyWechatId())
|
|
|
+ .setCompanyWechatName(orderInfo.getCompanyWechatName())
|
|
|
+ .setBrandId(orderDetail.getBrandId())
|
|
|
+ .setBrandName(orderDetail.getBrandName())
|
|
|
+ .setMainId(orderDetail.getMainNumber())
|
|
|
+ .setMainName(orderDetail.getMainName())
|
|
|
+ .setSmallId(orderDetail.getSmallNumber())
|
|
|
+ .setSmallName(orderDetail.getSmallName())
|
|
|
+ .setGoodsName(orderDetail.getGoodsMaterialName())
|
|
|
+ .setSeriesName(orderDetail.getGoodsMaterialSeriesName())
|
|
|
+ .setSpecsName(orderDetail.getGoodsSpecValue())
|
|
|
+ .setUnit(orderDetail.getGoodsMaterialUnit())
|
|
|
+ .setPrice(orderDetail.getPrice())
|
|
|
+ .setSdate(orderInfo.getExamineTime())
|
|
|
+ .setChangeQty(orderDetail.getNum())
|
|
|
+ .setRefBillNo(orderInfo.getOrderId())
|
|
|
+ .setRefBillType(refBillType)
|
|
|
+ .setStorageId(orderInfo.getPickStorageId())
|
|
|
+ .setStorageName(orderInfo.getPickStorageName())
|
|
|
+ .setGoodsMaterialId(orderDetail.getGoodsMaterialId())
|
|
|
+ .setRemark(remark)
|
|
|
+ .setOperateBy(currentCompanyWechat.getUserId());
|
|
|
+ dtoList.add(dto);
|
|
|
+ }
|
|
|
|
|
|
- private void productCategory(OrderOldProduct orderOldProduct, GoodsCategoryItem goodsCategoryItem) {
|
|
|
- BeanUtil.copyProperties(goodsCategoryItem,orderOldProduct);
|
|
|
- orderOldProduct.setPrice(goodsCategoryItem.getPrice());
|
|
|
- orderOldProduct.setSpecId(goodsCategoryItem.getId());
|
|
|
- orderOldProduct.setSpecName(goodsCategoryItem.getDictName());
|
|
|
+ goodsMaterialStockLogic.handleGoodsMaterialStock(dtoList);
|
|
|
}
|
|
|
|
|
|
|