From 138e3641fbe49a114a399323aa145774f310627e Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Fri, 11 Jul 2025 18:06:31 +0800 Subject: [PATCH] 订单信息优化 --- oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderAddressSnapshotServiceImpl.java | 2 oying-system/src/main/resources/config/application-dev.yml | 2 oying-system/src/main/resources/mapper/sh/OrderMapper.xml | 141 ++++++++++++++++++++--- oying-system/src/main/java/com/oying/modules/sh/domain/OrderAddressSnapshot.java | 15 + oying-system/src/main/java/com/oying/modules/sh/domain/OrderProductSnapshot.java | 25 +++ oying-system/src/main/java/com/oying/modules/sh/domain/Order.java | 33 +++++ oying-system/src/main/java/com/oying/modules/sh/rest/OrderController.java | 12 -- oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderQueryCriteria.java | 6 + oying-system/src/main/java/com/oying/modules/sh/domain/request/SubmitOrder.java | 10 + oying-system/src/main/resources/config/application-prod.yml | 2 oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderAddressSnapshotQueryCriteria.java | 4 oying-system/src/main/java/com/oying/modules/system/service/impl/MerchantServiceImpl.java | 2 oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java | 40 ++++++ oying-system/src/main/java/com/oying/modules/system/domain/Merchant.java | 1 oying-system/src/main/java/com/oying/modules/sh/mapper/OrderMapper.java | 2 oying-system/src/main/resources/mapper/sh/OrderAddressSnapshotMapper.xml | 9 16 files changed, 254 insertions(+), 52 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/sh/domain/Order.java b/oying-system/src/main/java/com/oying/modules/sh/domain/Order.java index d1893bd..21544b0 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/domain/Order.java +++ b/oying-system/src/main/java/com/oying/modules/sh/domain/Order.java @@ -1,5 +1,6 @@ package com.oying.modules.sh.domain; +import com.baomidou.mybatisplus.annotation.TableField; import com.oying.base.BaseEntity; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -8,6 +9,9 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.Objects; +import java.util.Set; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -28,6 +32,10 @@ @ApiModelProperty(value = "主键") private Long orderId; + @TableField(exist = false) + @ApiModelProperty(value = "用户角色") + private Set<OrderProductSnapshot> productSnapshots; + @NotBlank @ApiModelProperty(value = "订单号") private String orderNum; @@ -39,6 +47,13 @@ @NotBlank @ApiModelProperty(value = "订单状态描述") private String orderStatusDescribe; + + @ApiModelProperty(value = "订单状态描述") + private String orderRemark; + + @NotBlank + @ApiModelProperty(value = "预计送达时间") + private String orderTime; @NotNull @ApiModelProperty(value = "用户id") @@ -116,6 +131,24 @@ @ApiModelProperty(value = "签名") private String paySign; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order user = (Order) o; + return Objects.equals(orderId, user.orderId) && + Objects.equals(orderNum, user.orderNum); + } + + @Override + public int hashCode() { + return Objects.hash(orderId, username); + } + public void copy(Order source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/oying-system/src/main/java/com/oying/modules/sh/domain/OrderAddressSnapshot.java b/oying-system/src/main/java/com/oying/modules/sh/domain/OrderAddressSnapshot.java index 4c25323..e1afb75 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/domain/OrderAddressSnapshot.java +++ b/oying-system/src/main/java/com/oying/modules/sh/domain/OrderAddressSnapshot.java @@ -1,6 +1,5 @@ package com.oying.modules.sh.domain; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; @@ -8,16 +7,20 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; +import lombok.Setter; /** * @description / * @author lixin * @date 2025-06-11 **/ -@Data +@Getter +@Setter @TableName("sh_order_address_snapshot") public class OrderAddressSnapshot implements Serializable { @@ -26,8 +29,8 @@ private Long snapshotId; @NotNull - @ApiModelProperty(value = "订单ID") - private Long orderId; + @ApiModelProperty(value = "订单号") + private String orderNum; @NotBlank @ApiModelProperty(value = "收货人姓名") @@ -49,6 +52,10 @@ @ApiModelProperty(value = "街道") private String street; + @ApiModelProperty(value = "短地址") + @NotBlank + private String shortAddress; + @NotBlank @ApiModelProperty(value = "详细地址") private String detail; diff --git a/oying-system/src/main/java/com/oying/modules/sh/domain/OrderProductSnapshot.java b/oying-system/src/main/java/com/oying/modules/sh/domain/OrderProductSnapshot.java index a9a2237..f3eb947 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/domain/OrderProductSnapshot.java +++ b/oying-system/src/main/java/com/oying/modules/sh/domain/OrderProductSnapshot.java @@ -1,6 +1,5 @@ package com.oying.modules.sh.domain; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; @@ -8,16 +7,21 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.Objects; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; +import lombok.Setter; /** * @description / * @author lixin * @date 2025-06-11 **/ -@Data +@Getter +@Setter @TableName("sh_order_product_snapshot") public class OrderProductSnapshot implements Serializable { @@ -86,6 +90,23 @@ @ApiModelProperty(value = "状态") private String payState; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OrderProductSnapshot snapshot = (OrderProductSnapshot) o; + return Objects.equals(snapshotId, snapshot.snapshotId); + } + + @Override + public int hashCode() { + return Objects.hash(snapshotId); + } + public void copy(OrderProductSnapshot source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderAddressSnapshotQueryCriteria.java b/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderAddressSnapshotQueryCriteria.java index 4f28d07..e7b91a0 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderAddressSnapshotQueryCriteria.java +++ b/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderAddressSnapshotQueryCriteria.java @@ -16,6 +16,6 @@ @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; - @ApiModelProperty(value = "订单ID") - private Long orderId; + @ApiModelProperty(value = "订单号") + private String orderNum; } diff --git a/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderQueryCriteria.java b/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderQueryCriteria.java index 2aadb4a..76e8eee 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderQueryCriteria.java +++ b/oying-system/src/main/java/com/oying/modules/sh/domain/dto/OrderQueryCriteria.java @@ -18,6 +18,9 @@ @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; + @ApiModelProperty(value = "商品模糊查询") + private String blurry; + @ApiModelProperty(value = "订单状态") private Integer orderStatus; @@ -43,4 +46,7 @@ private String payType; private List<String> payTime; private List<Timestamp> createTime; + + @ApiModelProperty(value = "偏移量", hidden = true) + private long offset; } diff --git a/oying-system/src/main/java/com/oying/modules/sh/domain/request/SubmitOrder.java b/oying-system/src/main/java/com/oying/modules/sh/domain/request/SubmitOrder.java index 7119f9d..03bb2da 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/domain/request/SubmitOrder.java +++ b/oying-system/src/main/java/com/oying/modules/sh/domain/request/SubmitOrder.java @@ -5,7 +5,8 @@ import lombok.Getter; import lombok.Setter; -import java.sql.Timestamp; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.util.List; /** @@ -17,16 +18,21 @@ @Setter public class SubmitOrder { + @NotNull(message = "地址不能为空") @ApiModelProperty(value = "地址ID") private Long addressId; + @NotBlank(message = "送达时间不能为空") @ApiModelProperty(value = "送达时间") - private Timestamp dateTime; + private String dateTime; + @NotNull(message = "门店不能为空") @ApiModelProperty(value = "门店ID") private Long storeId; + @NotNull(message = "商品不能为空") @ApiModelProperty(value = "商品&数量") private List<ProductOrder> products; @ApiModelProperty(value = "备注") private String remark; + @NotBlank(message = "支付类型不能为空") @ApiModelProperty(value = "支付类型") private PayTypeEnum payType; diff --git a/oying-system/src/main/java/com/oying/modules/sh/mapper/OrderMapper.java b/oying-system/src/main/java/com/oying/modules/sh/mapper/OrderMapper.java index e7fb24b..a879aba 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/mapper/OrderMapper.java +++ b/oying-system/src/main/java/com/oying/modules/sh/mapper/OrderMapper.java @@ -21,6 +21,8 @@ List<Order> findAll(@Param("criteria") OrderQueryCriteria criteria); + Long countAll(@Param("criteria") OrderQueryCriteria criteria); + Order getByOrderNum(String orderNum); void updatePayStatus(String orderNum, String payState, String payMessage, String payTime); diff --git a/oying-system/src/main/java/com/oying/modules/sh/rest/OrderController.java b/oying-system/src/main/java/com/oying/modules/sh/rest/OrderController.java index 3ee152d..4bee5be 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/rest/OrderController.java +++ b/oying-system/src/main/java/com/oying/modules/sh/rest/OrderController.java @@ -1,7 +1,6 @@ package com.oying.modules.sh.rest; import com.oying.annotation.Log; -import com.oying.exception.BadRequestException; import com.oying.modules.sh.domain.request.GeneratorOrder; import com.oying.modules.sh.domain.request.SubmitOrder; import com.oying.modules.sh.service.OrderService; @@ -48,17 +47,6 @@ @ApiOperation("查询订单信息") @PreAuthorize("@el.check('order:list')") public ResponseEntity<Object> queryOrder(OrderQueryCriteria criteria) { - Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); - return new ResponseEntity<>(R.success(orderService.queryAll(criteria, page)), HttpStatus.OK); - } - - @GetMapping("app") - @ApiOperation("APP:查询订单信息") - @PreAuthorize("@el.check('order:list')") - public ResponseEntity<Object> appQueryOrder(OrderQueryCriteria criteria) { - if (criteria.getStoreId() == null) { - throw new BadRequestException("请选择门店"); - } Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); return new ResponseEntity<>(R.success(orderService.queryAll(criteria, page)), HttpStatus.OK); } diff --git a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderAddressSnapshotServiceImpl.java b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderAddressSnapshotServiceImpl.java index a137b6f..6438a09 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderAddressSnapshotServiceImpl.java +++ b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderAddressSnapshotServiceImpl.java @@ -70,7 +70,7 @@ List<Map<String, Object>> list = new ArrayList<>(); for (OrderAddressSnapshot orderAddressSnapshot : all) { Map<String, Object> map = new LinkedHashMap<>(); - map.put("订单ID", orderAddressSnapshot.getOrderId()); + map.put("订单号", orderAddressSnapshot.getOrderNum()); map.put("收货人姓名", orderAddressSnapshot.getReceiverName()); map.put("收货人电话", orderAddressSnapshot.getReceiverPhone()); map.put("省份", orderAddressSnapshot.getProvince()); diff --git a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java index aaae919..243f9ea 100644 --- a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java +++ b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderServiceImpl.java @@ -10,12 +10,15 @@ import com.oying.modules.pc.store.domain.Store; import com.oying.modules.pc.store.service.StoreService; import com.oying.modules.sh.domain.Order; +import com.oying.modules.sh.domain.OrderAddressSnapshot; import com.oying.modules.sh.domain.OrderProductSnapshot; +import com.oying.modules.sh.domain.UserAddress; import com.oying.modules.sh.domain.request.GeneratorOrder; import com.oying.modules.sh.domain.request.ProductOrder; import com.oying.modules.sh.domain.request.SubmitOrder; import com.oying.modules.sh.domain.vo.OrderInfo; import com.oying.modules.sh.domain.vo.ProductInfo; +import com.oying.modules.sh.service.OrderAddressSnapshotService; import com.oying.modules.sh.service.OrderProductSnapshotService; import com.oying.modules.sh.service.UserAddressService; import com.oying.utils.*; @@ -53,13 +56,17 @@ private final ProductService productService; private final SwiftPassService swiftPassService; private final OrderProductSnapshotService productSnapshotService; + private final OrderAddressSnapshotService addressSnapshotService; private final RedisUtils redisUtils; private final StoreService storeService; private final static String DESCRIBE = "哦应:"; @Override public PageResult<Order> queryAll(OrderQueryCriteria criteria, Page<Object> page) { - return PageUtil.toPage(orderMapper.findAll(criteria, page)); + criteria.setOffset(page.offset()); + List<Order> list = orderMapper.findAll(criteria); + Long total = orderMapper.countAll(criteria); + return PageUtil.toPage(list, total); } @Override @@ -70,8 +77,12 @@ @Override @Transactional(rollbackFor = Exception.class) public synchronized Order submitOrder(SubmitOrder submit, HttpServletRequest request) { - if (!submit.getPayType().equals(PayTypeEnum.HWC)) { - throw new BadRequestException("支付类型暂未开放"); + switch (submit.getPayType()) { + case HWC: + case HWC2: + break; + default: + throw new BadRequestException("支付类型暂未开放"); } String orderNum = redisUtils.generateOrderSn(GenerateEnum.ORDER.getKey()); // 总金额 @@ -82,7 +93,6 @@ OrderInfo info = generatorOrder(generator); // 商品快照 List<OrderProductSnapshot> snapshots = new ArrayList<>(); - for (ProductInfo productInfo : info.getProducts()) { Product product = productInfo.getProduct(); OrderProductSnapshot snapshot = new OrderProductSnapshot(); @@ -117,6 +127,8 @@ order.setOrderNum(orderNum); order.setOrderStatus(OrderStatusEnum.ZERO.getKey()); order.setOrderStatusDescribe(OrderStatusEnum.ZERO.getValue()); + order.setOrderRemark(submit.getRemark() != null ? submit.getRemark() : ""); + order.setOrderTime(submit.getDateTime()); order.setUserId(SecurityUtils.getCurrentUserId()); order.setUsername(SecurityUtils.getCurrentUsername()); Store store = storeService.getById(submit.getStoreId()); @@ -150,11 +162,31 @@ order.setPayMessage(PayStateEnum.SUCCESS.getValue()); order.setPayTime(DateUtil.localDateTimeFormat(now.toLocalDateTime(), DateUtil.SDF_YMDHMS)); } + UserAddress address = userAddressService.getById(submit.getAddressId()); + OrderAddressSnapshot snapshot = getOrderAddressSnapshot(orderNum, address); + addressSnapshotService.save(snapshot); orderMapper.insert(order); productSnapshotService.saveBatch(snapshots); return order; } + private static OrderAddressSnapshot getOrderAddressSnapshot(String orderNum, UserAddress address) { + OrderAddressSnapshot snapshot = new OrderAddressSnapshot(); + snapshot.setOrderNum(orderNum); + snapshot.setReceiverName(address.getReceiverName()); + snapshot.setReceiverPhone(address.getReceiverPhone()); + snapshot.setProvince(address.getProvince() != null ? address.getProvince() : ""); + snapshot.setCity(address.getCity() != null ? address.getCity() : ""); + snapshot.setDistrict(address.getDistrict() != null ? address.getDistrict() : ""); + snapshot.setStreet(address.getStreet() != null ? address.getStreet() : ""); + snapshot.setShortAddress(address.getShortAddress()); + snapshot.setDetail(address.getDetail()); + snapshot.setLongitude(address.getLongitude()); + snapshot.setLatitude(address.getLatitude()); + snapshot.setTag(address.getTag()); + return snapshot; + } + @Override @Transactional(rollbackFor = Exception.class) public synchronized OrderInfo generatorOrder(GeneratorOrder criteria) { diff --git a/oying-system/src/main/java/com/oying/modules/system/domain/Merchant.java b/oying-system/src/main/java/com/oying/modules/system/domain/Merchant.java index 3c6a316..7d443e4 100644 --- a/oying-system/src/main/java/com/oying/modules/system/domain/Merchant.java +++ b/oying-system/src/main/java/com/oying/modules/system/domain/Merchant.java @@ -34,7 +34,6 @@ @ApiModelProperty(value = "名称") private String merchantName; - @NotBlank @ApiModelProperty(value = "商户编码") private String merchantCode; diff --git a/oying-system/src/main/java/com/oying/modules/system/service/impl/MerchantServiceImpl.java b/oying-system/src/main/java/com/oying/modules/system/service/impl/MerchantServiceImpl.java index f8e0219..fc2cc34 100644 --- a/oying-system/src/main/java/com/oying/modules/system/service/impl/MerchantServiceImpl.java +++ b/oying-system/src/main/java/com/oying/modules/system/service/impl/MerchantServiceImpl.java @@ -1,5 +1,6 @@ package com.oying.modules.system.service.impl; +import cn.hutool.core.util.IdUtil; import com.oying.modules.system.domain.Merchant; import com.oying.modules.system.domain.UserMerchant; import com.oying.modules.system.mapper.MerchantMapper; @@ -47,6 +48,7 @@ @Override @Transactional(rollbackFor = Exception.class) public void create(Merchant resources) { + resources.setMerchantCode(IdUtil.getSnowflakeNextIdStr()); merchantMapper.insert(resources); UserMerchant userMerchant = new UserMerchant(); userMerchant.setMerchantId(resources.getMerchantId()); diff --git a/oying-system/src/main/resources/config/application-dev.yml b/oying-system/src/main/resources/config/application-dev.yml index afb8b1c..36ab729 100644 --- a/oying-system/src/main/resources/config/application-dev.yml +++ b/oying-system/src/main/resources/config/application-dev.yml @@ -173,7 +173,7 @@ # 支付通知地址 notify-url: http://1.95.124.88:8088/api/swiftPass/alipayCallback # 退款通知地址 - refund-url: https://1.95.124.88:8088/api/swiftPass/returnNotify + refund-url: http://1.95.124.88:8088/api/swiftPass/returnNotify obs: access_key_id: RZ1UIOZDZ58DD4NWPD6Q diff --git a/oying-system/src/main/resources/config/application-prod.yml b/oying-system/src/main/resources/config/application-prod.yml index 2f4bb75..02030c1 100644 --- a/oying-system/src/main/resources/config/application-prod.yml +++ b/oying-system/src/main/resources/config/application-prod.yml @@ -184,7 +184,7 @@ # 支付通知地址 notify-url: http://1.95.124.88:8088/api/swiftPass/alipayCallback # 退款通知地址 - refund-url: https://1.95.124.88:8088/api/swiftPass/returnNotify + refund-url: http://1.95.124.88:8088/api/swiftPass/returnNotify obs: access_key_id: RZ1UIOZDZ58DD4NWPD6Q diff --git a/oying-system/src/main/resources/mapper/sh/OrderAddressSnapshotMapper.xml b/oying-system/src/main/resources/mapper/sh/OrderAddressSnapshotMapper.xml index 10dd77d..c7d07c8 100644 --- a/oying-system/src/main/resources/mapper/sh/OrderAddressSnapshotMapper.xml +++ b/oying-system/src/main/resources/mapper/sh/OrderAddressSnapshotMapper.xml @@ -3,13 +3,14 @@ <mapper namespace="com.oying.modules.sh.mapper.OrderAddressSnapshotMapper"> <resultMap id="BaseResultMap" type="com.oying.modules.sh.domain.OrderAddressSnapshot"> <id column="snapshot_id" property="snapshotId"/> - <result column="order_id" property="orderId"/> + <result column="order_num" property="orderNum"/> <result column="receiver_name" property="receiverName"/> <result column="receiver_phone" property="receiverPhone"/> <result column="province" property="province"/> <result column="city" property="city"/> <result column="district" property="district"/> <result column="street" property="street"/> + <result column="short_address" property="shortAddress"/> <result column="detail" property="detail"/> <result column="longitude" property="longitude"/> <result column="latitude" property="latitude"/> @@ -17,7 +18,7 @@ </resultMap> <sql id="Base_Column_List"> - snapshot_id, order_id, receiver_name, receiver_phone, province, city, district, street, detail, longitude, latitude, tag + snapshot_id, order_num, receiver_name, receiver_phone, province, city, district, street, short_address, detail, longitude, latitude, tag </sql> <select id="findAll" resultMap="BaseResultMap"> @@ -25,8 +26,8 @@ <include refid="Base_Column_List"/> from sh_order_address_snapshot <where> - <if test="criteria.orderId != null"> - and order_id = #{criteria.orderId} + <if test="criteria.orderNum != null"> + and order_num = #{criteria.orderNum} </if> </where> order by snapshot_id desc diff --git a/oying-system/src/main/resources/mapper/sh/OrderMapper.xml b/oying-system/src/main/resources/mapper/sh/OrderMapper.xml index 7162d03..bd2fb2c 100644 --- a/oying-system/src/main/resources/mapper/sh/OrderMapper.xml +++ b/oying-system/src/main/resources/mapper/sh/OrderMapper.xml @@ -6,6 +6,8 @@ <result column="order_num" property="orderNum"/> <result column="order_status" property="orderStatus"/> <result column="order_status_describe" property="orderStatusDescribe"/> + <result column="order_remark" property="orderRemark"/> + <result column="order_time" property="orderTime"/> <result column="user_id" property="userId"/> <result column="username" property="username"/> <result column="store_id" property="storeId"/> @@ -31,63 +33,166 @@ <result column="create_time" property="createTime"/> <result column="update_by" property="updateBy"/> <result column="update_time" property="updateTime"/> + <collection property="productSnapshots" ofType="com.oying.modules.sh.domain.OrderProductSnapshot"> + <id column="snapshot_id" property="snapshotId"/> + <result column="product_id" property="productId"/> + <result column="product_code" property="productCode"/> + <result column="product_barcode" property="productBarcode"/> + <result column="product_name" property="productName"/> + <result column="product_title" property="productTitle"/> + <result column="product_main_image" property="productMainImage"/> + <result column="product_description" property="productDescription"/> + <result column="param_data" property="paramData"/> + <result column="unit_price" property="unitPrice"/> + <result column="detail_count" property="detailCount"/> + <result column="original_price" property="originalPrice"/> + <result column="paid_price" property="paidPrice"/> + <result column="actually_pay_price" property="actuallyPayPrice"/> + <result column="pay_state" property="payState"/> + </collection> </resultMap> <sql id="Base_Column_List"> - order_id, order_num, order_status, order_status_describe, user_id, username, store_id, store_name, store_logo, order_describe, original_price, paid_price, actually_pay_price, pay_state, pay_message, pay_type, pay_time, expire_time, openid, app_id, timestamp, nonce_str, package_val, sign_type, pay_sign, create_by, create_time, update_by, update_time + o.order_id, o.order_num, o.order_status, o.order_status_describe, o.order_remark, o.order_time, o.user_id, o.username, o.store_id, + o.store_name, o.store_logo, o.order_describe, o.original_price, o.paid_price, o.actually_pay_price, o.pay_state, o.pay_message, + o.pay_type, o.pay_time, o.expire_time, o.openid, o.app_id, o.timestamp, o.nonce_str, o.package_val, o.sign_type, o.pay_sign, + o.create_by, o.create_time, o.update_by, o.update_time + </sql> + + <sql id="product_Column_List"> + p.snapshot_id, p.product_id, p.product_code, p.product_barcode, p.product_name, p.product_title, + p.product_main_image, p.product_description, p.param_data, p.unit_price, p.detail_count, p.original_price, p.paid_price, + p.actually_pay_price, p.pay_state </sql> <update id="updatePayStatus"> - update sh_order set pay_state = #{payState}, pay_message = #{payMessage}, - pay_time = #{payTime} where order_num = #{orderNum} + update sh_order + set pay_state = #{payState}, + pay_message = #{payMessage}, + pay_time = #{payTime} + where order_num = #{orderNum} </update> <update id="updateCloseStatus"> - update sh_order set pay_state = #{payState} where order_num = #{orderNum} + update sh_order + set pay_state = #{payState} + where order_num = #{orderNum} </update> <select id="findAll" resultMap="BaseResultMap"> + select o.*, + <include refid="product_Column_List"/> + from ( select <include refid="Base_Column_List"/> - from sh_order + from sh_order as o <where> <if test="criteria.orderNum != null and criteria.orderNum != ''"> - and order_num like concat('%',#{criteria.orderNum},'%') + and o.order_num like concat('%',#{criteria.orderNum},'%') </if> <if test="criteria.orderStatus != null and criteria.orderStatus != ''"> - and order_status = #{criteria.orderStatus} + and o.order_status = #{criteria.orderStatus} </if> <if test="criteria.userId != null and criteria.userId != ''"> - and user_id = #{criteria.userId} + and o.user_id = #{criteria.userId} </if> <if test="criteria.username != null and criteria.username != ''"> - and username like concat('%',#{criteria.username},'%') + and o.username like concat('%',#{criteria.username},'%') </if> <if test="criteria.storeId != null and criteria.storeId != ''"> - and store_id = #{criteria.storeId} + and o.store_id = #{criteria.storeId} </if> <if test="criteria.orderDescribe != null and criteria.orderDescribe != ''"> - and order_describe like concat('%',#{criteria.orderDescribe},'%') + and o.order_describe like concat('%',#{criteria.orderDescribe},'%') </if> <if test="criteria.payState != null and criteria.payState != ''"> - and pay_state = #{criteria.payState} + and o.pay_state = #{criteria.payState} </if> <if test="criteria.payType != null and criteria.payType != ''"> - and pay_type = #{criteria.payType} + and o.pay_type = #{criteria.payType} </if> <if test="criteria.payTime != null and criteria.payTime.size() > 0"> - AND pay_time BETWEEN #{criteria.payTime[0]} AND #{criteria.payTime[1]} + AND o.pay_time BETWEEN #{criteria.payTime[0]} AND #{criteria.payTime[1]} </if> <if test="criteria.createTime != null and criteria.createTime.size() > 0"> - AND create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]} + AND o.create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]} </if> </where> - order by order_id desc + order by o.order_id desc + <if test="criteria.offset != null"> + limit #{criteria.offset}, #{criteria.size} + </if> + ) o + left join sh_order_product_snapshot as p on p.order_num = o.order_num + where 1=1 + <if test="criteria.blurry != null and criteria.blurry != ''"> + and (o.product_code like concat('%',#{criteria.blurry},'%') + or o.product_barcode like concat('%',#{criteria.blurry},'%') + or o.product_name like concat('%',#{criteria.blurry},'%') + or o.product_title like concat('%',#{criteria.blurry},'%') + or o.product_description like concat('%',#{criteria.blurry},'%')) + </if> + order by o.order_id desc </select> <select id="getByOrderNum" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> - from sh_order - where order_num = #{orderNum} + from sh_order as o + where o.order_num = #{orderNum} + </select> + <select id="countAll" resultType="java.lang.Long"> + select count(1) + from ( select distinct o.*, + p.product_code, + p.product_barcode, + p.product_name, + p.product_title, + p.product_description + from ( + select + <include refid="Base_Column_List"/> + from sh_order as o + <where> + <if test="criteria.orderNum != null and criteria.orderNum != ''"> + and o.order_num like concat('%',#{criteria.orderNum},'%') + </if> + <if test="criteria.orderStatus != null and criteria.orderStatus != ''"> + and o.order_status = #{criteria.orderStatus} + </if> + <if test="criteria.userId != null and criteria.userId != ''"> + and o.user_id = #{criteria.userId} + </if> + <if test="criteria.username != null and criteria.username != ''"> + and o.username like concat('%',#{criteria.username},'%') + </if> + <if test="criteria.storeId != null and criteria.storeId != ''"> + and o.store_id = #{criteria.storeId} + </if> + <if test="criteria.orderDescribe != null and criteria.orderDescribe != ''"> + and o.order_describe like concat('%',#{criteria.orderDescribe},'%') + </if> + <if test="criteria.payState != null and criteria.payState != ''"> + and o.pay_state = #{criteria.payState} + </if> + <if test="criteria.payType != null and criteria.payType != ''"> + and o.pay_type = #{criteria.payType} + </if> + <if test="criteria.payTime != null and criteria.payTime.size() > 0"> + AND o.pay_time BETWEEN #{criteria.payTime[0]} AND #{criteria.payTime[1]} + </if> + <if test="criteria.createTime != null and criteria.createTime.size() > 0"> + AND o.create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]} + </if> + </where> + ) o + left join sh_order_product_snapshot as p on p.order_num = o.order_num + where 1=1 + <if test="criteria.blurry != null and criteria.blurry != ''"> + and (p.product_code like concat('%',#{criteria.blurry},'%') + or p.product_barcode like concat('%',#{criteria.blurry},'%') + or p.product_name like concat('%',#{criteria.blurry},'%') + or p.product_title like concat('%',#{criteria.blurry},'%') + or p.product_description like concat('%',#{criteria.blurry},'%')) + </if>) t </select> </mapper> -- Gitblit v1.9.3