feat(order): 新增商家订单详情查询接口
This commit is contained in:
parent
22d6ca9897
commit
8ba2a94e97
@ -3,9 +3,7 @@ package org.dromara.app.merchant;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.wzj.soopin.order.business.IOrderBusiness;
|
||||
import com.wzj.soopin.order.domain.bo.OrderItemBo;
|
||||
import com.wzj.soopin.order.domain.entity.Order;
|
||||
import com.wzj.soopin.order.domain.vo.MerchantOrderVO;
|
||||
import com.wzj.soopin.order.domain.vo.OrderVO;
|
||||
import com.wzj.soopin.order.service.IMerchantOrderService;
|
||||
import com.wzj.soopin.order.service.VerificationCodeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -33,6 +31,15 @@ public class AppMerchantOrderController {
|
||||
private final IMerchantOrderService merchantOrderService;
|
||||
|
||||
private final IOrderBusiness orderBusiness;
|
||||
|
||||
|
||||
@Operation(summary = "获取该商家订单子项详细信息")
|
||||
@GetMapping(value = "/{orderItemId}")
|
||||
public R<MerchantOrderVO> getInfo(@PathVariable("orderItemId") Long orderItemId) {
|
||||
return R.ok(orderBusiness.itemInfo(orderItemId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 扫码核销接口
|
||||
* @return 核销结果
|
||||
@ -49,9 +56,8 @@ public class AppMerchantOrderController {
|
||||
*/
|
||||
@GetMapping("/scan")
|
||||
@Operation(summary = "查询核销码对应的订单")
|
||||
public R<OrderVO> scan(@RequestParam("code") String code) {
|
||||
Order order = verificationCodeService.scan(code);
|
||||
return R.ok(orderBusiness.info(order.getId()));
|
||||
public R<MerchantOrderVO> scan(@RequestParam("code") String code) {
|
||||
return R.ok(orderBusiness.getItemInfoByVerificationCode(code));
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
|
@ -1,8 +1,14 @@
|
||||
package com.wzj.soopin.order.business;
|
||||
|
||||
import com.wzj.soopin.order.domain.bo.OrderBo;
|
||||
import com.wzj.soopin.order.domain.vo.MerchantOrderVO;
|
||||
import com.wzj.soopin.order.domain.vo.OrderVO;
|
||||
import org.dromara.common.web.core.IBusiness;
|
||||
|
||||
public interface IOrderBusiness extends IBusiness<OrderVO, OrderBo> {
|
||||
|
||||
|
||||
MerchantOrderVO itemInfo(Long orderItemId);
|
||||
|
||||
MerchantOrderVO getItemInfoByVerificationCode(String verificationCode);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.wzj.soopin.order.convert.OrderItemConvert;
|
||||
import com.wzj.soopin.order.domain.bo.OrderBo;
|
||||
import com.wzj.soopin.order.domain.entity.Order;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import com.wzj.soopin.order.domain.vo.MerchantOrderVO;
|
||||
import com.wzj.soopin.order.domain.vo.OrderItemVO;
|
||||
import com.wzj.soopin.order.domain.vo.OrderVO;
|
||||
import com.wzj.soopin.order.service.OrderItemService;
|
||||
@ -62,4 +63,14 @@ public class OrderBusinessImpl extends BusinessImpl<OrderService, OrderConvert,
|
||||
vo.setVerificationCodes(verificationCodeService.getByOrderId(vo.getId()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MerchantOrderVO itemInfo(Long orderItemId) {
|
||||
return orderItemService.getMerchantOrder(orderItemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MerchantOrderVO getItemInfoByVerificationCode(String verificationCode) {
|
||||
return orderItemService.getMerchantOrder(verificationCode);
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ public interface OrderItemMapper extends BaseMapperPlus<OrderItem, OrderItemVO>
|
||||
* @return 商品名称
|
||||
*/
|
||||
@Select("SELECT p.name " +
|
||||
"FROM oms_order_item oi " +
|
||||
"JOIN pms_product p ON oi.product_id = p.id " +
|
||||
"WHERE oi.order_id = #{orderId} " +
|
||||
"LIMIT 1")
|
||||
"FROM oms_order_item oi " +
|
||||
"JOIN pms_product p ON oi.product_id = p.id " +
|
||||
"WHERE oi.order_id = #{orderId} " +
|
||||
"LIMIT 1")
|
||||
String getName(Long orderId);
|
||||
|
||||
/**
|
||||
@ -50,25 +50,27 @@ public interface OrderItemMapper extends BaseMapperPlus<OrderItem, OrderItemVO>
|
||||
* @return 商品交易量信息列表
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
" oi.product_id, " +
|
||||
" oi.product_name, " +
|
||||
" oi.pic, " +
|
||||
" oi.out_product_id, " +
|
||||
" oi.product_category_id, " +
|
||||
" SUM(oi.quantity) as total_quantity, " +
|
||||
" SUM(oi.quantity * oi.sale_price) as total_amount, " +
|
||||
" COUNT(DISTINCT o.id) as order_count " +
|
||||
"FROM oms_order_item oi " +
|
||||
"JOIN oms_order o ON oi.order_id = o.id " +
|
||||
"WHERE o.status = 3 " + // 已完成订单
|
||||
" AND o.delete_status = 0 " + // 未删除订单
|
||||
"GROUP BY oi.product_id, oi.product_name, oi.pic, oi.out_product_id, oi.product_category_id " +
|
||||
"ORDER BY total_quantity DESC " +
|
||||
"LIMIT #{limit}")
|
||||
" oi.product_id, " +
|
||||
" oi.product_name, " +
|
||||
" oi.pic, " +
|
||||
" oi.out_product_id, " +
|
||||
" oi.product_category_id, " +
|
||||
" SUM(oi.quantity) as total_quantity, " +
|
||||
" SUM(oi.quantity * oi.sale_price) as total_amount, " +
|
||||
" COUNT(DISTINCT o.id) as order_count " +
|
||||
"FROM oms_order_item oi " +
|
||||
"JOIN oms_order o ON oi.order_id = o.id " +
|
||||
"WHERE o.status = 3 " + // 已完成订单
|
||||
" AND o.delete_status = 0 " + // 未删除订单
|
||||
"GROUP BY oi.product_id, oi.product_name, oi.pic, oi.out_product_id, oi.product_category_id " +
|
||||
"ORDER BY total_quantity DESC " +
|
||||
"LIMIT #{limit}")
|
||||
List<Map<String, Object>> selectTopTradingProducts(int limit);
|
||||
|
||||
@Select("SELECT * FROM oms_order_item WHERE order_id = #{orderId}")
|
||||
List<OrderItem> findByOrderId(Long orderId);
|
||||
|
||||
IPage<MerchantOrderVO> selectMerchatOrderPage(@Param("page") Page<Object> page, @Param("query") OrderItemBo query);
|
||||
|
||||
MerchantOrderVO selectMerchatOrder(@Param("tenantId") String tenantId, @Param("orderItemId") Long orderItemId, @Param("verificationCode") String verificationCode);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.wzj.soopin.order.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import com.wzj.soopin.order.domain.vo.MerchantOrderVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -14,4 +15,8 @@ public interface OrderItemService extends IService<OrderItem> {
|
||||
* @param limit 查询数量限制
|
||||
*/
|
||||
void cacheTopTradingProducts(int limit);
|
||||
|
||||
MerchantOrderVO getMerchantOrder(Long orderItemId);
|
||||
|
||||
MerchantOrderVO getMerchantOrder(String code);
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
package com.wzj.soopin.order.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import com.wzj.soopin.order.domain.vo.MerchantOrderVO;
|
||||
import com.wzj.soopin.order.mapper.OrderItemMapper;
|
||||
import com.wzj.soopin.order.service.OrderItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.redis.redis.RedisCache;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -62,4 +66,18 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
|
||||
log.error("缓存交易量最多商品到Redis失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MerchantOrderVO getMerchantOrder(Long orderItemId) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
Assert.notEmpty(tenantId, () -> ServiceException.of("您无权查看商户订单"));
|
||||
return baseMapper.selectMerchatOrder(tenantId, orderItemId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MerchantOrderVO getMerchantOrder(String code) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
Assert.notEmpty(tenantId, () -> ServiceException.of("您无权查看商户订单"));
|
||||
return baseMapper.selectMerchatOrder(tenantId,null, code);
|
||||
}
|
||||
}
|
||||
|
@ -73,28 +73,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectMerchatOrderPage" resultType="com.wzj.soopin.order.domain.vo.MerchantOrderVO">
|
||||
SELECT o.id AS orderId,
|
||||
o.order_sn AS orderSn,
|
||||
o.member_id AS memberId,
|
||||
o.member_username AS memberUsername,
|
||||
o.merchant_note AS merchantNote,
|
||||
o.pay_type AS payType,
|
||||
o.status AS status,
|
||||
o.aftersale AS aftersale,
|
||||
oi.id AS orderItemId,
|
||||
oi.product_id AS productId,
|
||||
oi.sku_id AS skuId,
|
||||
oi.product_snapshot_id AS productSnapshotId,
|
||||
ppc.name AS productCategoryName,
|
||||
oi.sku_snapshot_id AS skuSnapshotId,
|
||||
oi.pic AS pic,
|
||||
oi.product_name AS productName,
|
||||
oi.sale_price AS salePrice,
|
||||
oi.quantity AS quantity,
|
||||
oi.product_category_id AS productCategoryId,
|
||||
oi.sp_data AS spData,
|
||||
oi.tenant_id AS tenantId,
|
||||
oi.tenant_name AS tenantName
|
||||
SELECT o.id AS orderId,
|
||||
o.order_sn AS orderSn,
|
||||
o.member_id AS memberId,
|
||||
o.member_username AS memberUsername,
|
||||
o.merchant_note AS merchantNote,
|
||||
o.pay_type AS payType,
|
||||
o.status AS status,
|
||||
o.aftersale AS aftersale,
|
||||
oi.id AS orderItemId,
|
||||
oi.product_id AS productId,
|
||||
oi.sku_id AS skuId,
|
||||
oi.product_snapshot_id AS productSnapshotId,
|
||||
ppc.name AS productCategoryName,
|
||||
oi.sku_snapshot_id AS skuSnapshotId,
|
||||
oi.pic AS pic,
|
||||
oi.product_name AS productName,
|
||||
oi.sale_price AS salePrice,
|
||||
oi.quantity AS quantity,
|
||||
oi.product_category_id AS productCategoryId,
|
||||
oi.sp_data AS spData,
|
||||
oi.tenant_id AS tenantId,
|
||||
oi.tenant_name AS tenantName,
|
||||
vc.code AS code,
|
||||
vc.status AS verificationCodeStatus,
|
||||
vc.used_time AS usedTime,
|
||||
vc.used_merchant_id AS usedMerchantId,
|
||||
vc.expire_time AS expireTime,
|
||||
vc.verification_time AS verificationTime,
|
||||
vc.reason AS reason
|
||||
|
||||
FROM oms_order_item oi
|
||||
LEFT JOIN oms_order o ON oi.order_id = o.id
|
||||
LEFT JOIN pms_product_category ppc ON oi.product_category_id = ppc.id
|
||||
@ -137,4 +145,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND oi.product_category_id = #{query.productCategoryId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectMerchatOrder" resultType="com.wzj.soopin.order.domain.vo.MerchantOrderVO">
|
||||
SELECT o.id AS orderId,
|
||||
o.order_sn AS orderSn,
|
||||
o.member_id AS memberId,
|
||||
o.member_username AS memberUsername,
|
||||
o.merchant_note AS merchantNote,
|
||||
o.pay_type AS payType,
|
||||
o.status AS status,
|
||||
o.aftersale AS aftersale,
|
||||
oi.id AS orderItemId,
|
||||
oi.product_id AS productId,
|
||||
oi.sku_id AS skuId,
|
||||
oi.product_snapshot_id AS productSnapshotId,
|
||||
ppc.name AS productCategoryName,
|
||||
oi.sku_snapshot_id AS skuSnapshotId,
|
||||
oi.pic AS pic,
|
||||
oi.product_name AS productName,
|
||||
oi.sale_price AS salePrice,
|
||||
oi.quantity AS quantity,
|
||||
oi.product_category_id AS productCategoryId,
|
||||
oi.sp_data AS spData,
|
||||
oi.tenant_id AS tenantId,
|
||||
oi.tenant_name AS tenantName,
|
||||
vc.code AS code,
|
||||
vc.status AS verificationCodeStatus,
|
||||
vc.used_time AS usedTime,
|
||||
vc.used_merchant_id AS usedMerchantId,
|
||||
vc.expire_time AS expireTime,
|
||||
vc.verification_time AS verificationTime,
|
||||
vc.reason AS reason
|
||||
FROM oms_order_item oi
|
||||
LEFT JOIN oms_order o ON oi.order_id = o.id
|
||||
LEFT JOIN pms_product_category ppc ON oi.product_category_id = ppc.id
|
||||
LEFT JOIN oms_verification_codes vc ON oi.id = vc.order_item_id
|
||||
where oi.tenant_id = #{tenantId}
|
||||
<if test="orderItemId != null">
|
||||
AND oi.id = #{orderItemId}
|
||||
</if>
|
||||
<if test="verificationCode != null">
|
||||
AND vc.code = #{verificationCode}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user