4 Commits 2f0fffd3f1 ... 3be09a2647

Autor SHA1 Mensagem Data
  pangqijun 3be09a2647 Merge remote-tracking branch 'origin/dev' into dev 3 meses atrás
  pangqijun 1199b9810f Merge remote-tracking branch 'origin/dev' into dev 3 meses atrás
  pangqijun 2385937f2c Merge branch 'dev' of http://gogs.gzzzyd.com/pangqijun/vending-machine-api into dev 3 meses atrás
  pangqijun 6486d15956 feat: 修改小程序查询订单接口 3 meses atrás

+ 5 - 1
src/main/java/org/springblade/modules/api/controller/ApiOrderGoodsController.java

@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @AllArgsConstructor
 @RequestMapping(CommonConstant.API_URL + "/orderGoods")
-@Api(value = "商品订单接口", tags = "商品订单接口")
+@Api(value = "移动端商品订单接口", tags = "移动端商品订单接口")
 public class ApiOrderGoodsController {
 
     private final IOrderGoodsService iOrderGoodsService;
@@ -69,6 +69,10 @@ public class ApiOrderGoodsController {
         Assert.notNull(orderGoods, "未查询到商品订单信息");
         OrderGoodsVO orderGoodsVO = OrderGoodsWrapper.build().entityVO(orderGoods);
         orderGoodsVO.setOrderState(order.getOrderState());
+        orderGoodsVO.setOrderNo(order.getOrderNo());
+        orderGoodsVO.setPaymentAmount(order.getPaymentAmount());
+        orderGoodsVO.setTotalAmount(order.getTotalAmount());
+        orderGoodsVO.setDiscountAmount(order.getDiscountAmount());
         return R.data(orderGoodsVO);
     }
 

+ 1 - 1
src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.java

@@ -39,7 +39,7 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
 	 * @param orderGoods
 	 * @return
 	 */
-	List<OrderGoodsVO> selectOrderGoodsPage(IPage page, OrderGoodsVO orderGoods);
+	List<OrderGoodsVO> selectOrderGoodsPage(IPage page, @Param("p") OrderGoodsVO orderGoods);
 
 	/**
 	 * 查询用户订单

+ 44 - 3
src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.xml

@@ -27,16 +27,53 @@
     </resultMap>
 
 
-    <select id="selectOrderGoodsPage" resultMap="orderGoodsResultMap">
+    <select id="selectOrderGoodsPage" resultType="org.springblade.modules.finance.vo.OrderGoodsVO">
         SELECT
             og.*,
+            o.order_no,
             o.order_state,
-            o.is_aftersales
+            o.is_aftersales,
+            u.`name` nickname,
+            o.payment_mode,
+            o.payment_time,
+            o.payment_state,
+            o.payment_amount,
+            o.total_amount,
+            o.discount_amount,
+            o.third_order_no
         FROM
             t_order o
             JOIN t_order_goods og ON o.id = og.order_id
-
+            JOIN blade_user u on o.user_id = u.id
+        WHERE
+        o.is_delete = 0
+        <if test="@cn.hutool.core.util.StrUtil@isNotBlank(p.orderNo)">
+            and instr(o.order_no, #{p.orderNo}) > 0
+        </if>
+        <if test="@cn.hutool.core.util.StrUtil@isNotBlank(p.phone)">
+            and instr(u.phone, #{p.phone}) > 0
+        </if>
+        <if test="p.orderState != null">
+            and o.order_state = #{p.orderState}
+        </if>
+        <if test="p.goodsId != null">
+            and og.goods_id = #{p.goodsId}
+        </if>
+        <if test="p.merchantId != null">
+            and og.merchant_id = #{p.merchantId}
+        </if>
+        <if test="p.shopId != null">
+            and og.shop_id = #{p.shopId}
+        </if>
+        <if test="p.startTime != null">
+            and o.create_time <![CDATA[ >= ]]> #{p.startTime}
+        </if>
+        <if test="p.endTime != null">
+            and o.create_time <![CDATA[ <= ]]> #{p.endTime}
+        </if>
+        order by o.create_time desc
     </select>
+
     <select id="selectUserOrder" resultType="org.springblade.modules.finance.vo.OrderGoodsVO">
         SELECT
             og.*,
@@ -47,6 +84,10 @@
             t_order o
             JOIN t_order_goods og ON o.id = og.order_id
         WHERE o.is_delete = 0 and o.user_id = #{p.userId}
+        <if test="p.orderState != 0">
+            and o.order_state = #{p.orderState}
+        </if>
+        ORDER BY o.create_time desc
     </select>
 
     <select id="getMerchantOrder" resultType="org.springblade.modules.finance.vo.MerchantPageOrderVO">

+ 6 - 0
src/main/java/org/springblade/modules/finance/service/impl/OrderGoodsServiceImpl.java

@@ -19,6 +19,8 @@ import org.springblade.modules.finance.service.IOrderGoodsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.modules.mall.entity.GoodsInfo;
 import org.springblade.modules.mall.service.IGoodsInfoService;
+import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IUserService;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
@@ -39,6 +41,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 	private final IGoodsInfoService iGoodsInfoService;
 	private final IFacilityCargoWayService iFacilityCargoWayService;
 	private final IShopService iShopService;
+	private final IUserService iUserService;
 
 	@Override
 	public IPage<OrderGoodsVO> selectOrderGoodsPage(IPage<OrderGoodsVO> page, OrderGoodsVO orderGoods) {
@@ -64,6 +67,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 		Assert.notNull(cargoWay, "货道信息不存在");
 		Shop shop = iShopService.getById(request.getShopId());
 		Assert.notNull(shop, "门店信息不存在");
+		User user = iUserService.getById(request.getUserId());
 
 		// 订单初始化
 		Order order = iOrderService.init();
@@ -77,6 +81,8 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 		BigDecimal payAmount = cargoWay.getSalePrice().multiply(BigDecimal.valueOf(cargoWay.getDiscount())).multiply(BigDecimal.valueOf(request.getGoodsNum()));
 		order.setPaymentAmount(payAmount);
 		order.setDiscountAmount(order.getTotalAmount().subtract(order.getPaymentAmount()));
+		order.setConsignee(user.getName());
+		order.setConsigneePhoneNumber(user.getPhone());
 		iOrderService.save(order);
 
 		OrderGoods orderGoods = new OrderGoods();

+ 26 - 0
src/main/java/org/springblade/modules/finance/vo/OrderGoodsVO.java

@@ -18,11 +18,15 @@ package org.springblade.modules.finance.vo;
 
 import io.swagger.annotations.ApiModelProperty;
 import org.springblade.common.enums.OrderStateEnum;
+import org.springblade.common.enums.PaymentTypeEnum;
 import org.springblade.modules.finance.entity.OrderGoods;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import io.swagger.annotations.ApiModel;
 
+import java.math.BigDecimal;
+import java.util.Date;
+
 /**
  * 商品订单表视图实体类
  *
@@ -39,6 +43,28 @@ public class OrderGoodsVO extends OrderGoods {
 	private Integer orderState;
 	@ApiModelProperty(value = "订单状态描述")
 	private String orderStateDesc;
+	private String orderNo;
+	private String phone;
+	private String nickname;
+	private Date startTime;
+	private Date endTime;
+	private String payModeDesc;
+	@ApiModelProperty(value = "支付金额")
+	private BigDecimal paymentAmount;
+	@ApiModelProperty(value = "支付方式")
+	private String paymentMode;
+	@ApiModelProperty(value = "支付时间")
+	private Date paymentTime;
+	@ApiModelProperty(value = "支付状态;1-未支付 2-已支付 3-已退款")
+	private Integer paymentState;
+	@ApiModelProperty(value = "总金额")
+	private BigDecimal totalAmount;
+	@ApiModelProperty(value = "优惠金额")
+	private BigDecimal discountAmount;
+
+	public String getPayModeDesc() {
+		return PaymentTypeEnum.getNameByValue(paymentMode);
+	}
 
 	public String getOrderStateDesc() {
 		return OrderStateEnum.getNameByValue(orderState);

+ 2 - 1
src/main/java/org/springblade/modules/resource/builder/oss/OssBuilder.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.resource.builder.oss;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.springblade.core.cache.utils.CacheUtil;
@@ -85,7 +86,7 @@ public class OssBuilder {
 	 */
 	public OssTemplate template(String code) {
 		String tenantId = AuthUtil.getTenantId();
-		if(tenantId == null){
+		if(StrUtil.isBlank(tenantId)){
 			tenantId = BladeConstant.ADMIN_TENANT_ID;
 		}
 		Oss oss = getOss(tenantId, code);