当前位置:网站首页>Personal Center - order business process
Personal Center - order business process
2022-07-27 18:50:00 【Fantasia of the cat】
Process analysis :

Controller Realization :( Implementation of user login verification interface in personal Center )

// check token Is it overdue
@PostMapping("/check")
public R userTokenCheck(@RequestHeader("token") String token){
return new R(ResStatus.OK,"success",null);
}
User Center Order Management :
After process analysis and sorting :

Interface implementation :
Database implementation :
- According to the user's ID Query the order information of the current user in pages 、 Associate and query the product snapshot in the order
- According to the user's ID And order status to query the order information of the current user 、 Associate and query the product snapshot in the order
Encapsulated object OrderVO

Mapper Interface :( Subquery )
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);
}The mapping file :
orderItemMapper mapping :( Son )
<?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 mapping :
<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 Interface :
public R listOrders(String userId,String status,int pageNum,int limit);service Implementation class :
@Override
public R listOrders(String userId, String status, int pageNum, int limit) {
//1. Paging query
int start = (pageNum-1)*limit;
List<OrdersVO> ordersVOS = ordersMapper.selectOrders(userId, status, pageNum, limit);
//2. Total number of records queried
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. Calculate the total number of pages
int pageCount = count%limit==0 ? count/limit:count/limit+1;
//4. Encapsulated data
PageHelper<OrdersVO> pageHelper = new PageHelper<>(count,pageCount,ordersVOS);
return new R(ResStatus.OK,"success",pageHelper);
}Cortoller:
// Order query interface
@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;
}边栏推荐
- Jianmu continuous integration platform v2.5.2 release
- 文件的上传和下载
- [yuntu said] 249 mobile application security service - app's physical examination center, comprehensive testing, safe on the road!
- Uniapp H5 cross domain problem
- pygame飞机大战游戏背景实现
- LED带风扇护眼学习台灯触摸芯片-DLT8S12A
- JPA connection database password field blob
- Labels such as {@code}, {@link} and < P > in the notes
- Zhaoqi scientific and technological innovation introduces high-level talents at home and abroad and connects innovation and entrepreneurship projects
- Class not found: "the com.parkmanagement.dao.daotest test cannot find the test class
猜你喜欢
随机推荐
JDBC learning day1:jdbc
Jianmu continuous integration platform v2.5.2 release
常用词词性表
Using Jieba and pyhanlp tools to extract keyword words and sentences
TS study notes class
Uploading and downloading of files
建木持续集成平台v2.5.2发布
个人中心--订单业务流程
Vue uses keep alive to realize page caching
你有没有在MySQL的order by上栽过跟头
Login page tablelayout
知识图谱 — pyhanlp实现命名体识别(附命名体识别代码)
2021.8.6 notes jsoup
Labels such as {@code}, {@link} and < P > in the notes
pandas的to_sql函数使用
2 万字 + 30 张图 | 细聊 MySQL undo log、redo log、binlog 有什么用?
TS learning notes interface
Openstack login dashboard prompt authentication error
这样的API网关查询接口优化,我是被迫的
阿里p8总结的10条 SQL 优化方案(非常实用)









