Compare commits
No commits in common. "89cc176e907b0604664ad446d28593bcff9472ec" and "4a9055ecd35f46f1546c2de23d743a333b48a787" have entirely different histories.
89cc176e90
...
4a9055ecd3
|
@ -10,9 +10,11 @@ import java.util.List;
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "结算实体类")
|
@Schema(description = "结算实体类")
|
||||||
public class TradeVo {
|
public class TradeVo {
|
||||||
|
|
||||||
@Schema(description = "结算总金额")
|
@Schema(description = "结算总金额")
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
@Schema(description = "结算商品列表")
|
@Schema(description = "结算商品列表")
|
||||||
private List<OrderItem> orderItemList;
|
private List<OrderItem> orderItemList;
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,7 +5,6 @@ import com.atguigu.spzx.model.dto.h5.OrderInfoDto;
|
||||||
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
||||||
import com.atguigu.spzx.model.vo.h5.TradeVo;
|
import com.atguigu.spzx.model.vo.h5.TradeVo;
|
||||||
import com.atguigu.spzx.model.vo.result.Result;
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
@ -39,24 +38,4 @@ public class OrderInfoController {
|
||||||
OrderInfo orderInfo = orderInfoService.getOrderInfo(orderId);
|
OrderInfo orderInfo = orderInfoService.getOrderInfo(orderId);
|
||||||
return Result.success(orderInfo);
|
return Result.success(orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "立即购买")
|
|
||||||
@GetMapping("auth/buy/{skuId}")
|
|
||||||
public Result<TradeVo> buy(@Parameter(name = "skuId", description = "商品skuId", required = true) @PathVariable Long skuId) {
|
|
||||||
TradeVo tradeVo = orderInfoService.buy(skuId);
|
|
||||||
return Result.success(tradeVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "获取订单分页列表")
|
|
||||||
@GetMapping("auth/{page}/{limit}")
|
|
||||||
public Result<PageInfo<OrderInfo>> list(
|
|
||||||
@Parameter(name = "page", description = "当前页码", required = true)
|
|
||||||
@PathVariable Integer page,
|
|
||||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
|
||||||
@PathVariable Integer limit,
|
|
||||||
@Parameter(name = "orderStatus", description = "订单状态", required = false)
|
|
||||||
@RequestParam(required = false, defaultValue = "") Integer orderStatus) {
|
|
||||||
PageInfo<OrderInfo> pageInfo = orderInfoService.findUserPage(page, limit, orderStatus);
|
|
||||||
return Result.success(pageInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -3,8 +3,6 @@ package com.atguigu.order.mapper;
|
||||||
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderInfoMapper {
|
public interface OrderInfoMapper {
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +19,4 @@ public interface OrderInfoMapper {
|
||||||
* @return OrderInfo
|
* @return OrderInfo
|
||||||
*/
|
*/
|
||||||
OrderInfo getById(Long orderId);
|
OrderInfo getById(Long orderId);
|
||||||
|
|
||||||
List<OrderInfo> findUserPage(Long userId, Integer orderStatus);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.atguigu.order.mapper;
|
||||||
import com.atguigu.spzx.model.entity.order.OrderItem;
|
import com.atguigu.spzx.model.entity.order.OrderItem;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderItemMapper {
|
public interface OrderItemMapper {
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +11,4 @@ public interface OrderItemMapper {
|
||||||
* @param orderItem orderItem
|
* @param orderItem orderItem
|
||||||
*/
|
*/
|
||||||
void save(OrderItem orderItem);
|
void save(OrderItem orderItem);
|
||||||
|
|
||||||
List<OrderItem> findByOrderId(Long id);
|
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package com.atguigu.order.service;
|
||||||
import com.atguigu.spzx.model.dto.h5.OrderInfoDto;
|
import com.atguigu.spzx.model.dto.h5.OrderInfoDto;
|
||||||
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
||||||
import com.atguigu.spzx.model.vo.h5.TradeVo;
|
import com.atguigu.spzx.model.vo.h5.TradeVo;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
|
|
||||||
public interface OrderInfoService {
|
public interface OrderInfoService {
|
||||||
/**
|
/**
|
||||||
|
@ -28,22 +27,4 @@ public interface OrderInfoService {
|
||||||
* @return OrderInfo
|
* @return OrderInfo
|
||||||
*/
|
*/
|
||||||
OrderInfo getOrderInfo(Long orderId);
|
OrderInfo getOrderInfo(Long orderId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 立即购买
|
|
||||||
*
|
|
||||||
* @param skuId 商品Id
|
|
||||||
* @return 结算实体类
|
|
||||||
*/
|
|
||||||
TradeVo buy(Long skuId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单分页列表
|
|
||||||
*
|
|
||||||
* @param page page
|
|
||||||
* @param limit limit
|
|
||||||
* @param orderStatus orderStatus
|
|
||||||
* @return PageInfo<OrderInfo>
|
|
||||||
*/
|
|
||||||
PageInfo<OrderInfo> findUserPage(Integer page, Integer limit, Integer orderStatus);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.atguigu.spzx.model.entity.user.UserInfo;
|
||||||
import com.atguigu.spzx.model.vo.h5.TradeVo;
|
import com.atguigu.spzx.model.vo.h5.TradeVo;
|
||||||
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
||||||
import com.atguigu.utils.EmptyUtil;
|
import com.atguigu.utils.EmptyUtil;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -161,54 +160,4 @@ public class OrderInfoServiceImpl implements OrderInfoService {
|
||||||
public OrderInfo getOrderInfo(Long orderId) {
|
public OrderInfo getOrderInfo(Long orderId) {
|
||||||
return orderInfoMapper.getById(orderId);
|
return orderInfoMapper.getById(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 立即购买
|
|
||||||
*
|
|
||||||
* @param skuId 商品Id
|
|
||||||
* @return 结算实体类
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TradeVo buy(Long skuId) {
|
|
||||||
// 查询商品
|
|
||||||
ProductSku productSku = productFeignClient.getBySkuId(skuId).getData();
|
|
||||||
List<OrderItem> orderItemList = new ArrayList<>();
|
|
||||||
OrderItem orderItem = new OrderItem();
|
|
||||||
orderItem.setSkuId(skuId);
|
|
||||||
orderItem.setSkuName(productSku.getSkuName());
|
|
||||||
orderItem.setSkuNum(1);
|
|
||||||
orderItem.setSkuPrice(productSku.getSalePrice());
|
|
||||||
orderItem.setThumbImg(productSku.getThumbImg());
|
|
||||||
orderItemList.add(orderItem);
|
|
||||||
|
|
||||||
// 计算总金额
|
|
||||||
BigDecimal totalAmount = productSku.getSalePrice();
|
|
||||||
TradeVo tradeVo = new TradeVo();
|
|
||||||
tradeVo.setTotalAmount(totalAmount);
|
|
||||||
tradeVo.setOrderItemList(orderItemList);
|
|
||||||
|
|
||||||
// 返回
|
|
||||||
return tradeVo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单分页列表
|
|
||||||
*
|
|
||||||
* @param page page
|
|
||||||
* @param limit limit
|
|
||||||
* @param orderStatus orderStatus
|
|
||||||
* @return PageInfo<OrderInfo>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public PageInfo<OrderInfo> findUserPage(Integer page, Integer limit, Integer orderStatus) {
|
|
||||||
Long userId = BaseContext.getUserInfo().getId();
|
|
||||||
List<OrderInfo> orderInfoList = orderInfoMapper.findUserPage(userId, orderStatus);
|
|
||||||
|
|
||||||
orderInfoList.forEach(orderInfo -> {
|
|
||||||
List<OrderItem> orderItem = orderItemMapper.findByOrderId(orderInfo.getId());
|
|
||||||
orderInfo.setOrderItemList(orderItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
return new PageInfo<>(orderInfoList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,19 +66,4 @@
|
||||||
where
|
where
|
||||||
id = #{id}
|
id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<select id="findUserPage" resultType="com.atguigu.spzx.model.entity.order.OrderInfo">
|
|
||||||
select
|
|
||||||
<include refid="columns"/>
|
|
||||||
from order_info
|
|
||||||
<where>
|
|
||||||
<if test="userId != null">
|
|
||||||
and user_id = #{userId}
|
|
||||||
</if>
|
|
||||||
<if test="orderStatus != null">
|
|
||||||
and order_status = #{orderStatus}
|
|
||||||
</if>
|
|
||||||
and is_deleted = 0
|
|
||||||
</where>
|
|
||||||
order by id desc
|
|
||||||
</select>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -23,13 +23,4 @@
|
||||||
#{skuPrice},
|
#{skuPrice},
|
||||||
#{skuNum})
|
#{skuNum})
|
||||||
</insert>
|
</insert>
|
||||||
<select id="findByOrderId" resultType="com.atguigu.spzx.model.entity.order.OrderItem">
|
|
||||||
select
|
|
||||||
<include refid="columns"/>
|
|
||||||
from order_item
|
|
||||||
where
|
|
||||||
order_id = #{orderId}
|
|
||||||
and is_deleted = 0
|
|
||||||
order by id desc
|
|
||||||
</select>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue