修改bug

This commit is contained in:
2025-02-28 16:15:03 +08:00
parent d64f5b4bbb
commit 412c017c96
8 changed files with 361 additions and 318 deletions

View File

@@ -29,4 +29,6 @@ public interface OmsOrderItemMapper {
int updateByPrimaryKey(OmsOrderItem record);
OmsOrderItem selectByOrderId(Long orderId);
OmsOrderItem getByOrderSn(String orderSn);
}

View File

@@ -33,4 +33,5 @@ public interface OmsOrderMapper {
int updateByPrimaryKey(OmsOrder record);
PmsProduct selectAll(@Param("orderSn") String orderSn);}
PmsProduct selectAll(@Param("orderSn") String orderSn);
}

View File

@@ -361,6 +361,11 @@ public class UmsMemberAccountTransactionExample {
return (Criteria) this;
}
public Criteria andFlowTypeEqualTo(Integer value) {
addCriterion("flow_type =", value, "flowType");
return (Criteria) this;
}
public Criteria andTransactionStateNotEqualTo(Integer value) {
addCriterion("transaction_state <>", value, "transactionState");
return (Criteria) this;

View File

@@ -513,4 +513,34 @@
select * from mall.oms_order_item where order_id = #{orderId}
</select>
<select id="getByOrderSn" resultType="com.buy507.mall.model.OmsOrderItem">
select id,
order_id,
order_sn,
product_id,
product_pic,
product_name,
product_brand,
product_sn,
product_price,
product_quantity,
product_sku_id,
product_sku_code,
product_category_id,
promotion_name,
promotion_amount,
coupon_amount,
integration_amount,
real_amount,
gift_integration,
gift_growth,
product_attr,
sp1,
sp2,
sp3,
intergrationPrice,
intergrationExchange
from oms_order_item
where order_sn = #{orderSn}
</select>
</mapper>

View File

@@ -926,4 +926,5 @@
JOIN oms_order o ON oi.order_sn = o.order_sn
WHERE o.order_sn = #{orderSn}
</select>
<select id="getPnameByOrderSn" resultType="java.lang.String"></select>
</mapper>

View File

@@ -336,39 +336,39 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
OrderResult orderResult = new OrderResult();
OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
//删除状态0->未删除1->已删除
if(order != null && order.getMemberId().equals(loginMember.getId()) && order.getDeleteStatus() == 0) {
if (order != null && order.getMemberId().equals(loginMember.getId()) && order.getDeleteStatus() == 0) {
orderResult.setOrderId(order.getId());
orderResult.setOrderSn(order.getOrderSn());
orderResult.setCreateTime(order.getCreateTime());
orderResult.setPayAmount(order.getPayAmount());
orderResult.setOrderStatus(order.getStatus());
orderResult.setDeliveryType(order.getDeliveryType());
if(order.getStatus() == 0) {
if (order.getStatus() == 0) {
orderResult.setOrderStatusName("待付款");
if(order.getPayType() != null && order.getPayType() == 3) {
if (order.getPayType() != null && order.getPayType() == 3) {
orderResult.setOrderStatusName("已付款待审核");
}
}
if(order.getStatus() == 1) {
if (order.getStatus() == 1) {
orderResult.setOrderStatusName("待发货");
}
if(order.getStatus() == 2) {
if (order.getStatus() == 2) {
// 提货方式0->自提1->物流
if(order.getDeliveryType() == 0) {
if (order.getDeliveryType() == 0) {
orderResult.setOrderStatusName("待提货");
} else {
orderResult.setOrderStatusName("待收货");
}
}
if(order.getStatus() == 3) {
if (order.getStatus() == 3) {
orderResult.setOrderStatusName("交易完成");
if(order.getCommentTime() == null) {
if (order.getCommentTime() == null) {
orderResult.setCommentStatus(0); //未评价
} else {
orderResult.setCommentStatus(1); //已评价
}
}
if(order.getStatus() == 4) {
if (order.getStatus() == 4) {
orderResult.setOrderStatusName("交易关闭");
orderResult.setOrderStatus(4);
}
@@ -387,14 +387,14 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
//支付类型: 0->未支付1->支付宝2->微信; 3->线下支付; 4->积分支付
//判断是否为积分专区商品
if(isPointsExchangeStatus) {
if (isPointsExchangeStatus) {
orderResult.setIntergrationPrice(product.getIntergrationPrice());
orderResult.setIntergrationExchange(product.getPointsExchangeStatus());
orderResult.setPayType(order.getPayType());
if (order.getPayType() == 0) {
orderResult.setPayTypeName("未支付");
}
}else {
} else {
// 如果不是积分兑换专区商品,则继续使用其他支付方式
if (order.getPayType() != null) {
orderResult.setPayType(order.getPayType());
@@ -433,11 +433,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderResult.setOrderStatus(0);
//0->不开发票1->电子发票2->纸质发票
if(order.getBillType() != null) {
if (order.getBillType() != null) {
orderResult.setBillType(order.getBillType());
if(order.getBillType() == 1) {
if (order.getBillType() == 1) {
orderResult.setBillTypeName("电子发票");
} else if(order.getBillType() == 2) {
} else if (order.getBillType() == 2) {
orderResult.setBillTypeName("纸质发票");
} else {
orderResult.setBillTypeName("不开发票");
@@ -463,7 +463,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
OrderItemResult orderItemResult = null;
orderResult.setProductsNum(orderItemList.size());
List<OrderItemResult> orderItemResultList = new ArrayList<>();
for(OmsOrderItem orderItem : orderItemList) {
for (OmsOrderItem orderItem : orderItemList) {
orderItemResult = new OrderItemResult();
orderItemResult.setOrderId(order.getId());
orderItemResult.setOrderSn(order.getOrderSn());
@@ -752,30 +752,30 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
*/
public CommonResult createOrder(OrderParam orderParam) {
//orderParam.setSkuId(98L);
if(orderParam.getSkuId() == null) {
if (orderParam.getSkuId() == null) {
return CommonResult.validateFailed("商品SKU不能为空");
}
if(orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1) ) {
if (orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1)) {
return CommonResult.validateFailed("提货方式不能为空");
}
if(orderParam.getMemberReceiveAddressId() == null) {
if (orderParam.getMemberReceiveAddressId() == null) {
return CommonResult.validateFailed("会员收货地址不能为空");
}
UmsMemberReceiveAddress address = memberReceiveAddressMapper.selectOneById(orderParam.getMemberReceiveAddressId());
if(address == null) {
if (address == null) {
return CommonResult.validateFailed("未查询到会员收货地址");
}
if(orderParam.getQuantity() == null) {
if (orderParam.getQuantity() == null) {
return CommonResult.validateFailed("商品数量不能为空");
}
if(orderParam.getQuantity() <= 0) {
if (orderParam.getQuantity() <= 0) {
return CommonResult.validateFailed("商品数量错误");
}
PmsSkuStock skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId());
if(skuStock == null) {
if (skuStock == null) {
return CommonResult.validateFailed("未查询到商品信息");
}
@@ -801,12 +801,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
}
Map<String, Object> result = new HashMap<>();
if(product != null) {
if (product != null) {
UmsMember member = memberMapper.selectByPrimaryKey(memberService.getCurrentMember().getId());
BigDecimal discount = commonService.getDiscount(member.getId());
if(discount != null) {
if (discount != null) {
price = skuStock.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
}
@@ -814,7 +814,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
BigDecimal zero = new BigDecimal(0);
totalAmount = price.multiply(new BigDecimal(orderParam.getQuantity()));
if(orderParam.getIntegration() == null) {
if (orderParam.getIntegration() == null) {
orderParam.setIntegration(zero);
}
@@ -823,7 +823,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
//flag = -1,表示integration小于0flag = 0,表示integration等于0flag = 1,表示integration大于0
//int integerationFlag = orderParam.getIntegration().compareTo(new BigDecimal(0)); //mcoo
int integerationFlag = 0;
if(integerationFlag == 1) {
if (integerationFlag == 1) {
int flag = member.getBalance().compareTo(orderParam.getIntegration());
//flag = -1,表示balance小于integrationflag = 0,表示balance等于integrationflag = 1,表示balance大于integration
/*if(flag == -1) {
@@ -831,9 +831,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
}*/
}
while(true) {
while (true) {
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
if(redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) {
if (redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) {
//重新查询获取最新的数据
skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId());
@@ -856,13 +856,13 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order.setTotalAmount(totalAmount); // 订单总金额
order.setIntegrationAmount(zero); // 积分部分金额设为零
order.setIntegrationAmount(orderParam.getIntegration() == null ? zero : orderParam.getIntegration());
if(integerationFlag == 1) {
if (integerationFlag == 1) {
int flag = orderParam.getIntegration().compareTo(totalAmount);
BigDecimal integeration = new BigDecimal(0);
//flag = -1,表示integration小于totalAmountflag = 0,表示integration等于totalAmountflag = 1,表示integration大于totalAmount
//如果传入的积分小于实际支付金额,用实际支付金额减去抵扣积分。
//如果传入的积分等于或者大于实际支付金额,表示全额抵扣
if(flag == -1) {
if (flag == -1) {
order.setPayAmount(totalAmount.subtract(orderParam.getIntegration())); //实际支付金额
order.setIntegrationAmount(orderParam.getIntegration());
integeration = orderParam.getIntegration();
@@ -1361,7 +1361,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
// 判断是否使用积分支付
UmsMember member = memberMapper.selectByPrimaryKey(currentMember.getId());
if(product1.getPointsExchangeStatus() == 1) {
if (product1.getPointsExchangeStatus() == 1) {
// 获取积分兑换价格
// 使用订单中的积分字段
@@ -1411,7 +1411,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
accountTransaction.setTransferPaymentTime(order.getPaymentTime());
accountTransaction.setRevenuePoints(-totalPointsAmount.intValue());
PmsProduct pmsProduct = orderMapper.selectAll(order.getOrderSn());
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
accountTransaction.setRemarks("商品名称" + pmsProduct.getName());
umsMemberAccountTransactionMapper.insert(accountTransaction);
// 返还积分金额到前端
@@ -1573,10 +1573,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
accountTransaction.setFlowType(1);
accountTransaction.setTransferPaymentTime(orderResult.getPaymentTime());
accountTransaction.setRevenueAmount(payAmount.negate());
PmsProduct pmsProduct = orderMapper.selectAll(orderResult.getOrderSn());
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
OmsOrderItem orderItem = orderItemMapper.getByOrderSn(orderResult.getOrderSn());
accountTransaction.setRemarks("商品名称" + orderItem.getProductName());
umsMemberAccountTransactionMapper.insert(accountTransaction);
PmsProduct pmsProduct = orderMapper.selectAll(orderResult.getOrderSn());
//如果是积分专区的商品则进行积分专区相对应的逻辑
if (pmsProduct.getPointsAreaStatus() == 1) {
//奖励积分是购买的价格的100%
@@ -1593,7 +1594,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
// 更新用户积分
memberMapper.updateByPrimaryKey(member);
//增加基金积分
int fundPoints = (int)(rewardPoints * 0.05);
int fundPoints = (int) (rewardPoints * 0.05);
umsDevelopmentFundMapper.updatePoints(fundPoints);
//插入流水表积分
UmsMemberAccountTransaction transaction = new UmsMemberAccountTransaction();
@@ -1602,7 +1603,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
transaction.setFlowType(2);
transaction.setTransferPaymentTime(orderResult.getPaymentTime());
transaction.setRevenuePoints(rewardPoints);
transaction.setRemarks( "购买商品返还积分:" + pmsProduct.getName());
transaction.setRemarks("购买商品返还积分:" + pmsProduct.getName());
umsMemberAccountTransactionMapper.insert(transaction);
}
}
@@ -1615,8 +1616,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order.setStatus(2);
order.setPaymentTime(new Date());
orderMapper.updateByPrimaryKey(order);
if (pmsProduct.getPointsAreaStatus() == 1) {
//积分分润逻辑
memberPointsSplitProfitService.pointsSplit(order);
}
// 处理库存、分销等后续操作
executorService.execute(() -> {
@@ -1628,7 +1631,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
}
/**
*处理库存的逻辑
* 处理库存的逻辑
*/
private void updateStock(Long orderId) {
// 查询订单商品信息,进行库存更新等操作
@@ -1646,8 +1649,6 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
}
/**
* 微信预支付
*
@@ -2061,7 +2062,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
// 更新用户积分
memberMapper.updateByPrimaryKey(member);
//增加基金积分
int fundPoints = (int)(rewardPoints * 0.05);
int fundPoints = (int) (rewardPoints * 0.05);
umsDevelopmentFundMapper.updatePoints(fundPoints);
//插入流水表积分
@@ -2071,7 +2072,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
accountTransaction.setFlowType(2);
accountTransaction.setTransferPaymentTime(order.getPaymentTime());
accountTransaction.setRevenuePoints(rewardPoints);
accountTransaction.setRemarks( "购买商品返还积分:" + pmsProduct.getName());
accountTransaction.setRemarks("购买商品返还积分:" + pmsProduct.getName());
umsMemberAccountTransactionMapper.insert(accountTransaction);
//积分分润逻辑

View File

@@ -529,6 +529,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
BigDecimal totalIncome = BigDecimal.ZERO;
accountTransactionExample.createCriteria()
.andTransactionStateEqualTo(UmsMemberAccountTransaction.TRANSACTION_STATE_YES)
.andFlowTypeEqualTo(1)
.andMemberIdEqualTo(member.getId());
List<UmsMemberAccountTransaction> totalList = umsMemberAccountTransactionMapper.selectByExample(accountTransactionExample);
@@ -546,6 +547,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
accountTransactionExample.createCriteria()
.andTransferPaymentTimeBetween(DateUtil.beginOfDay(nowTime) ,nowTime)
.andTransactionStateEqualTo(UmsMemberAccountTransaction.TRANSACTION_STATE_YES)
.andFlowTypeEqualTo(1)
.andMemberIdEqualTo(member.getId());
List<UmsMemberAccountTransaction> todayIncomeList = umsMemberAccountTransactionMapper.selectByExample(accountTransactionExample);
if(todayIncomeList!= null && !todayIncomeList.isEmpty()){

View File

@@ -83,6 +83,7 @@ public class VipCenterServiceImpl implements VipCenterService {
//返回订单id
Map<String, Object> result = new HashMap<>();
result.put("orderId", order.getId());
result.put("orderType", order.getOrderType());
return CommonResult.success(result, "下单成功");
}
}