|
|
|
@ -63,6 +63,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.support.TransactionTemplate;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
@ -72,15 +73,15 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* H5端订单操作
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | Author: CRMEB Team <admin@crmeb.com>
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
* | Author: CRMEB Team <admin@crmeb.com>
|
|
|
|
|
* +----------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class OrderServiceImpl implements OrderService {
|
|
|
|
@ -140,6 +141,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StoreProductAttrValueService storeProductAttrValueService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 订单列表
|
|
|
|
|
*
|
|
|
|
@ -151,12 +153,27 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
public PageInfo<OrderDetailResponse> list(Integer type, PageParam pageRequest) {
|
|
|
|
|
PageHelper.startPage(pageRequest.getPageNo(), pageRequest.getPageSize());
|
|
|
|
|
LambdaQueryWrapper<StoreOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
if(null != type){
|
|
|
|
|
if (null != type) {
|
|
|
|
|
lambdaQueryWrapper.eq(StoreOrder::getType, type);
|
|
|
|
|
}
|
|
|
|
|
lambdaQueryWrapper.orderByDesc(StoreOrder::getId);
|
|
|
|
|
List<StoreOrder> storeOrders = dao.selectList(lambdaQueryWrapper);
|
|
|
|
|
return new PageInfo<>(StoreOrderConvert.INSTANCE.convert(storeOrders));
|
|
|
|
|
PageInfo<OrderDetailResponse> orderDetailResponsePageInfo = new PageInfo<>(StoreOrderConvert.INSTANCE.convert(storeOrders));
|
|
|
|
|
if (!CollectionUtils.isEmpty(orderDetailResponsePageInfo.getList())) {
|
|
|
|
|
orderDetailResponsePageInfo.getList().forEach(e -> {
|
|
|
|
|
List<StoreOrderInfo> list = storeOrderInfoService.list(Wrappers.<StoreOrderInfo>lambdaQuery().eq(StoreOrderInfo::getOrderId, e.getId()));
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
List<OrderInfoResponse> orderInfoList = new ArrayList<>();
|
|
|
|
|
list.forEach(x -> {
|
|
|
|
|
OrderInfoResponse response = new OrderInfoResponse();
|
|
|
|
|
BeanUtils.copyProperties(x, response);
|
|
|
|
|
orderInfoList.add(response);
|
|
|
|
|
});
|
|
|
|
|
e.setOrderInfoList(orderInfoList);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return orderDetailResponsePageInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -167,13 +184,26 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
@Override
|
|
|
|
|
public StoreOrderDetailInfoResponse detailOrder(String orderId) {
|
|
|
|
|
StoreOrder storeOrder = storeOrderService.getByOderId(orderId);
|
|
|
|
|
return StoreOrderOneConvert.INSTANCE.convert(storeOrder);
|
|
|
|
|
List<StoreOrderInfo> list = storeOrderInfoService.list(Wrappers.<StoreOrderInfo>lambdaQuery().eq(StoreOrderInfo::getOrderId, storeOrder.getId()));
|
|
|
|
|
StoreOrderDetailInfoResponse convert = StoreOrderOneConvert.INSTANCE.convert(storeOrder);
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
List<OrderInfoResponse> orderInfoList = new ArrayList<>();
|
|
|
|
|
list.forEach(e -> {
|
|
|
|
|
OrderInfoResponse response = new OrderInfoResponse();
|
|
|
|
|
BeanUtils.copyProperties(e, response);
|
|
|
|
|
orderInfoList.add(response);
|
|
|
|
|
});
|
|
|
|
|
convert.setOrderInfoList(orderInfoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return convert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取订单总数
|
|
|
|
|
*
|
|
|
|
|
* @param dateLimit 时间端
|
|
|
|
|
* @param status String 状态
|
|
|
|
|
* @param status String 状态
|
|
|
|
|
* @return Integer
|
|
|
|
|
*/
|
|
|
|
|
private Long getCount(String dateLimit, String status, Integer type) {
|
|
|
|
@ -192,8 +222,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取订单金额
|
|
|
|
|
*
|
|
|
|
|
* @param dateLimit 时间端
|
|
|
|
|
* @param type 支付类型
|
|
|
|
|
* @param type 支付类型
|
|
|
|
|
* @return BigDecimal
|
|
|
|
|
*/
|
|
|
|
|
private BigDecimal getAmount(String dateLimit, String type) {
|
|
|
|
@ -217,8 +248,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据订单状态获取where条件
|
|
|
|
|
*
|
|
|
|
|
* @param queryWrapper QueryWrapper<StoreOrder> 表达式
|
|
|
|
|
* @param status String 类型
|
|
|
|
|
* @param status String 类型
|
|
|
|
|
*/
|
|
|
|
|
private void getStatusWhereNew(QueryWrapper<StoreOrder> queryWrapper, String status) {
|
|
|
|
|
if (StrUtil.isBlank(status)) {
|
|
|
|
@ -266,7 +298,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
break;
|
|
|
|
|
case Constants.ORDER_STATUS_REFUNDING: //退款中
|
|
|
|
|
queryWrapper.eq("paid", 1);
|
|
|
|
|
queryWrapper.in("refund_status", 1,3);
|
|
|
|
|
queryWrapper.in("refund_status", 1, 3);
|
|
|
|
|
queryWrapper.eq("is_del", 0);
|
|
|
|
|
break;
|
|
|
|
|
case Constants.ORDER_STATUS_REFUNDED: //已退款
|
|
|
|
@ -291,7 +323,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
* @return 订单状态数据量
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public OrderDataResponse orderData(String dateLimit, Integer type,String payType) {
|
|
|
|
|
public OrderDataResponse orderData(String dateLimit, Integer type, String payType) {
|
|
|
|
|
OrderDataResponse response = new OrderDataResponse();
|
|
|
|
|
if (type.equals(2)) {
|
|
|
|
|
type = null;
|
|
|
|
@ -307,7 +339,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
// 退款订单数量
|
|
|
|
|
response.setRefundCount(getCount(dateLimit, Constants.ORDER_STATUS_REFUNDED, type));
|
|
|
|
|
// 总消费钱数
|
|
|
|
|
response.setSumPrice(getAmount(dateLimit,payType));
|
|
|
|
|
response.setSumPrice(getAmount(dateLimit, payType));
|
|
|
|
|
// 未支付订单数量
|
|
|
|
|
response.setUnPaidCount(getCount(dateLimit, Constants.ORDER_STATUS_UNPAID, type));
|
|
|
|
|
// 待发货订单数量
|
|
|
|
@ -330,7 +362,8 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询单条订单
|
|
|
|
|
*@param orderNo 订单编号
|
|
|
|
|
*
|
|
|
|
|
* @param orderNo 订单编号
|
|
|
|
|
* @return 退款理由集合
|
|
|
|
|
*/
|
|
|
|
|
private StoreOrder getInfoException(Integer orderNo) {
|
|
|
|
@ -342,6 +375,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
}
|
|
|
|
|
return storeOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 订单删除
|
|
|
|
|
*
|
|
|
|
@ -517,7 +551,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Object expressOrder(String orderId) {
|
|
|
|
|
HashMap<String,Object> resultMap = new HashMap<>();
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
StoreOrder storeOrderPram = new StoreOrder();
|
|
|
|
|
storeOrderPram.setOrderId(orderId);
|
|
|
|
|
StoreOrder existOrder = storeOrderService.getByEntityOne(storeOrderPram);
|
|
|
|
@ -547,7 +581,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
orderInfo.put("info", cartInfos);
|
|
|
|
|
|
|
|
|
|
resultMap.put("order", orderInfo);
|
|
|
|
|
// resultMap.put("express", expressInfo);
|
|
|
|
|
// resultMap.put("express", expressInfo);
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -770,7 +804,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
//用户剩余积分
|
|
|
|
|
//用户剩余经验
|
|
|
|
|
// 缓存订单
|
|
|
|
|
String key = user.getId() + DateUtils.getNowTime().toString()+CrmebUtil.getUuid();
|
|
|
|
|
String key = user.getId() + DateUtils.getNowTime().toString() + CrmebUtil.getUuid();
|
|
|
|
|
redisUtil.set("user_order:" + key, JSONUtil.parseObj(orderInfoVo), Constants.ORDER_CASH_CONFIRM, TimeUnit.MINUTES);
|
|
|
|
|
MyRecord record = new MyRecord();
|
|
|
|
|
record.set("preOrderNo", key);
|
|
|
|
@ -779,6 +813,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验预下单商品信息
|
|
|
|
|
*
|
|
|
|
|
* @param request 预下单请求参数
|
|
|
|
|
* @return OrderInfoVo
|
|
|
|
|
*/
|
|
|
|
@ -866,6 +901,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 再次下单预下单校验
|
|
|
|
|
*
|
|
|
|
|
* @param detailRequest 请求参数
|
|
|
|
|
* @return List<OrderInfoDetailVo>
|
|
|
|
|
*/
|
|
|
|
@ -935,8 +971,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 购物车预下单校验
|
|
|
|
|
*
|
|
|
|
|
* @param request 请求参数
|
|
|
|
|
* @param user 用户
|
|
|
|
|
* @param user 用户
|
|
|
|
|
* @return List<OrderInfoDetailVo>
|
|
|
|
|
*/
|
|
|
|
|
private List<OrderInfoDetailVo> validatePreOrderShopping(PreOrderRequest request, MemberUserRespDTO user) {
|
|
|
|
@ -991,6 +1028,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
});
|
|
|
|
|
return detailVoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加载预下单信息
|
|
|
|
|
*
|
|
|
|
@ -1031,6 +1069,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 计算订单价格
|
|
|
|
|
*
|
|
|
|
|
* @param request 计算订单价格请求对象
|
|
|
|
|
* @return ComputedOrderPriceResponse
|
|
|
|
|
*/
|
|
|
|
@ -1137,7 +1176,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
orderRequest.setRealName(userAddress.getRealName());
|
|
|
|
|
orderRequest.setPhone(userAddress.getPhone());
|
|
|
|
|
userAddressStr = userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getDetail();
|
|
|
|
|
}else if (orderRequest.getShippingType() == 2) { // 到店自提
|
|
|
|
|
} else if (orderRequest.getShippingType() == 2) { // 到店自提
|
|
|
|
|
if (StringUtils.isBlank(orderRequest.getRealName()) || StringUtils.isBlank(orderRequest.getPhone())) {
|
|
|
|
|
throw new ServiceException("请填写姓名和电话");
|
|
|
|
|
}
|
|
|
|
@ -1150,7 +1189,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
// if (ObjectUtil.isNull(systemStore) || systemStore.getIsDel() || !systemStore.getIsShow()) {
|
|
|
|
|
// throw new ServiceException("暂无门店无法选择门店自提");
|
|
|
|
|
// }
|
|
|
|
|
verifyCode = CrmebUtil.randomCount(1111111111,999999999)+"";
|
|
|
|
|
verifyCode = CrmebUtil.randomCount(1111111111, 999999999) + "";
|
|
|
|
|
//userAddressStr = systemStore.getName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1292,7 +1331,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
storeOrder.setType(1);// 视频号订单
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// StoreCouponUser storeCouponUser = new StoreCouponUser();
|
|
|
|
|
// StoreCouponUser storeCouponUser = new StoreCouponUser();
|
|
|
|
|
// 优惠券修改
|
|
|
|
|
// if (storeOrder.getCouponId() > 0) {
|
|
|
|
|
// storeCouponUser = storeCouponUserService.getById(storeOrder.getCouponId());
|
|
|
|
@ -1304,12 +1343,12 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
// 扣减库存
|
|
|
|
|
// 需要根据是否活动商品,扣减不同的库存
|
|
|
|
|
// 普通商品
|
|
|
|
|
for (MyRecord skuRecord : skuRecordList) {
|
|
|
|
|
// 普通商品口库存
|
|
|
|
|
storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
|
|
|
// 普通商品规格扣库存
|
|
|
|
|
//storeProductAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
|
|
|
}//
|
|
|
|
|
for (MyRecord skuRecord : skuRecordList) {
|
|
|
|
|
// 普通商品口库存
|
|
|
|
|
storeProductService.operationStock(skuRecord.getInt("productId"), skuRecord.getInt("num"), "sub");
|
|
|
|
|
// 普通商品规格扣库存
|
|
|
|
|
//storeProductAttrValueService.operationStock(skuRecord.getInt("attrValueId"), skuRecord.getInt("num"), "sub", Constants.PRODUCT_TYPE_NORMAL);
|
|
|
|
|
}//
|
|
|
|
|
|
|
|
|
|
storeOrderService.create(storeOrder);
|
|
|
|
|
storeOrderInfos.forEach(info -> info.setOrderId(storeOrder.getId()));
|
|
|
|
@ -1337,7 +1376,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, storeOrder.getOrderId());
|
|
|
|
|
|
|
|
|
|
// TODO 发送后台管理员下单提醒通知短信
|
|
|
|
|
// sendAdminOrderNotice(storeOrder.getOrderId());
|
|
|
|
|
// sendAdminOrderNotice(storeOrder.getOrderId());
|
|
|
|
|
|
|
|
|
|
MyRecord record = new MyRecord();
|
|
|
|
|
record.set("orderNo", storeOrder.getOrderId());
|
|
|
|
@ -1346,6 +1385,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验商品库存(生成订单)
|
|
|
|
|
*
|
|
|
|
|
* @param orderInfoVo 订单详情Vo
|
|
|
|
|
* @return List<MyRecord>
|
|
|
|
|
* skuRecord 扣减库存对象
|
|
|
|
@ -1392,6 +1432,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
}
|
|
|
|
|
return recordList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取支付配置
|
|
|
|
|
*
|
|
|
|
|