当前位置:网站首页>个人中心--订单业务流程
个人中心--订单业务流程
2022-07-27 16:18:00 【猫的幻想曲】
流程分析:

Controller实现 :(个人中心用户登录校验接口实现)

//校验token是否过期
@PostMapping("/check")
public R userTokenCheck(@RequestHeader("token") String token){
return new R(ResStatus.OK,"success",null);
}
用户中心的订单管理:
流程分析整理后:

接口实现:
数据库实现:
- 根据用户的ID分页查询当前用户的订单信息、关联查询订单中的商品快照
- 根据用户的ID和订单状态分页查询当前用户的订单信息、关联查询订单中的商品快照
封装对象OrderVO

Mapper接口:(子查询)
orderMapper
package com.qfedu.fmmall.dao;
import com.qfedu.fmmall.entity.Orders;
import com.qfedu.fmmall.entity.OrdersVO;
import com.qfedu.fmmall.general.GeneralDAO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrdersMapper extends GeneralDAO<Orders> {
public List<OrdersVO> selectOrders(@Param("userId") String userId,
@Param("status") String status,
@Param("start") int start,
@Param("limit") int limit);
}package com.qfedu.fmmall.dao;
OrderItemMapper:
package com.qfedu.fmmall.dao;
import com.qfedu.fmmall.entity.OrderItem;
import com.qfedu.fmmall.general.GeneralDAO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrderItemMapper extends GeneralDAO<OrderItem> {
public List<OrderItem> listOrderItemsByOrderId(String orderId);
}映射文件:
orderItemMapper映射:(子)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.qfedu.fmmall.dao.OrderItemMapper" >
<resultMap id="BaseResultMap" type="com.qfedu.fmmall.entity.OrderItem" >
<!--
WARNING - @mbg.generated
-->
<id column="item_id" property="itemId" jdbcType="VARCHAR" />
<result column="order_id" property="orderId" jdbcType="VARCHAR" />
<result column="product_id" property="productId" jdbcType="VARCHAR" />
<result column="product_name" property="productName" jdbcType="VARCHAR" />
<result column="product_img" property="productImg" jdbcType="VARCHAR" />
<result column="sku_id" property="skuId" jdbcType="VARCHAR" />
<result column="sku_name" property="skuName" jdbcType="VARCHAR" />
<result column="product_price" property="productPrice" jdbcType="DECIMAL" />
<result column="buy_counts" property="buyCounts" jdbcType="INTEGER" />
<result column="total_amount" property="totalAmount" jdbcType="DECIMAL" />
<result column="basket_date" property="basketDate" jdbcType="TIMESTAMP" />
<result column="buy_time" property="buyTime" jdbcType="TIMESTAMP" />
<result column="is_comment" property="isComment" jdbcType="INTEGER" />
</resultMap>
<select id="listOrderItemsByOrderId" resultMap="BaseResultMap">
select
item_id,
order_id ,
product_id,
product_name,
product_img,
sku_id,
sku_name,
product_price,
buy_counts,
total_amount,
basket_date,
buy_time,
is_comment
from order_item where order_id=#{orderId}
</select>
</mapper>OrderMapper映射:
<resultMap id="OrdersVOMap" type="com.qfedu.fmmall.entity.OrdersVO">
<result column="order_id" jdbcType="VARCHAR" property="orderId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="untitled" jdbcType="VARCHAR" property="untitled" />
<result column="receiver_name" jdbcType="VARCHAR" property="receiverName" />
<result column="receiver_mobile" jdbcType="VARCHAR" property="receiverMobile" />
<result column="receiver_address" jdbcType="VARCHAR" property="receiverAddress" />
<result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
<result column="actual_amount" jdbcType="INTEGER" property="actualAmount" />
<result column="pay_type" jdbcType="INTEGER" property="payType" />
<result column="order_remark" jdbcType="VARCHAR" property="orderRemark" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="delivery_type" jdbcType="VARCHAR" property="deliveryType" />
<result column="delivery_flow_id" jdbcType="VARCHAR" property="deliveryFlowId" />
<result column="order_freight" jdbcType="DECIMAL" property="orderFreight" />
<result column="delete_status" jdbcType="INTEGER" property="deleteStatus" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="pay_time" jdbcType="TIMESTAMP" property="payTime" />
<result column="delivery_time" jdbcType="TIMESTAMP" property="deliveryTime" />
<result column="flish_time" jdbcType="TIMESTAMP" property="flishTime" />
<result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime" />
<result column="close_type" jdbcType="INTEGER" property="closeType" />
<collection property="orderItems" column="order_id" select="com.qfedu.fmmall.dao.OrderItemMapper.listOrderItemsByOrderId"/>
</resultMap>
<select id="selectOrders" resultMap="OrdersVOMap">
select order_id,
user_id,
untitled,
receiver_name,
receiver_mobile,
receiver_address,
total_amount,
actual_amount,
pay_type,
order_remark,
status,
delivery_type,
delivery_flow_id,
order_freight,
delete_status,
create_time,
update_time,
pay_time,
delivery_time,
flish_time,
cancel_time,
close_type
from orders
where user_id = #{userId}
<if test="status != null">
and status = #{status}
</if>
limit #{start},#{limit}
</select>service接口:
public R listOrders(String userId,String status,int pageNum,int limit);service实现类:
@Override
public R listOrders(String userId, String status, int pageNum, int limit) {
//1.分页查询
int start = (pageNum-1)*limit;
List<OrdersVO> ordersVOS = ordersMapper.selectOrders(userId, status, pageNum, limit);
//2.查询总记录数
Example example = new Example(Orders.class);
Example.Criteria criteria = example.createCriteria();
criteria.andLike("userId",userId);
if(status != null && !"".equals(status)){
criteria.andLike("status",status);
}
int count = ordersMapper.selectCountByExample(example);
//3.计算总页数
int pageCount = count%limit==0 ? count/limit:count/limit+1;
//4.封装数据
PageHelper<OrdersVO> pageHelper = new PageHelper<>(count,pageCount,ordersVOS);
return new R(ResStatus.OK,"success",pageHelper);
}Cortoller:
//订单查询接口
@GetMapping("/list")
public R list(@RequestHeader("token")String token,
String userId,String status,int pageNum,int limit){
R r = orderService.listOrders(userId, status, pageNum, limit);
return r;
}边栏推荐
- Graphical interface programming
- Use ETL tools for data migration in salesforce project
- What if MySQL database forgets its password???
- 一个案例理解mysql视图
- RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】
- 你有没有在MySQL的order by上栽过跟头
- Meituan Er Mian: why does redis have sentinels?
- 10 SQL optimization schemes summarized by Alibaba P8 (very practical)
- Idea packaging war package and war package location
- LED带风扇护眼学习台灯触摸芯片-DLT8S12A
猜你喜欢

全自动吸奶器芯片-DLTAP703SD

智能失眠治疗仪产品-DLT8P68SA-杰力科创

知识图谱 — pyhanlp实现命名体识别(附命名体识别代码)

阿里架构师耗时280个小时整理的1015页分布式全栈小册,轻松入手分布式系统

2 万字 + 30 张图 | 细聊 MySQL undo log、redo log、binlog 有什么用?

浅谈JVM(面试常考)

知识图谱 — jieba、pyhanlp、smoothnlp工具实现中文分词(词性表)

2021.7.13笔记 子查询

Uni app label jump

Uni app traversal array rendering data vertical rendering
随机推荐
常用词词性表
1. OpenCV image basic operation
迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
JDBC learning day1:jdbc
uniapp运行到手机(真机调试)
2021.7.22 note constraints
The second parameter of fragmenttransaction.replace reports an error
What does the number of network request interface layers (2/3 layers) mean
MySQL basic statement
Meituan Er Mian: why does redis have sentinels?
Log4j 史诗级漏洞,京东这样的大厂都中招了
网红RGB镜子灯触摸芯片-DLT8S15B-杰力科创
Wechat applet obtains mobile number
TypeError: conv2d(): argument ‘padding‘ (position 5) must be tuple of ints, not str【报错】
Visual Studio Code安装教程(超详细)
js实现简易表单验证与全选功能
使用jieba、pyhanlp工具实现关键字词句的提取
2021.8.6 notes jsoup
RSA encryption and decryption (compatible with wechat applet environment)
Pandas' to_ SQL function usage