当前位置:网站首页>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;
}边栏推荐
- 我人都傻了,CompletableFuture和OpenFegin一起使用竟然报错
- Idea 2020.1 Community Edition download experience
- 搭建一个简单的知识问答系统
- LED学习护眼台灯触摸芯片-DLT8T10S-杰力科创
- idea 2020.1社区版下载体验
- C basic concepts list description suggestions collection
- pygame飞机大战游戏背景实现
- Openstack login dashboard prompt authentication error
- TypeError: conv2d(): argument ‘padding‘ (position 5) must be tuple of ints, not str【报错】
- 订单超时取消 及 按类别查询商品
猜你喜欢

迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创

MySQL 主从复制数据不一致,怎么办?

如何实现Word、PDF、TXT文件的全文内容检索?

LED带风扇护眼学习台灯触摸芯片-DLT8S12A

What does the number of network request interface layers (2/3 layers) mean

MySQL learns the relationship between Day2 Sorting Query / aggregation function / grouping query / paging query / constraint / multiple tables

Ant privacy computing innovation tee technology has won academic recognition

2021.7.12 internal and external connection of notes

面试官:你觉得你最大的缺点是什么?

js实现简易表单验证与全选功能
随机推荐
MySQL code database creation parking management system foreign key
Knowledge map - Jieba, pyhanlp, smoothnlp tools to realize Chinese word segmentation (part of speech)
MySQL 主从复制数据不一致,怎么办?
Conflict between blur event and click event in input box
MySQL set validate_ Adding skip grant tables after password=off failed to start the service
个人中心--订单业务流程
Aircraft collision detection
TS learning notes interface
Commonly used built-in methods of mybtis plus
pygame飞机大战游戏背景实现
飞机大战英雄出场加子弹实现
图文结合,完美解释MySQL逻辑备份的实现流程
我人都傻了,CompletableFuture和OpenFegin一起使用竟然报错
2021.8.7 note Servlet
JS中的数组与对象
多功能无线遥控艾灸仪芯片-DLTAP703SD
RuntimeError: output with shape [1, 256, 256] doesn‘t match the broadcast shape [3, 256, 256]【报错】
商品名称模糊搜索:
JS tool - Cookie simple encapsulation
Jianmu continuous integration platform v2.5.2 release