mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2024-12-27 01:52:13 +08:00
Merge remote-tracking branch 'origin/company_server' into company_server
# Conflicts: # skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java
This commit is contained in:
commit
9bcb330431
3 changed files with 107 additions and 152 deletions
|
@ -89,7 +89,7 @@ public class Order extends AreaInfo {
|
|||
private String payType;
|
||||
|
||||
@TableField("total_price")
|
||||
@ApiModelProperty(value = "商品总价,单位:分",required = "required")
|
||||
@Property(value = "商品总价,单位:分")
|
||||
private String totalPrice;
|
||||
|
||||
@TableField("discount_price")
|
||||
|
|
|
@ -224,10 +224,8 @@ public class OrderCommentServiceImpl extends SkyeyeBusinessServiceImpl<OrderComm
|
|||
}
|
||||
|
||||
private List<OrderComment> setAdditionalReviewAndMerchantReply(List<OrderComment> customerFirst, List<OrderComment> customerLater, List<OrderComment> merchantReply) {
|
||||
Map<String, OrderComment> customerTowMap = customerLater.stream()
|
||||
.filter(ObjectUtil::isEmpty).collect(Collectors.toMap(OrderComment::getParentId, o -> o));// 客户追评
|
||||
Map<String, List<OrderComment>> merchantReplyMapList = merchantReply.stream()
|
||||
.filter(ObjectUtil::isEmpty).collect(Collectors.groupingBy(OrderComment::getParentId));// 商家回复
|
||||
Map<String, OrderComment> customerTowMap = customerLater.stream().collect(Collectors.toMap(OrderComment::getParentId, o -> o));// 客户追评
|
||||
Map<String, List<OrderComment>> merchantReplyMapList = merchantReply.stream().collect(Collectors.groupingBy(OrderComment::getParentId));// 商家回复
|
||||
for (OrderComment item : customerFirst) {
|
||||
if (customerTowMap.containsKey(item.getId())) {
|
||||
item.setAdditionalReview(JSONUtil.toBean(JSONUtil.toJsonStr(customerTowMap.get(item.getId())), null));
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.skyeye.common.util.DateUtil;
|
|||
import com.skyeye.common.util.mybatisplus.MybatisPlusUtil;
|
||||
import com.skyeye.coupon.entity.CouponUse;
|
||||
import com.skyeye.coupon.entity.CouponUseMaterial;
|
||||
import com.skyeye.coupon.enums.CouponUseState;
|
||||
import com.skyeye.coupon.enums.PromotionDiscountType;
|
||||
import com.skyeye.coupon.enums.PromotionMaterialScope;
|
||||
import com.skyeye.coupon.service.CouponUseMaterialService;
|
||||
|
@ -129,77 +130,29 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
checkAndSetVariable(order);
|
||||
// 活动信息及积分操作方法
|
||||
checkAndSetActive(order);
|
||||
// 总单的优惠券处理
|
||||
checkAndSetOrderCouponUse(order);
|
||||
refreshCache(order.getId());
|
||||
}
|
||||
|
||||
private void checkAndSetItemCouponUse(Order order) {// 子单的优惠券操作
|
||||
List<OrderItem> orderItemList = order.getOrderItemList();
|
||||
checkCouponUseMaterial(order);// 将总单的couponUserId赋值到对应子单
|
||||
// 设置商品信息、商品规格信息和优惠券信息
|
||||
iMaterialNormsService.setDataMation(orderItemList, OrderItem::getNormsId);
|
||||
iMaterialService.setDataMation(orderItemList, OrderItem::getMaterialId);
|
||||
for (OrderItem orderItem : orderItemList) {
|
||||
for (OrderItem orderItem : orderItemList) {// 计算每一个子单的总价
|
||||
// 获取子单单价 元 -> 分
|
||||
String salePrice = CalculationUtil.multiply(orderItem.getNormsMation().get("salePrice").toString(), "100");
|
||||
// 设置子单总价
|
||||
orderItem.setPrice(CalculationUtil.multiply(orderItem.getCount(), salePrice));
|
||||
if (StrUtil.isEmpty(orderItem.getCouponUseId())) {// 没有优惠券
|
||||
orderItem.setPayPrice(orderItem.getPrice());
|
||||
orderItem.setDiscountPrice("0");
|
||||
setLastValue(order, orderItem);// 总单商品数量、子单状态、总单原价、总单应付金额
|
||||
continue;
|
||||
}
|
||||
// 获取优惠券使用条件,即满多少金额可使用。
|
||||
String usePrice = orderItem.getCouponUseMation().get("usePrice").toString();
|
||||
if (CalculationUtil.getMax(orderItem.getPrice(), usePrice, CommonNumConstants.NUM_SIX).equals(usePrice)) {
|
||||
throw new CustomException("优惠券不满足使用金额");
|
||||
}
|
||||
// 获取折扣类型
|
||||
Integer discountType = (Integer) (orderItem.getCouponUseMation().get("discountType"));
|
||||
if (Objects.equals(PromotionDiscountType.PRICE.getKey(), discountType)) {// 满减
|
||||
// 取出折扣价格
|
||||
String discountPrice = orderItem.getCouponUseMation().get("discountPrice").toString();
|
||||
// 折后价
|
||||
String afterPrice = CalculationUtil.subtract(orderItem.getPrice(), discountPrice, CommonNumConstants.NUM_SIX);
|
||||
orderItem.setPayPrice(afterPrice);
|
||||
orderItem.setCouponPrice(discountPrice);
|
||||
} else {//百分比折扣
|
||||
// 取出折扣
|
||||
String discountPercentInt = orderItem.getCouponUseMation().get("discountPercent").toString();
|
||||
// 百分比的折后价
|
||||
String percentPrice = CalculationUtil.multiply(orderItem.getPrice(), discountPercentInt, CommonNumConstants.NUM_SIX);
|
||||
// 百分比折扣的优惠价格
|
||||
String percentDiscountPrice = CalculationUtil.subtract(orderItem.getPrice(), percentPrice, CommonNumConstants.NUM_SIX);
|
||||
// 折扣上限
|
||||
String discountLimitPrice = orderItem.getCouponUseMation().get("discountLimitPrice").toString();
|
||||
// 折扣上限的折后价
|
||||
String limitPrice = CalculationUtil.multiply(orderItem.getPrice(), discountLimitPrice, CommonNumConstants.NUM_SIX);
|
||||
// 是否超过折扣上限
|
||||
boolean priceCompare = CalculationUtil.getMax(percentDiscountPrice, discountLimitPrice, CommonNumConstants.NUM_SIX).equals(percentDiscountPrice);
|
||||
// 设置应支付<EFBFBD><EFBFBD><EFBFBD>格和优惠价格
|
||||
if (priceCompare) { // 未超过优惠价
|
||||
orderItem.setPayPrice(percentPrice);
|
||||
orderItem.setCouponPrice(percentDiscountPrice);
|
||||
} else {// 超过优惠价
|
||||
orderItem.setPayPrice(limitPrice);
|
||||
orderItem.setCouponPrice(discountLimitPrice);
|
||||
}
|
||||
}
|
||||
setLastValue(order, orderItem);// 总单商品数量、子单状态、总单原价、总单应付金额
|
||||
String price = CalculationUtil.multiply(String.valueOf(orderItem.getCount()), salePrice, CommonNumConstants.NUM_SIX);
|
||||
orderItem.setPrice(price);
|
||||
orderItem.setPayPrice(price);
|
||||
orderItem.setDiscountPrice("0");
|
||||
// 总单商品数量、子单状态、总单原价、总单应付金额
|
||||
order.setCount(order.getCount() + orderItem.getCount());
|
||||
orderItem.setCommentState(ShopOrderCommentState.UNFINISHED.getKey());
|
||||
order.setTotalPrice(CalculationUtil.add(order.getTotalPrice(), orderItem.getPrice(), CommonNumConstants.NUM_SIX));
|
||||
order.setPayPrice(CalculationUtil.add(order.getPayPrice(), orderItem.getPayPrice(), CommonNumConstants.NUM_SIX));
|
||||
}
|
||||
}
|
||||
|
||||
public void setLastValue(Order order, OrderItem orderItem) {
|
||||
order.setCount(order.getCount() + orderItem.getCount());
|
||||
orderItem.setCommentState(ShopOrderCommentState.UNFINISHED.getKey());
|
||||
order.setTotalPrice(CalculationUtil.add(order.getTotalPrice(), orderItem.getPrice(), CommonNumConstants.NUM_SIX));
|
||||
order.setPayPrice(CalculationUtil.add(order.getPayPrice(), orderItem.getPayPrice(), CommonNumConstants.NUM_SIX));
|
||||
}
|
||||
|
||||
private void checkAndSetOrderCouponUse(Order order) {// 总单的优惠券处理
|
||||
|
||||
checkCouponUseMaterial(order);// 将总单的couponUserId赋值到对应子单
|
||||
}
|
||||
|
||||
private void checkAndSetDeliveryPrice(Order order) {
|
||||
|
@ -214,51 +167,80 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
|
||||
private void checkCouponUseMaterial(Order order) {
|
||||
String couponUseId = order.getCouponUseId();//优惠券id
|
||||
double totalPrice = Integer.parseInt(order.getTotalPrice());//总单原价
|
||||
double totalPrice = Double.parseDouble(order.getTotalPrice());//总单原价
|
||||
if (StrUtil.isEmpty(couponUseId)) {//没有使用优惠券
|
||||
return;
|
||||
}
|
||||
List<OrderItem> orderItemList = order.getOrderItemList();//子单列表
|
||||
|
||||
CouponUse couponUse = couponUseService.selectById(couponUseId);//优惠券信息
|
||||
if (ObjectUtil.isEmpty(couponUse)) {
|
||||
throw new CustomException("优惠券不存在");
|
||||
} else if (couponUse.getState() != CouponUseState.UNUSED.getKey()) {
|
||||
throw new CustomException("该优惠券已使用或已过期");
|
||||
} else if (Double.parseDouble(couponUse.getUsePrice()) > totalPrice) {
|
||||
throw new CustomException("优惠券不满足使用金额");
|
||||
}
|
||||
List<OrderItem> orderItemList = order.getOrderItemList();//子单列表
|
||||
OrderItem orderItem = null;//优惠券使用商品
|
||||
if (Objects.equals(couponUse.getProductScope(), PromotionMaterialScope.ALL.getKey())) {// 全部商品
|
||||
if (Objects.equals(couponUse.getDiscountType(), PromotionDiscountType.PERCENT.getKey())) {// 百分比折扣
|
||||
orderItem = orderItemList.stream().max(Comparator.comparing(OrderItem::getPrice)).orElse(null);// 获取优惠券使用商品列表中,价格最高的商品
|
||||
} else {// 满减 将优惠券使用到第一个商品
|
||||
double usePrice = Integer.parseInt(couponUse.getUsePrice());//优惠券使用金额
|
||||
if (totalPrice >= usePrice) {//商品价格大于等于优惠券使用金额
|
||||
Optional<OrderItem> maxPriceItem = orderItemList.stream()
|
||||
.max(Comparator.comparing(OrderItem::getPrice));//获取优惠券使用商品列表中,价格最高的商品
|
||||
int index = maxPriceItem
|
||||
.map(item -> orderItemList.indexOf(item))
|
||||
.orElse(-1);//获取最高价格商品在子单列表中的索引
|
||||
orderItemList.get(index).setCouponUseId(couponUseId);
|
||||
orderItemList.get(index).setCouponUseMation(JSONUtil.toBean(JSONUtil.toJsonStr(couponUse), null));// 设置mation方便后续计算价格
|
||||
return;
|
||||
} else {
|
||||
throw new CustomException("商品价格不足以使用优惠券");
|
||||
}
|
||||
}
|
||||
orderItem = orderItemList.stream().max(Comparator.comparing(OrderItem::getPrice)).orElse(null);// 获取优惠券使用商品列表中,价格最高的商品
|
||||
setOrderAndOrderItem(couponUse, order, orderItem);// 操作订单和子单的优惠券
|
||||
} else if (Objects.equals(couponUse.getProductScope(), PromotionMaterialScope.SPU.getKey())) {// 指定商品
|
||||
List<String> couponUseMaterialIds = couponUseMaterialService.queryListByCouponIds(Collections.singletonList(couponUseId))
|
||||
.stream().map(CouponUseMaterial::getMaterialId).collect(Collectors.toList());// 收集子单商品id
|
||||
.stream().map(CouponUseMaterial::getMaterialId).collect(Collectors.toList());// 收集子单商品id
|
||||
List<OrderItem> newOrderItemList = new ArrayList<>();
|
||||
for (OrderItem item : orderItemList) {
|
||||
for (OrderItem item : orderItemList) {// 筛选出优惠券可用的商品
|
||||
if (couponUseMaterialIds.contains(item.getMaterialId())) {
|
||||
newOrderItemList.add(item);
|
||||
}
|
||||
}
|
||||
orderItem = newOrderItemList.stream().max(Comparator.comparing(OrderItem::getPrice)).orElse(null);// 获取优惠券使用商品列表中,价格最高的商品
|
||||
}
|
||||
if (orderItem == null) {
|
||||
throw new CustomException("优惠券没有匹配的商品");
|
||||
}
|
||||
for (OrderItem item : orderItemList) {
|
||||
if (item.getId().equals(orderItem.getId())) {
|
||||
item.setCouponUseId(couponUseId);
|
||||
item.setCouponUseMation(JSONUtil.toBean(JSONUtil.toJsonStr(couponUse), null));// 设置mation方便后续计算价格
|
||||
if (CollectionUtil.isEmpty(newOrderItemList)) {
|
||||
throw new CustomException("商品列表不存在满足优惠券的使用对象");
|
||||
}
|
||||
orderItem = newOrderItemList.stream().max(Comparator.comparing(OrderItem::getPrice)).orElse(null);// 获取优惠券使用商品列表中,价格最高的商品
|
||||
setOrderAndOrderItem(couponUse, order, orderItem);// 操作订单和子单的优惠券
|
||||
}
|
||||
}
|
||||
|
||||
private void setOrderAndOrderItem(CouponUse couponUse, Order order, OrderItem targetOrderItem) {
|
||||
if (Objects.equals(couponUse.getDiscountType(), PromotionDiscountType.PERCENT.getKey())) {// 百分比折扣
|
||||
for (OrderItem item : order.getOrderItemList()) {// 找到目标子单
|
||||
if (item.getId().equals(targetOrderItem.getId())) {
|
||||
item.setCouponUseId(order.getCouponUseId());
|
||||
// 操作优惠券
|
||||
String discountPercentInt = CalculationUtil.divide(couponUse.getDiscountPercent().toString(), "100", CommonNumConstants.NUM_SIX);
|
||||
// 百分比的折后价
|
||||
String percentPrice = CalculationUtil.multiply(targetOrderItem.getPrice(), discountPercentInt, CommonNumConstants.NUM_SIX);
|
||||
// 百分比折扣的优惠价格
|
||||
String percentDiscountPrice = CalculationUtil.subtract(targetOrderItem.getPrice(), percentPrice, CommonNumConstants.NUM_SIX);
|
||||
// 折扣上限
|
||||
String discountLimitPrice = couponUse.getDiscountLimitPrice();
|
||||
// 折扣上限的折后价
|
||||
String limitPrice = CalculationUtil.subtract(targetOrderItem.getPrice(), discountLimitPrice, CommonNumConstants.NUM_SIX);
|
||||
// 是否超过折扣上限
|
||||
boolean priceCompare = CalculationUtil.getMax(percentDiscountPrice, discountLimitPrice, CommonNumConstants.NUM_SIX).equals(percentDiscountPrice);
|
||||
// 设置应支付价格和优惠价格
|
||||
if (priceCompare) { // 未超过优惠价
|
||||
item.setPayPrice(percentPrice);
|
||||
item.setCouponPrice(percentDiscountPrice);
|
||||
// 修改总单总价
|
||||
order.setPayPrice(CalculationUtil.subtract(order.getPayPrice(), discountPercentInt, CommonNumConstants.NUM_SIX));
|
||||
order.setCouponPrice(percentDiscountPrice);
|
||||
} else {// 超过优惠价
|
||||
item.setPayPrice(limitPrice);
|
||||
item.setCouponPrice(discountLimitPrice);
|
||||
// 修改总单总价
|
||||
order.setPayPrice(CalculationUtil.subtract(order.getPayPrice(), discountLimitPrice, CommonNumConstants.NUM_SIX));
|
||||
order.setCouponPrice(discountLimitPrice);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {// 满减 直接在总单减去价格,子单不做处理
|
||||
String discountPrice = couponUse.getDiscountPrice();
|
||||
// 折后价
|
||||
String afterPrice = CalculationUtil.subtract(order.getTotalPrice(), discountPrice, CommonNumConstants.NUM_SIX);
|
||||
order.setPayPrice(afterPrice);
|
||||
order.setCouponPrice(discountPrice);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,33 +276,33 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
break;
|
||||
case "2": // 待收货
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.UNDELIVERED.getKey(),// 待发货
|
||||
ShopOrderState.DELIVERED.getKey(), // 已发货
|
||||
ShopOrderState.TRANSPORTING.getKey()});//运输中
|
||||
ShopOrderState.UNDELIVERED.getKey(),// 待发货
|
||||
ShopOrderState.DELIVERED.getKey(), // 已发货
|
||||
ShopOrderState.TRANSPORTING.getKey()});//运输中
|
||||
break;
|
||||
case "3":// 已完成
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.SIGN.getKey(), // 已签收
|
||||
ShopOrderState.COMPLETED.getKey(), // 已完成
|
||||
ShopOrderState.UNEVALUATE.getKey(), // 待评价
|
||||
ShopOrderState.EVALUATED.getKey()});// 已评价
|
||||
ShopOrderState.SIGN.getKey(), // 已签收
|
||||
ShopOrderState.COMPLETED.getKey(), // 已完成
|
||||
ShopOrderState.UNEVALUATE.getKey(), // 待评价
|
||||
ShopOrderState.EVALUATED.getKey()});// 已评价
|
||||
break;
|
||||
case "4":// 已取消
|
||||
stateList = Arrays.asList(new Integer[]{ShopOrderState.CANCELED.getKey()});
|
||||
break;
|
||||
case "5":// 处理中
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.REFUNDING.getKey(), // 退款中
|
||||
ShopOrderState.REFUNDING.getKey(), // 退款中
|
||||
|
||||
ShopOrderState.SALESRETURNING.getKey(),//退货中
|
||||
ShopOrderState.SALESRETURNING.getKey(),//退货中
|
||||
|
||||
ShopOrderState.EXCHANGEING.getKey()});//换货中
|
||||
ShopOrderState.EXCHANGEING.getKey()});//换货中
|
||||
break;
|
||||
case "6": // 申请记录
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.REFUND.getKey(), // 已退款
|
||||
ShopOrderState.SALESRETURNED.getKey(),//已退货
|
||||
ShopOrderState.EXCHANGED.getKey()});//已换货
|
||||
ShopOrderState.REFUND.getKey(), // 已退款
|
||||
ShopOrderState.SALESRETURNED.getKey(),//已退货
|
||||
ShopOrderState.EXCHANGED.getKey()});//已换货
|
||||
}
|
||||
QueryWrapper<Order> wrapper = super.getQueryWrapper(commonPageInfo);
|
||||
if (CollectionUtil.isNotEmpty(stateList)) { // 状态列表为空时,则查询全部订单
|
||||
|
@ -357,31 +339,31 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
break;
|
||||
case "2": // 待收货
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.UNDELIVERED.getKey(),// 待发货
|
||||
ShopOrderState.DELIVERED.getKey(), // 已发货
|
||||
ShopOrderState.TRANSPORTING.getKey()});//运输中
|
||||
ShopOrderState.UNDELIVERED.getKey(),// 待发货
|
||||
ShopOrderState.DELIVERED.getKey(), // 已发货
|
||||
ShopOrderState.TRANSPORTING.getKey()});//运输中
|
||||
break;
|
||||
case "3":// 已完成
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.SIGN.getKey(), // 已签收
|
||||
ShopOrderState.COMPLETED.getKey(), // 已完成
|
||||
ShopOrderState.UNEVALUATE.getKey(), // 待评价
|
||||
ShopOrderState.EVALUATED.getKey()});// 已评价
|
||||
ShopOrderState.SIGN.getKey(), // 已签收
|
||||
ShopOrderState.COMPLETED.getKey(), // 已完成
|
||||
ShopOrderState.UNEVALUATE.getKey(), // 待评价
|
||||
ShopOrderState.EVALUATED.getKey()});// 已评价
|
||||
break;
|
||||
case "4":// 已取消
|
||||
stateList = Arrays.asList(new Integer[]{ShopOrderState.CANCELED.getKey()});
|
||||
break;
|
||||
case "5":// 处理中
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.REFUNDING.getKey(), // 退款中
|
||||
ShopOrderState.SALESRETURNING.getKey(),//退货中
|
||||
ShopOrderState.EXCHANGEING.getKey()});//换货中
|
||||
ShopOrderState.REFUNDING.getKey(), // 退款中
|
||||
ShopOrderState.SALESRETURNING.getKey(),//退货中
|
||||
ShopOrderState.EXCHANGEING.getKey()});//换货中
|
||||
break;
|
||||
case "6": // 申请记录
|
||||
stateList = Arrays.asList(new Integer[]{
|
||||
ShopOrderState.REFUND.getKey(), // 已退款
|
||||
ShopOrderState.SALESRETURNED.getKey(),//已退货
|
||||
ShopOrderState.EXCHANGED.getKey()});//已换货
|
||||
ShopOrderState.REFUND.getKey(), // 已退款
|
||||
ShopOrderState.SALESRETURNED.getKey(),//已退货
|
||||
ShopOrderState.EXCHANGED.getKey()});//已换货
|
||||
}
|
||||
QueryWrapper<Order> wrapper = new QueryWrapper<>();
|
||||
if (CollectionUtil.isNotEmpty(stateList)) { // 状态列表为空时,则查询全部订单
|
||||
|
@ -489,9 +471,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
}
|
||||
// 可取消的订单状态:未提交(0)、已提交(1)、待支付(2)、待发货(5)
|
||||
if (Objects.equals(one.getState(), ShopOrderState.UNSUBMIT.getKey()) ||
|
||||
Objects.equals(one.getState(), ShopOrderState.SUBMIT.getKey()) ||
|
||||
Objects.equals(one.getState(), ShopOrderState.UNPAID.getKey()) ||
|
||||
Objects.equals(one.getState(), ShopOrderState.UNDELIVERED.getKey())) {
|
||||
Objects.equals(one.getState(), ShopOrderState.SUBMIT.getKey()) ||
|
||||
Objects.equals(one.getState(), ShopOrderState.UNPAID.getKey()) ||
|
||||
Objects.equals(one.getState(), ShopOrderState.UNDELIVERED.getKey())) {
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getState), ShopOrderState.CANCELED.getKey());
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getCancelType), params.get("cancelType"));
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString());
|
||||
|
@ -546,7 +528,7 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getPayTime), payOrderRespDTO.get("successTime").toString());
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getChannelFeeRate), payChannel.get("feeRate").toString());
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getChannelFeePrice), CalculationUtil.multiply(
|
||||
one.getPayPrice(), payChannel.get("feeRate").toString()));
|
||||
one.getPayPrice(), payChannel.get("feeRate").toString()));
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getExtensionId), payOrderRespDTO.get("id").toString());
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getExtensionNo), payOrderRespDTO.get("no").toString());
|
||||
update(updateWrapper);
|
||||
|
@ -603,34 +585,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl<OrderDao, Order>
|
|||
UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq(CommonConstants.ID, orderId);
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getState), ShopOrderState.CANCELED.getKey())
|
||||
.set(MybatisPlusUtil.toColumns(Order::getCancelType), ShopOrderCancelType.PAY_TIMEOUT.getKey())
|
||||
.set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString());
|
||||
.set(MybatisPlusUtil.toColumns(Order::getCancelType), ShopOrderCancelType.PAY_TIMEOUT.getKey())
|
||||
.set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString());
|
||||
update(updateWrapper);
|
||||
refreshCache(orderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrderItemState(InputObject inputObject, OutputObject outputObject) {
|
||||
Map<String, Object> map = inputObject.getParams();
|
||||
String orderId = map.get("id").toString();
|
||||
String orderItemId = map.get("orderItemId").toString();
|
||||
orderItemService.UpdateOrderItemState(orderItemId);
|
||||
List<OrderItem> orderItemList = orderItemService.queryOrderItemByParentId(orderId);
|
||||
boolean allTwo = orderItemList.stream().map(OrderItem::getOrderItemState)
|
||||
.allMatch(orderItemState -> orderItemState == CommonNumConstants.NUM_TWO);
|
||||
if (allTwo) {
|
||||
Integer numThree = CommonNumConstants.NUM_THREE;
|
||||
updateOrderState(orderId, numThree);
|
||||
} else {
|
||||
Integer numTwo = CommonNumConstants.NUM_TWO;
|
||||
updateOrderState(orderId, numTwo);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOrderState(String orderId, Integer orderState) {
|
||||
UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq(CommonConstants.ID, orderId);
|
||||
updateWrapper.set(MybatisPlusUtil.toColumns(Order::getOrderState), orderState);
|
||||
update(updateWrapper);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue