|
|
@@ -28,7 +28,6 @@ import com.kxmall.notify.MemberNotifyBizService;
|
|
|
import com.kxmall.order.biz.*;
|
|
|
import com.kxmall.order.biz.common.DeliveryResult;
|
|
|
import com.kxmall.order.domain.*;
|
|
|
-import com.kxmall.order.domain.bo.KxProsuctParam;
|
|
|
import com.kxmall.order.domain.bo.KxStoreOrderBo;
|
|
|
import com.kxmall.order.domain.bo.OrderMessageBO;
|
|
|
import com.kxmall.order.domain.bo.RiderProductBO;
|
|
|
@@ -48,7 +47,6 @@ import com.kxmall.user.mapper.KxUserMapper;
|
|
|
import com.kxmall.web.controller.order.service.IKxStoreOrderService;
|
|
|
import com.kxmall.web.controller.user.service.IKxUserService;
|
|
|
import com.kxmall.wechat.WxPayConfiguration;
|
|
|
-import com.thoughtworks.xstream.core.SecurityUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -123,16 +121,16 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
String payTypeName = OrderUtil.payTypeName(kxStoreOrderVo.getPayChannel(), 1);
|
|
|
kxStoreOrderVo.setPayTypeName(payTypeName);
|
|
|
|
|
|
- //新增记录产品详情
|
|
|
+ // 新增记录产品详情
|
|
|
kxStoreOrderVo.setProductList(orderProductMapper.selectVoList(new LambdaQueryWrapper<KxStoreOrderProduct>().eq(KxStoreOrderProduct::getOrderId, kxStoreOrderVo.getId())));
|
|
|
|
|
|
- //添加用户信息
|
|
|
+ // 添加用户信息
|
|
|
kxStoreOrderVo.setKxUserVo(kxUserService.selectByUid(kxStoreOrderVo.getUid()));
|
|
|
if (kxStoreOrderVo.getKxUserVo() == null) {
|
|
|
kxStoreOrderVo.setKxUserVo(new KxUserVo());
|
|
|
}
|
|
|
|
|
|
- //放一下订单信息
|
|
|
+ // 放一下订单信息
|
|
|
kxStoreOrderVo.setRiderOrder(orderRiderBizService.queryByOrderId(kxStoreOrderVo.getOrderId()));
|
|
|
|
|
|
KxRiderVo riderVo = riderMapper.selectVoById(kxStoreOrderVo.getPostId());
|
|
|
@@ -153,10 +151,10 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
String payTypeName = OrderUtil.payTypeName(kxStoreOrderVo.getPayChannel(), 1);
|
|
|
kxStoreOrderVo.setPayTypeName(payTypeName);
|
|
|
|
|
|
- //新增记录产品详情
|
|
|
+ // 新增记录产品详情
|
|
|
kxStoreOrderVo.setProductList(orderProductMapper.selectVoList(new LambdaQueryWrapper<KxStoreOrderProduct>().eq(KxStoreOrderProduct::getOrderId, kxStoreOrderVo.getId())));
|
|
|
|
|
|
- //添加用户信息
|
|
|
+ // 添加用户信息
|
|
|
kxStoreOrderVo.setKxUserVo(kxUserService.selectByUid(kxStoreOrderVo.getUid()));
|
|
|
if (kxStoreOrderVo.getKxUserVo() == null) {
|
|
|
kxStoreOrderVo.setKxUserVo(new KxUserVo());
|
|
|
@@ -308,7 +306,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
private void validEntityBeforeSave(KxStoreOrder entity) {
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
+ // TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -317,7 +315,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
if (isValid) {
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ // TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
}
|
|
|
@@ -332,7 +330,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
if (ObjectUtil.isNull(storeOrder)) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
- //通知会员开始配货
|
|
|
+ // 通知会员开始配货
|
|
|
GlobalExecutor.execute(() -> {
|
|
|
memberNotifyBizService.newOrder(storeOrder);
|
|
|
});
|
|
|
@@ -347,11 +345,11 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
|
|
|
@Override
|
|
|
public Boolean merchantDistribution(Long id) {
|
|
|
- //判断一下如果正在第三方配置,就不能点击系统配送,以免重复
|
|
|
+ // 判断一下如果正在第三方配置,就不能点击系统配送,以免重复
|
|
|
Long count = orderDeliveryMapper.selectCount(new LambdaQueryWrapper<KxOrderDelivery>()
|
|
|
.eq(KxOrderDelivery::getOrderId, id)
|
|
|
.eq(KxOrderDelivery::getIsDelete, 0));
|
|
|
- if (count>0L) {
|
|
|
+ if (count > 0L) {
|
|
|
throw new ServiceException("已发起第三方配送,无法再次发起商家配送");
|
|
|
}
|
|
|
return this.updateOrderStatus(id, OrderStatusType.WAIT_CONFIRM.getCode(), OrderStatusType.WAIT_STOCK.getCode());
|
|
|
@@ -365,17 +363,17 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
throw new ServiceException("状态不是待收货,请刷新后操作!");
|
|
|
}
|
|
|
this.updateOrderStatus(id, OrderStatusType.WAIT_APPRAISE.getCode(), OrderStatusType.WAIT_CONFIRM.getCode());
|
|
|
- //积分发放
|
|
|
+ // 积分发放
|
|
|
this.pointRelease(kxStoreOrder);
|
|
|
|
|
|
- //分销计算
|
|
|
+ // 分销计算
|
|
|
if (kxStoreOrder.getBargainId() == 0 &&
|
|
|
kxStoreOrder.getCombinationId() == 0
|
|
|
&& kxStoreOrder.getSeckillId() == 0) {
|
|
|
orderBizService.backOrderBrokerage(kxStoreOrder);
|
|
|
}
|
|
|
|
|
|
- //通知会员完成订单
|
|
|
+ // 通知会员完成订单
|
|
|
GlobalExecutor.execute(() -> {
|
|
|
memberNotifyBizService.completeOrder(kxStoreOrder);
|
|
|
});
|
|
|
@@ -387,23 +385,22 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
if (orderDO.getGainIntegral().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
KxUser user = userMapper.selectById(orderDO.getUid());
|
|
|
|
|
|
- //用户积分添加
|
|
|
+ // 用户积分添加
|
|
|
BigDecimal newIntegral = NumberUtil.add(user.getIntegral(), orderDO.getGainIntegral());
|
|
|
user.setIntegral(newIntegral);
|
|
|
user.setUid(orderDO.getUid());
|
|
|
userMapper.updateById(user);
|
|
|
|
|
|
- //增加流水
|
|
|
+ // 增加流水
|
|
|
billBizService.income(user.getUid(), "购买商品赠送积分", BillDetailEnum.CATEGORY_2.getValue(), BillDetailEnum.TYPE_9.getValue(), orderDO.getGainIntegral().doubleValue(), newIntegral.doubleValue(), "购买商品赠送" + orderDO.getGainIntegral() + "积分", orderDO.getId().toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean distributeOrder(Long orderId, Long riderId) {
|
|
|
+ public Boolean distributeOrder(String orderNo, Long riderId) {
|
|
|
boolean result = false;
|
|
|
try {
|
|
|
-
|
|
|
- List<KxStoreOrder> storeOrders = baseMapper.selectList(new QueryWrapper<KxStoreOrder>().eq("order_id", orderId));
|
|
|
+ List<KxStoreOrder> storeOrders = baseMapper.selectList(new QueryWrapper<KxStoreOrder>().eq("order_id", orderNo));
|
|
|
if (CollectionUtils.isEmpty(storeOrders)) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
@@ -418,20 +415,21 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
throw new ServiceException("仓库信息不存在");
|
|
|
}
|
|
|
|
|
|
- //订单状态不正确,大于40说明订单达到未知状态,即报错
|
|
|
+ // 订单状态不正确,大于40说明订单达到未知状态,即报错
|
|
|
if (orderDO.getStatus() >= 40) {
|
|
|
throw new ServiceException("订单状态更新异常,请检查当前订单真实状态!");
|
|
|
}
|
|
|
|
|
|
- //判断一下如果正在第三方配置,就不能点击系统配送,以免重复
|
|
|
+ // 判断一下如果正在第三方配置,就不能点击系统配送,以免重复
|
|
|
Long count = orderDeliveryMapper.selectCount(new LambdaQueryWrapper<KxOrderDelivery>()
|
|
|
- .eq(KxOrderDelivery::getOrderId, orderId)
|
|
|
+ .eq(KxOrderDelivery::getOrderId, orderNo)
|
|
|
.eq(KxOrderDelivery::getIsDelete, 0));
|
|
|
- if (count>0L) {
|
|
|
+ if (count > 0L) {
|
|
|
throw new ServiceException("已发起第三方配送,无法再次发起系统配送");
|
|
|
}
|
|
|
|
|
|
OrderMessageBO orderMessageBO = new OrderMessageBO();
|
|
|
+ orderMessageBO.setOrderId(orderDO.getId());
|
|
|
orderMessageBO.setOrderNo(orderDO.getOrderId());
|
|
|
orderMessageBO.setStoreName(storageDO.getName());
|
|
|
orderMessageBO.setStorageId(storeId);
|
|
|
@@ -472,7 +470,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
if (riderId == 0) {
|
|
|
updateKxStoreOrder.setStatus(OrderStatusType.WAIT_CONFIRM.getCode());
|
|
|
}
|
|
|
- if (baseMapper.update(updateKxStoreOrder, new QueryWrapper<KxStoreOrder>().eq("order_id", orderId)) > 0) {
|
|
|
+ if (baseMapper.update(updateKxStoreOrder, new QueryWrapper<KxStoreOrder>().eq("order_id", orderNo)) > 0) {
|
|
|
// 发送订单配送信息给骑手端
|
|
|
result = orderRiderBizService.comsumerOderMessageBusiness(orderMessageBO);
|
|
|
}
|
|
|
@@ -489,7 +487,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
@Override
|
|
|
public Boolean completePickup(Long id, String verifyCode) {
|
|
|
KxStoreOrder order;
|
|
|
- //只有核销码
|
|
|
+ // 只有核销码
|
|
|
if (ObjectUtils.isEmpty(id)) {
|
|
|
List<KxStoreOrder> storeOrders = baseMapper.selectList(new QueryWrapper<KxStoreOrder>().eq("verify_code", verifyCode).eq("status", 20));
|
|
|
order = storeOrders.get(0);
|
|
|
@@ -532,12 +530,12 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
|
|
|
BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
int totalFee = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();
|
|
|
- //订单总金额
|
|
|
+ // 订单总金额
|
|
|
wxPayRefundRequest.setTotalFee(totalFee);
|
|
|
wxPayRefundRequest.setOutTradeNo(orderInfo.getOrderId());
|
|
|
- //生成退款单号
|
|
|
+ // 生成退款单号
|
|
|
wxPayRefundRequest.setOutRefundNo("refund_" + orderInfo.getOrderId());
|
|
|
- //退款金额
|
|
|
+ // 退款金额
|
|
|
wxPayRefundRequest.setRefundFee(payPrice);
|
|
|
try {
|
|
|
wxPayService.refund(wxPayRefundRequest);
|
|
|
@@ -577,21 +575,21 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
}
|
|
|
|
|
|
KxStoreOrder storeOrder = KxStoreOrder.builder().build();
|
|
|
- //修改状态
|
|
|
+ // 修改状态
|
|
|
storeOrder.setId(storeOrderVo.getId());
|
|
|
|
|
|
- //根据支付类型不同退款不同
|
|
|
+ // 根据支付类型不同退款不同
|
|
|
if (PayChannelType.BALANCE.getCode().equals(storeOrderVo.getPayChannel())) {
|
|
|
storeOrder.setRefundStatus(2);
|
|
|
storeOrder.setRefundPrice(refundAmount);
|
|
|
baseMapper.updateById(storeOrder);
|
|
|
- //退款到余额
|
|
|
+ // 退款到余额
|
|
|
KxUser user = new KxUser();
|
|
|
user.setNowMoney(kxUser.getNowMoney().add(refundAmount));
|
|
|
user.setUid(storeOrderVo.getUid());
|
|
|
userMapper.updateById(user);
|
|
|
|
|
|
- //增加流水
|
|
|
+ // 增加流水
|
|
|
billBizService.income(storeOrderVo.getUid(), "商品退款", BillDetailEnum.CATEGORY_1.getValue(), BillDetailEnum.TYPE_5.getValue(), refundAmount.doubleValue(), NumberUtil.add(refundAmount, kxUser.getNowMoney()).doubleValue(), "订单退款到余额" + refundAmount + "元", storeOrderVo.getId().toString());
|
|
|
this.returnStock(storeOrderVo.getOrderId());
|
|
|
|
|
|
@@ -674,20 +672,20 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean cancelOrder(Long id,String reason) {
|
|
|
+ public Boolean cancelOrder(Long id, String reason) {
|
|
|
|
|
|
- KxStoreOrder kxStoreOrder = baseMapper.selectOne(new LambdaQueryWrapper<KxStoreOrder>().eq(KxStoreOrder::getId,id));
|
|
|
+ KxStoreOrder kxStoreOrder = baseMapper.selectOne(new LambdaQueryWrapper<KxStoreOrder>().eq(KxStoreOrder::getId, id));
|
|
|
|
|
|
- //商品除去优惠后的总价格
|
|
|
+ // 商品除去优惠后的总价格
|
|
|
BigDecimal totalPrice = BigDecimal.ZERO;
|
|
|
- //拿到所有的商品
|
|
|
+ // 拿到所有的商品
|
|
|
|
|
|
- List<KxStoreOrderProduct> kxStoreOrderProducts = orderProductMapper.selectList(new LambdaQueryWrapper<KxStoreOrderProduct>().eq(KxStoreOrderProduct::getOrderId,kxStoreOrder.getId()));
|
|
|
+ List<KxStoreOrderProduct> kxStoreOrderProducts = orderProductMapper.selectList(new LambdaQueryWrapper<KxStoreOrderProduct>().eq(KxStoreOrderProduct::getOrderId, kxStoreOrder.getId()));
|
|
|
for (KxStoreOrderProduct storeOrderProduct : kxStoreOrderProducts) {
|
|
|
- //商品优惠前总金额
|
|
|
+ // 商品优惠前总金额
|
|
|
// TODO BigDecimal totalAmountOfGoods = NumberUtil.mul(storeOrderProduct.getTruePrice(), storeOrderProduct.getNum());
|
|
|
BigDecimal totalAmountOfGoods = NumberUtil.mul(storeOrderProduct.getPrice(), storeOrderProduct.getNum());
|
|
|
- //商品优惠总金额
|
|
|
+ // 商品优惠总金额
|
|
|
BigDecimal totalPriceMinusPostage = NumberUtil.sub(kxStoreOrder.getTotalPrice(), kxStoreOrder.getPayPostage());
|
|
|
BigDecimal commodityDiscountAmount;
|
|
|
|
|
|
@@ -697,14 +695,14 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
// 处理除数为零的情况,返回默认值
|
|
|
commodityDiscountAmount = BigDecimal.ZERO;
|
|
|
}
|
|
|
- //商品优惠后总金额
|
|
|
+ // 商品优惠后总金额
|
|
|
totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
|
|
|
// todo 根据自己的业务逻辑修改,是否退运费,默认退运费
|
|
|
totalPrice = NumberUtil.add(totalPrice, kxStoreOrder.getPayPostage());
|
|
|
}
|
|
|
|
|
|
|
|
|
- //更新订单状态
|
|
|
+ // 更新订单状态
|
|
|
kxStoreOrder.setStatus(OrderStatusType.REFUNDING.getCode());
|
|
|
kxStoreOrder.setRefundStatus(1);
|
|
|
kxStoreOrder.setRefundReasonWap("商家取消订单");
|
|
|
@@ -712,13 +710,13 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
kxStoreOrder.setRefundReasonTime(new Date());
|
|
|
baseMapper.updateById(kxStoreOrder);
|
|
|
|
|
|
- //生成售后订单
|
|
|
+ // 生成售后订单
|
|
|
KxStoreAfterSales storeAfterSales = new KxStoreAfterSales();
|
|
|
storeAfterSales.setOrderCode(kxStoreOrder.getOrderId());
|
|
|
- //此处需要对比原来订单的支付价格
|
|
|
- if(totalPrice.compareTo(kxStoreOrder.getPayPrice()) > 0){
|
|
|
+ // 此处需要对比原来订单的支付价格
|
|
|
+ if (totalPrice.compareTo(kxStoreOrder.getPayPrice()) > 0) {
|
|
|
storeAfterSales.setRefundAmount(kxStoreOrder.getPayPrice());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
storeAfterSales.setRefundAmount(totalPrice);
|
|
|
}
|
|
|
|
|
|
@@ -732,7 +730,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
storeAfterSales.setIsDel(0);
|
|
|
storeAfterSales.setUserId(kxStoreOrder.getUid());
|
|
|
storeAfterSalesMapper.insert(storeAfterSales);
|
|
|
- //售后商品详情
|
|
|
+ // 售后商品详情
|
|
|
for (KxStoreOrderProduct storeOrderProduct : kxStoreOrderProducts) {
|
|
|
KxStoreAfterSalesItem storeAfterSalesItem = new KxStoreAfterSalesItem();
|
|
|
storeAfterSalesItem.setStoreAfterSalesId(storeAfterSales.getId());
|
|
|
@@ -742,7 +740,7 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
storeAfterSalesItemMapper.insert(storeAfterSalesItem);
|
|
|
}
|
|
|
|
|
|
- //操作记录
|
|
|
+ // 操作记录
|
|
|
KxStoreAfterSalesStatus storeAfterSalesStatus = new KxStoreAfterSalesStatus();
|
|
|
storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId());
|
|
|
storeAfterSalesStatus.setChangeType(0);
|
|
|
@@ -805,15 +803,15 @@ public class KxStoreOrderServiceImpl implements IKxStoreOrderService {
|
|
|
|
|
|
KxUser user = userMapper.selectById(order.getUid());
|
|
|
|
|
|
- //增加积分
|
|
|
+ // 增加积分
|
|
|
BigDecimal newIntegral = NumberUtil.add(order.getUseIntegral(), user.getIntegral());
|
|
|
user.setIntegral(newIntegral);
|
|
|
userMapper.updateById(user);
|
|
|
|
|
|
- //增加流水
|
|
|
+ // 增加流水
|
|
|
billBizService.income(user.getUid(), "积分回退", BillDetailEnum.CATEGORY_2.getValue(), BillDetailEnum.TYPE_8.getValue(), order.getUseIntegral().doubleValue(), newIntegral.doubleValue(), "购买商品失败,回退积分" + order.getUseIntegral(), order.getId().toString());
|
|
|
|
|
|
- //更新回退积分
|
|
|
+ // 更新回退积分
|
|
|
KxStoreOrder storeOrder = KxStoreOrder.builder().build();
|
|
|
storeOrder.setBackIntegral(order.getUseIntegral());
|
|
|
storeOrder.setId(order.getId());
|