refactor(order):优化订单相关逻辑与数据映射
- 修改订单项租户ID获取逻辑,使用item.getTenantId()替代vo.getTenantId()- 调整热销商品统计SQL,将状态筛选从status=3改为status in (2,9) - 移除OrderMapper中冗余的selectByEntity方法及XML配置- 删除OrderVO中冗余的租户信息、收货地址等字段- 注释掉OrderVO中的采购价字段 - 清理OrderVO中与前端展示无关的商品相关信息字段 - 移除订单统计SQL中不必要的delete_status条件限制 - 修改商品分类控制器依赖注入方式,使用接口类型替换实现类- 移除订单详情接口中设置租户信息的重复逻辑 - 清理OrderVO中冗余的tenant对象属性 - 删除订单列表查询XML中冗余的orderPage和selectOrderDetail方法配置
This commit is contained in:
parent
8ba2a94e97
commit
d4079a5f28
@ -6,7 +6,7 @@ import com.wzj.soopin.goods.convert.ProductCategoryConvert;
|
||||
import com.wzj.soopin.goods.domain.bo.ProductCategoryBo;
|
||||
import com.wzj.soopin.goods.domain.entity.ProductCategory;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.goods.service.impl.ProductCategoryServiceImpl;
|
||||
import com.wzj.soopin.goods.service.ProductCategoryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -31,9 +31,8 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class ProductCategoryController extends BaseController {
|
||||
|
||||
private final ProductCategoryService service;
|
||||
|
||||
|
||||
private final ProductCategoryServiceImpl service;
|
||||
private final ProductCategoryConvert convert;
|
||||
|
||||
@Operation(summary = "查询列表")
|
||||
|
@ -38,10 +38,6 @@ public class OrderBusinessImpl extends BusinessImpl<OrderService, OrderConvert,
|
||||
@Override
|
||||
public OrderVO info(Serializable id) {
|
||||
OrderVO vo= super.info(id);
|
||||
|
||||
//设置租户信息
|
||||
|
||||
|
||||
Member member = memberService.getById(vo.getMemberId());
|
||||
vo.setMemberNickname(member.getNickname());
|
||||
vo.setMemberPhoneEncrypted(member.getPhoneHidden());
|
||||
@ -51,7 +47,7 @@ public class OrderBusinessImpl extends BusinessImpl<OrderService, OrderConvert,
|
||||
List<OrderItemVO> itemVOList = orderItemList.stream().map(item -> {
|
||||
OrderItemVO itemVO=orderItemConvert.toVO(item);
|
||||
if (itemVO.getTenantId() != null) {
|
||||
SysTenantVo tenant = tenantService.queryByTenantId(vo.getTenantId());
|
||||
SysTenantVo tenant = tenantService.queryByTenantId(item.getTenantId());
|
||||
itemVO.setTenantName(tenant.getStoreName());
|
||||
}
|
||||
//赋值
|
||||
|
@ -6,7 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@ -37,8 +36,6 @@ public class OrderVO extends BaseAudit {
|
||||
@Schema(description ="租户id")
|
||||
private String tenantId;
|
||||
|
||||
private SysTenantVo tenant;
|
||||
|
||||
@Schema(description ="用户帐号")
|
||||
@Excel(name = "用户帐号")
|
||||
private String memberUsername;
|
||||
@ -50,10 +47,10 @@ public class OrderVO extends BaseAudit {
|
||||
@Schema(description ="订单总金额")
|
||||
@Excel(name = "订单总金额")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Schema(description ="采购价")
|
||||
@Excel(name = "采购价")
|
||||
private BigDecimal purchasePrice;
|
||||
//
|
||||
// @Schema(description ="采购价")
|
||||
// @Excel(name = "采购价")
|
||||
// private BigDecimal purchasePrice;
|
||||
|
||||
@Schema(description ="应付金额")
|
||||
@Excel(name = "应付金额", readConverterExp = "实=际支付金额")
|
||||
@ -72,34 +69,34 @@ public class OrderVO extends BaseAudit {
|
||||
@Schema(description="是否处于退款状态")
|
||||
private Boolean aftersale;
|
||||
|
||||
|
||||
@Schema(description ="省份/直辖市")
|
||||
@Excel(name = "省份/直辖市")
|
||||
private String receiverProvince;
|
||||
|
||||
@Schema(description ="城市")
|
||||
@Excel(name = "城市")
|
||||
private String receiverCity;
|
||||
|
||||
@Schema(description ="区")
|
||||
@Excel(name = "区")
|
||||
private String receiverDistrict;
|
||||
|
||||
@Schema(description ="省份/直辖市id")
|
||||
@Excel(name = "省份/直辖市id")
|
||||
private Long receiverProvinceId;
|
||||
|
||||
@Schema(description ="城市id")
|
||||
@Excel(name = "城市id")
|
||||
private Long receiverCityId;
|
||||
|
||||
@Schema(description ="区idvv")
|
||||
@Excel(name = "区id")
|
||||
private Long receiverDistrictId;
|
||||
|
||||
@Schema(description ="详细地址")
|
||||
@Excel(name = "详细地址")
|
||||
private String receiverDetailAddress;
|
||||
//
|
||||
// @Schema(description ="省份/直辖市")
|
||||
// @Excel(name = "省份/直辖市")
|
||||
// private String receiverProvince;
|
||||
//
|
||||
// @Schema(description ="城市")
|
||||
// @Excel(name = "城市")
|
||||
// private String receiverCity;
|
||||
//
|
||||
// @Schema(description ="区")
|
||||
// @Excel(name = "区")
|
||||
// private String receiverDistrict;
|
||||
//
|
||||
// @Schema(description ="省份/直辖市id")
|
||||
// @Excel(name = "省份/直辖市id")
|
||||
// private Long receiverProvinceId;
|
||||
//
|
||||
// @Schema(description ="城市id")
|
||||
// @Excel(name = "城市id")
|
||||
// private Long receiverCityId;
|
||||
//
|
||||
// @Schema(description ="区idvv")
|
||||
// @Excel(name = "区id")
|
||||
// private Long receiverDistrictId;
|
||||
//
|
||||
// @Schema(description ="详细地址")
|
||||
// @Excel(name = "详细地址")
|
||||
// private String receiverDetailAddress;
|
||||
|
||||
@Schema(description ="订单备注")
|
||||
@Excel(name = "订单备注")
|
||||
@ -119,34 +116,6 @@ public class OrderVO extends BaseAudit {
|
||||
@Schema(description ="用户手机号")
|
||||
private String memberPhoneEncrypted;
|
||||
|
||||
@Excel(name = "卖家昵称")
|
||||
@Schema(description ="卖家昵称")
|
||||
private String tenantContactName;
|
||||
|
||||
@Excel(name = "卖家手机号")
|
||||
@Schema(description ="卖家手机号")
|
||||
private String tenantContactPhone;
|
||||
|
||||
@Excel(name = "itemID")
|
||||
@Schema(description ="itemID")
|
||||
private Long itemId;
|
||||
|
||||
@Excel(name = "商品id")
|
||||
@Schema(description ="商品id")
|
||||
private Long productId;
|
||||
|
||||
@Excel(name = "商品品牌")
|
||||
@Schema(description ="商品品牌id")
|
||||
private Long productBrandId;
|
||||
|
||||
@Schema(description ="商品名称")
|
||||
@Excel(name = "商品名称")
|
||||
private String productName;
|
||||
|
||||
@Schema(description ="商品价格")
|
||||
@Excel(name = "商品价格")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@Schema(description = "订单类型:1->团购;2->拼团;3->秒杀;")
|
||||
@Excel(name = "订单类型:1->团购;2->拼团;3->秒杀;")
|
||||
private Integer type;
|
||||
|
@ -60,8 +60,7 @@ public interface OrderItemMapper extends BaseMapperPlus<OrderItem, OrderItemVO>
|
||||
" 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 " + // 未删除订单
|
||||
"WHERE o.status in (2,9) " + // 已完成订单
|
||||
"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}")
|
||||
|
@ -23,13 +23,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMapper extends BaseMapper<Order> {
|
||||
/**
|
||||
* 查询订单表列表
|
||||
*
|
||||
* @param order 订单表
|
||||
* @return 订单表集合
|
||||
*/
|
||||
List<Order> selectByEntity(Order order);
|
||||
|
||||
|
||||
|
||||
List<ManagerOrderVO> selectManagerOrderPage(ManagerOrderQueryForm request);
|
||||
|
@ -56,38 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectByEntity" parameterType="Order" resultMap="OrderResult">
|
||||
<include refid="selectOrderVo"/>
|
||||
<where>
|
||||
<if test="memberId != null "> and member_id = #{memberId}</if>
|
||||
<if test="memberUsername != null and memberUsername != ''"> and member_username like concat('%', #{memberUsername}, '%')</if>
|
||||
<if test="totalAmount != null "> and total_amount = #{totalAmount}</if>
|
||||
<if test="purchasePrice != null "> and purchase_price = #{purchasePrice}</if>
|
||||
<if test="payAmount != null "> and pay_amount = #{payAmount}</if>
|
||||
<if test="payType != null "> and pay_type = #{payType}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="aftersaleStatus != null "> and aftersale_status = #{aftersaleStatus}</if>
|
||||
<if test="deliveryCompany != null and deliveryCompany != ''"> and delivery_company = #{deliveryCompany}</if>
|
||||
<if test="deliverySn != null and deliverySn != ''"> and delivery_sn = #{deliverySn}</if>
|
||||
<if test="autoConfirmDay != null "> and auto_confirm_day = #{autoConfirmDay}</if>
|
||||
<if test="receiverName != null and receiverName != ''"> and receiver_name like concat('%', #{receiverName}, '%')</if>
|
||||
<if test="receiverPhone != null and receiverPhone != ''"> and receiver_phone = #{receiverPhone}</if>
|
||||
<if test="receiverPostCode != null and receiverPostCode != ''"> and receiver_post_code = #{receiverPostCode}</if>
|
||||
<if test="receiverProvince != null and receiverProvince != ''"> and receiver_province = #{receiverProvince}</if>
|
||||
<if test="receiverCity != null and receiverCity != ''"> and receiver_city = #{receiverCity}</if>
|
||||
<if test="receiverDistrict != null and receiverDistrict != ''"> and receiver_district = #{receiverDistrict}</if>
|
||||
<if test="receiverProvinceId != null "> and receiver_province_id = #{receiverProvinceId}</if>
|
||||
<if test="receiverCityId != null "> and receiver_city_id = #{receiverCityId}</if>
|
||||
<if test="receiverDistrictId != null "> and receiver_district_id = #{receiverDistrictId}</if>
|
||||
<if test="receiverDetailAddress != null and receiverDetailAddress != ''"> and receiver_detail_address = #{receiverDetailAddress}</if>
|
||||
<if test="note != null and note != ''"> and note = #{note}</if>
|
||||
<if test="confirmStatus != null "> and confirm_status = #{confirmStatus}</if>
|
||||
<if test="deleteStatus != null "> and delete_status = #{deleteStatus}</if>
|
||||
<if test="paymentTime != null "> and payment_time = #{paymentTime}</if>
|
||||
<if test="deliveryTime != null "> and delivery_time = #{deliveryTime}</if>
|
||||
<if test="receiveTime != null "> and receive_time = #{receiveTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectManagerOrderPage" resultType="com.wzj.soopin.order.domain.vo.ManagerOrderVO">
|
||||
select
|
||||
@ -155,64 +124,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by a.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="orderPage" resultType="com.wzj.soopin.order.domain.vo.H5OrderVO">
|
||||
select
|
||||
id orderId,
|
||||
pay_id,
|
||||
order_sn,
|
||||
member_id,
|
||||
total_amount,
|
||||
pay_amount,
|
||||
status,
|
||||
aftersale,
|
||||
note,
|
||||
delivery_sn,
|
||||
coupon_amount,
|
||||
create_time,
|
||||
payment_time,
|
||||
receiver_name,
|
||||
receiver_phone,
|
||||
receiver_province,
|
||||
receiver_city,
|
||||
receiver_district,
|
||||
receiver_detail_address
|
||||
from oms_order
|
||||
where
|
||||
delete_status=0
|
||||
and member_id=#{memberId}
|
||||
<if test="status==-1">
|
||||
and status in (1,2,3,4)
|
||||
</if>
|
||||
<if test="status>-1 and status<3">
|
||||
and status=#{status}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
<select id="selectOrderDetail" resultType="com.wzj.soopin.order.domain.vo.H5OrderVO">
|
||||
select
|
||||
id orderId,
|
||||
pay_id,
|
||||
order_sn,
|
||||
member_id,
|
||||
total_amount,
|
||||
pay_amount,
|
||||
coupon_amount,
|
||||
status,
|
||||
aftersale,
|
||||
note,
|
||||
delivery_sn,
|
||||
create_time,
|
||||
payment_time,
|
||||
receiver_name,
|
||||
receiver_phone,
|
||||
receiver_province,
|
||||
receiver_city,
|
||||
receiver_district,
|
||||
receiver_detail_address
|
||||
from oms_order
|
||||
where
|
||||
id=#{orderId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="countByStatusAndMemberId" resultType="com.wzj.soopin.order.domain.vo.CountOrderVO">
|
||||
select
|
||||
IFNULL(sum(case when status=0 and aftersale = 1 then 1 else 0 end),0) unpaid,
|
||||
@ -220,7 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
IFNULL(sum(case when status=2 and aftersale=1 then 1 else 0 end),0) noget,
|
||||
IFNULL(sum(case when aftersale in (2,3) then 1 else 0 end),0) aftersale
|
||||
from oms_order
|
||||
where member_id=#{memberId} and delete_status=0
|
||||
where member_id=#{memberId}
|
||||
</select>
|
||||
<select id="statOrderCountAndAmount" resultType="com.wzj.soopin.order.domain.vo.MemberDataStatisticsVO">
|
||||
select
|
||||
|
Loading…
x
Reference in New Issue
Block a user