2 files added
12 files modified
| | |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long userId; |
| | | |
| | | @NotBlank |
| | | @ApiModelProperty(value = "用户账号") |
| | | private String username; |
| | | |
| | | @NotNull |
| | | @ApiModelProperty(value = "门店ID") |
| | | private Long storeId; |
| | |
| | | @ApiModelProperty(value = "用户") |
| | | private Long userId; |
| | | |
| | | @NotBlank |
| | | @ApiModelProperty(value = "用户账号") |
| | | private String username; |
| | | |
| | | @NotNull |
| | | @ApiModelProperty(value = "门店ID") |
| | | private Long storeId; |
| | |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "用户账号") |
| | | private String username; |
| | | |
| | | @ApiModelProperty(value = "门店ID") |
| | | private Long storeId; |
| | | |
| | |
| | | @ApiModelProperty(value = "用户") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "用户账号") |
| | | private String username; |
| | | |
| | | @ApiModelProperty(value = "门店ID") |
| | | private Long storeId; |
| | | |
| | |
| | | public class GeneratorOrder { |
| | | |
| | | @ApiModelProperty(value = "门店ID") |
| | | private String storeId; |
| | | private Long storeId; |
| | | @ApiModelProperty(value = "商品&数量") |
| | | private List<ProductOrder> products; |
| | | } |
| | |
| | | @ApiModelProperty(value = "送达时间") |
| | | private Timestamp dateTime; |
| | | @ApiModelProperty(value = "门店ID") |
| | | private String storeId; |
| | | private Long storeId; |
| | | @ApiModelProperty(value = "商品&数量") |
| | | private List<ProductOrder> products; |
| | | @ApiModelProperty(value = "备注") |
New file |
| | |
| | | package com.oying.modules.sh.domain.vo; |
| | | |
| | | import com.oying.modules.sh.domain.UserAddress; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author xin |
| | | * @description |
| | | * @date 2025/7/4 16:27 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | public class OrderInfo { |
| | | |
| | | @ApiModelProperty(value = "商品信息列") |
| | | private List<ProductInfo> products; |
| | | @ApiModelProperty(value = "用户地址信息") |
| | | private List<UserAddress> userAddresses; |
| | | @ApiModelProperty(value = "商品总金额") |
| | | private BigDecimal amount = BigDecimal.ZERO; |
| | | @ApiModelProperty(value = "应付金额") |
| | | private BigDecimal payAmount = BigDecimal.ZERO; |
| | | @ApiModelProperty(value = "活动优惠") |
| | | private BigDecimal promotionAmount = BigDecimal.ZERO; |
| | | @ApiModelProperty(value = "优惠卷待定") |
| | | private Object coupon; |
| | | @ApiModelProperty(value = "运费待定") |
| | | private Object shippingFee; |
| | | @ApiModelProperty(value = "打包费待定") |
| | | private Object packingCharges; |
| | | } |
New file |
| | |
| | | package com.oying.modules.sh.domain.vo; |
| | | |
| | | import com.oying.modules.pc.product.domain.Product; |
| | | import com.oying.modules.pc.product.domain.ProductLabel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author xin |
| | | * @description |
| | | * @date 2025/7/4 15:45 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | public class ProductInfo { |
| | | |
| | | @ApiModelProperty(value = "商品信息") |
| | | private Product product; |
| | | @ApiModelProperty(value = "商品标签") |
| | | private List<ProductLabel> productLabels; |
| | | @ApiModelProperty(value = "商品数量") |
| | | private Integer count = 1; |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.oying.modules.sh.domain.request.GeneratorOrder; |
| | | import com.oying.modules.sh.domain.request.SubmitOrder; |
| | | import com.oying.modules.sh.domain.vo.OrderInfo; |
| | | import com.oying.utils.PageResult; |
| | | |
| | | /** |
| | |
| | | */ |
| | | List<Order> queryAll(OrderQueryCriteria criteria); |
| | | |
| | | Map<String, Object> generatorOrder(GeneratorOrder generator); |
| | | OrderInfo generatorOrder(GeneratorOrder generator); |
| | | |
| | | Order submitOrder(SubmitOrder submit); |
| | | |
| | |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<UserAddress> all, HttpServletResponse response) throws IOException; |
| | | |
| | | List<UserAddress> queryUserAddress(); |
| | | } |
| | |
| | | package com.oying.modules.sh.service.impl; |
| | | |
| | | import com.oying.exception.BadRequestException; |
| | | import com.oying.modules.pc.product.domain.Product; |
| | | import com.oying.modules.pc.product.domain.enums.ProductStatusEnum; |
| | | import com.oying.modules.pc.product.service.ProductService; |
| | | import com.oying.modules.sh.domain.Order; |
| | | 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.UserAddressService; |
| | | import com.oying.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.oying.utils.PageUtil; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | import com.oying.utils.PageResult; |
| | | |
| | | /** |
| | | * @description 服务实现 |
| | | * @author lixin |
| | | * @date 2025-06-11 |
| | | **/ |
| | | * @author lixin |
| | | * @description 服务实现 |
| | | * @date 2025-06-11 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { |
| | | |
| | | private final OrderMapper orderMapper; |
| | | private final UserAddressService userAddressService; |
| | | private final ProductService productService; |
| | | |
| | | @Override |
| | | public PageResult<Order> queryAll(OrderQueryCriteria criteria, Page<Object> page){ |
| | | public PageResult<Order> queryAll(OrderQueryCriteria criteria, Page<Object> page) { |
| | | return PageUtil.toPage(orderMapper.findAll(criteria, page)); |
| | | } |
| | | |
| | | @Override |
| | | public List<Order> queryAll(OrderQueryCriteria criteria){ |
| | | public List<Order> queryAll(OrderQueryCriteria criteria) { |
| | | return orderMapper.findAll(criteria); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> generatorOrder(GeneratorOrder generator) { |
| | | return Collections.emptyMap(); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public OrderInfo generatorOrder(GeneratorOrder criteria) { |
| | | List<ProductInfo> products = new ArrayList<>(); |
| | | BigDecimal amount = BigDecimal.ZERO; |
| | | for (ProductOrder productOrder : criteria.getProducts()) { |
| | | Product product = productService.getById(productOrder.getProductId()); |
| | | if (product == null) { |
| | | throw new BadRequestException("商品不存在"); |
| | | } |
| | | if (product.getStoreId().equals(criteria.getStoreId())) { |
| | | throw new BadRequestException("不支持跨门店下单"); |
| | | } |
| | | if (!product.getStatus().equals(ProductStatusEnum.AVAILABLE.getValue())) { |
| | | ProductStatusEnum statusEnum = ProductStatusEnum.get(product.getStatus()); |
| | | throw new BadRequestException(product.getName() + ":" + (statusEnum != null ? statusEnum.getReasonPhrase() : "状态")); |
| | | } |
| | | if (productOrder.getProductCount() > product.getStockQuantity()) { |
| | | throw new BadRequestException("商品库存不足"); |
| | | } |
| | | if (productOrder.getProductCount() < product.getMinPurchaseQuantity()) { |
| | | throw new BadRequestException("起售数量不足"); |
| | | } |
| | | ProductInfo info = new ProductInfo(); |
| | | info.setProduct(product); |
| | | info.setProductLabels(product.getLabels()); |
| | | info.setCount(productOrder.getProductCount()); |
| | | products.add(info); |
| | | amount = amount.add(product.getPrice().multiply(BigDecimal.valueOf(productOrder.getProductCount()))); |
| | | } |
| | | OrderInfo info = new OrderInfo(); |
| | | info.setProducts(products); |
| | | info.setAmount(amount); |
| | | info.setPayAmount(amount); |
| | | info.setPromotionAmount(BigDecimal.ZERO); |
| | | info.setUserAddresses(userAddressService.queryUserAddress()); |
| | | return info; |
| | | } |
| | | |
| | | @Override |
| | |
| | | map.put("订单号", order.getOrderNum()); |
| | | map.put("用户id", order.getUserId()); |
| | | map.put("门店ID", order.getStoreId()); |
| | | map.put("门店", order.getStoreName()); |
| | | map.put("描述", order.getOrderDescribe()); |
| | | map.put("原金额", order.getOriginalPrice()); |
| | | map.put("折扣价", order.getPaidPrice()); |
| | |
| | | map.put("订单失效时间RFC3339", order.getExpireTime()); |
| | | map.put("openid", order.getOpenid()); |
| | | map.put("APPID", order.getAppId()); |
| | | map.put("时间戳", order.getTimestamp()); |
| | | map.put(" nonceStr", order.getNonceStr()); |
| | | map.put(" packageVal", order.getPackageVal()); |
| | | map.put(" signType", order.getSignType()); |
| | | map.put("签名", order.getPaySign()); |
| | | map.put("创建人", order.getCreateBy()); |
| | | map.put("创建时间", order.getCreateTime()); |
| | | map.put("修改者", order.getUpdateBy()); |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.oying.utils.PageUtil; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | import com.oying.utils.PageResult; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<UserAddress> queryUserAddress() { |
| | | UserAddressQueryCriteria criteria = new UserAddressQueryCriteria(); |
| | | criteria.setUserId(SecurityUtils.getCurrentUserId()); |
| | | return queryAll(criteria); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(UserAddress resources) { |
| | | if (resources.getIsDefault()) { |
| | |
| | | <result column="order_status" property="orderStatus"/> |
| | | <result column="order_status_describe" property="orderStatusDescribe"/> |
| | | <result column="user_id" property="userId"/> |
| | | <result column="username" property="username"/> |
| | | <result column="store_id" property="storeId"/> |
| | | <result column="store_name" property="storeName"/> |
| | | <result column="store_logo" property="storeLogo"/> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | order_id, order_num, order_status, order_status_describe, user_id, 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 |
| | | 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 |
| | | </sql> |
| | | |
| | | <select id="findAll" resultMap="BaseResultMap"> |
| | |
| | | <if test="criteria.userId != null"> |
| | | and user_id = #{criteria.userId} |
| | | </if> |
| | | <if test="criteria.username != null"> |
| | | and username like concat('%',#{criteria.username},'%') |
| | | </if> |
| | | <if test="criteria.storeId != null"> |
| | | and store_id = #{criteria.storeId} |
| | | </if> |
| | |
| | | <result column="return_status_describe" property="returnStatusDescribe"/> |
| | | <result column="order_num" property="orderNum"/> |
| | | <result column="user_id" property="userId"/> |
| | | <result column="username" property="username"/> |
| | | <result column="store_id" property="storeId"/> |
| | | <result column="store_name" property="storeName"/> |
| | | <result column="store_logo" property="storeLogo"/> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | return_id, return_num, return_status, return_status_describe, order_num, user_id, store_id, store_name, store_logo, original_price, paid_price, actually_pay_price, refund_price, refund_status, success_time, channel, reason, remark, photos, audit_status, audit_user, audit_time, audit_message, create_by, create_time, update_by, update_time |
| | | return_id, return_num, return_status, return_status_describe, order_num, user_id, username, store_id, store_name, store_logo, original_price, paid_price, actually_pay_price, refund_price, refund_status, success_time, channel, reason, remark, photos, audit_status, audit_user, audit_time, audit_message, create_by, create_time, update_by, update_time |
| | | </sql> |
| | | |
| | | <select id="findAll" resultMap="BaseResultMap"> |
| | |
| | | <if test="criteria.userId != null"> |
| | | and user_id = #{criteria.userId} |
| | | </if> |
| | | <if test="criteria.username != null"> |
| | | and username like concat('%',#{criteria.username},'%') |
| | | </if> |
| | | <if test="criteria.storeId != null"> |
| | | and store_id = #{criteria.storeId} |
| | | </if> |