|
@@ -22,10 +22,12 @@ import com.txz.mall.core.ResultCode;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
|
|
+import com.txz.mall.enums.OrderEventsEnum;
|
|
import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
import com.txz.mall.model.*;
|
|
import com.txz.mall.model.*;
|
|
import com.txz.mall.service.*;
|
|
import com.txz.mall.service.*;
|
|
import com.txz.mall.util.EasyExcelUtil;
|
|
import com.txz.mall.util.EasyExcelUtil;
|
|
|
|
+import com.txz.mall.util.OrderStateMachine;
|
|
import com.txz.mall.util.OrderUtils;
|
|
import com.txz.mall.util.OrderUtils;
|
|
import dto.*;
|
|
import dto.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
@@ -36,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import po.StoreOrderExportPO;
|
|
import po.StoreOrderExportPO;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
@@ -1229,14 +1232,14 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storeOrder.setMark(StringEscapeUtils.escapeHtml4(request.getMark()));
|
|
storeOrder.setMark(StringEscapeUtils.escapeHtml4(request.getMark()));
|
|
storeOrder.setCombinationId(orderInfoVo.getCombinationId());
|
|
storeOrder.setCombinationId(orderInfoVo.getCombinationId());
|
|
storeOrder.setPinkId(orderInfoVo.getPinkId());
|
|
storeOrder.setPinkId(orderInfoVo.getPinkId());
|
|
- storeOrder.setBargainUserId(orderInfoVo.getBargainUserId());
|
|
|
|
|
|
+ // storeOrder.setBargainUserId(orderInfoVo.getBargainUserId());
|
|
storeOrder.setCreateTime(new Date());
|
|
storeOrder.setCreateTime(new Date());
|
|
storeOrder.setShippingType(request.getShippingType());
|
|
storeOrder.setShippingType(request.getShippingType());
|
|
storeOrder.setIsChannel(isChannel);
|
|
storeOrder.setIsChannel(isChannel);
|
|
storeOrder.setPaid(0);
|
|
storeOrder.setPaid(0);
|
|
storeOrder.setCost(BigDecimal.ZERO);
|
|
storeOrder.setCost(BigDecimal.ZERO);
|
|
storeOrder.setType(0);
|
|
storeOrder.setType(0);
|
|
- storeOrder.setStatus(PinkOrderStatusEnum.UNPAID.getKey());
|
|
|
|
|
|
+ storeOrder.setStatus(PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
|
|
|
|
// StoreCouponUser storeCouponUser = new StoreCouponUser();
|
|
// StoreCouponUser storeCouponUser = new StoreCouponUser();
|
|
// // 优惠券修改
|
|
// // 优惠券修改
|
|
@@ -1254,17 +1257,17 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
// 拼团商品扣库存
|
|
// 拼团商品扣库存
|
|
storeCombinationService.operationStock(skuRecord.getLong("activityId"), skuRecord.getInt("num"), "sub");
|
|
storeCombinationService.operationStock(skuRecord.getLong("activityId"), skuRecord.getInt("num"), "sub");
|
|
// 拼团商品规格扣库存
|
|
// 拼团商品规格扣库存
|
|
- productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
|
|
|
|
+ //** productAttrValueService.operationStock(skuRecord.getInt("activityAttrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_PINGTUAN);
|
|
// 普通商品口库存
|
|
// 普通商品口库存
|
|
storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
// 普通商品规格扣库存
|
|
// 普通商品规格扣库存
|
|
- productAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
|
|
|
|
+ //** productAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
} else { // 普通商品
|
|
} else { // 普通商品
|
|
for (MyRecord skuRecord : skuRecordList) {
|
|
for (MyRecord skuRecord : skuRecordList) {
|
|
// 普通商品口库存
|
|
// 普通商品口库存
|
|
storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
// 普通商品规格扣库存
|
|
// 普通商品规格扣库存
|
|
- productAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
|
|
|
|
+ //** productAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1317,7 +1320,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
} else {
|
|
} else {
|
|
throw new ServiceException("获取用户钱包账户失败");
|
|
throw new ServiceException("获取用户钱包账户失败");
|
|
}
|
|
}
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.WAIT_OPEN.getKey());
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey());
|
|
|
|
|
|
if ("open".equals(dto.getType())) {
|
|
if ("open".equals(dto.getType())) {
|
|
OpenParam openParam = new OpenParam();
|
|
OpenParam openParam = new OpenParam();
|
|
@@ -1345,10 +1348,16 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
@Override
|
|
@Override
|
|
public void refund(Long id) {
|
|
public void refund(Long id) {
|
|
StoreOrder storeOrder = findById(id);
|
|
StoreOrder storeOrder = findById(id);
|
|
- if (storeOrder.getPaid().equals(Constants.ORDER_STATUS_H5_UNPAID)) {
|
|
|
|
|
|
+// if (storeOrder.getPaid().equals(Constants.ORDER_STATUS_H5_UNPAID)) {
|
|
|
|
+// throw new ServiceException("当前状态不支持退款");
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_APPLY_REFUND, null);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
throw new ServiceException("当前状态不支持退款");
|
|
throw new ServiceException("当前状态不支持退款");
|
|
}
|
|
}
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_REFUNDING.getKey());
|
|
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_REFUND.getKey());
|
|
|
|
|
|
// 归还用户余额
|
|
// 归还用户余额
|
|
// accountDubboServiceClient.refund(id.toString(), storeOrder.getOrderId(), storeOrder.getPayPrice());
|
|
// accountDubboServiceClient.refund(id.toString(), storeOrder.getOrderId(), storeOrder.getPayPrice());
|
|
@@ -1356,24 +1365,40 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storeCombinationService.operationStock(storeOrder.getCombinationId(), storeOrder.getTotalNum(), "add");
|
|
storeCombinationService.operationStock(storeOrder.getCombinationId(), storeOrder.getTotalNum(), "add");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // 中奖回收状态逻辑还没加
|
|
@Override
|
|
@Override
|
|
public void close(Long id) {
|
|
public void close(Long id) {
|
|
StoreOrder storeOrder = findById(id);
|
|
StoreOrder storeOrder = findById(id);
|
|
- if (storeOrder.getStatus().equals(Constants.ORDER_STATUS_H5_COMPLETE)) {
|
|
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CLOSE.getKey());
|
|
|
|
- } else {
|
|
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_NOT_WIN, null);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
throw new ServiceException("当前状态不支持关闭");
|
|
throw new ServiceException("当前状态不支持关闭");
|
|
}
|
|
}
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_CLOSED.getKey());
|
|
|
|
+
|
|
|
|
+// if (storeOrder.getStatus().equals(Constants.ORDER_STATUS_H5_COMPLETE)) {
|
|
|
|
+// updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CLOSE.getKey());
|
|
|
|
+// } else {
|
|
|
|
+// throw new ServiceException("当前状态不支持关闭");
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void cancel(Long id) {
|
|
public void cancel(Long id) {
|
|
StoreOrder storeOrder = findById(id);
|
|
StoreOrder storeOrder = findById(id);
|
|
- if (storeOrder.getPaid().equals(0)) {
|
|
|
|
- updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CANCEL.getKey());
|
|
|
|
- } else {
|
|
|
|
|
|
+ PinkOrderStatusEnum pinkOrderStatusEnum = OrderStateMachine.handleEvent(storeOrder, OrderEventsEnum.GROUP_PURCHASE_CANCEL, null);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
|
|
throw new ServiceException("当前状态不支持取消");
|
|
throw new ServiceException("当前状态不支持取消");
|
|
}
|
|
}
|
|
|
|
+ updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_CANCELLATION.getKey());
|
|
|
|
+
|
|
|
|
+// if (storeOrder.getPaid().equals(0)) {
|
|
|
|
+// updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CANCEL.getKey());
|
|
|
|
+// } else {
|
|
|
|
+// throw new ServiceException("当前状态不支持取消");
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1408,7 +1433,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storeOrder.setDeliveryId(po.getDeliveryId());
|
|
storeOrder.setDeliveryId(po.getDeliveryId());
|
|
storeOrder.setDeliveryName(po.getDeliveryName());
|
|
storeOrder.setDeliveryName(po.getDeliveryName());
|
|
update(storeOrder);
|
|
update(storeOrder);
|
|
- updateOrderStatus(po.getId(), PinkOrderStatusEnum.WAIT_RECEIVER.getKey());
|
|
|
|
|
|
+ // updateOrderStatus(po.getId(), PinkOrderStatusEnum.WAIT_RECEIVER.getKey());
|
|
|
|
+ updateOrderStatus(po.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_RECEVIE.getKey());
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
@@ -1423,6 +1449,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
storeOrderStatusService.createLog(id, "", PinkOrderStatusEnum.getEnum(status).getValue());
|
|
storeOrderStatusService.createLog(id, "", PinkOrderStatusEnum.getEnum(status).getValue());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 校验商品库存(生成订单)
|
|
* 校验商品库存(生成订单)
|
|
*
|
|
*
|