当前位置:网站首页>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;
}边栏推荐
- Use mobaxtermto establish a two-tier springboard connection
- Quick access to website media resources
- Uniapp has no effect on the page selector on the app side
- The combination of text and words perfectly explains the implementation process of MySQL logical backup
- MySQL code database creation parking management system foreign key
- Aircraft battle with enemy aircraft
- 2021.8.6 notes jsoup
- 微信支付及支付回调
- 机器学习——SVM训练集只有一类标签数据而引发的错误
- 百度地图技术概述,及基本API与WebApi的应用开发
猜你喜欢
随机推荐
智能失眠治疗仪产品-DLT8P68SA-杰力科创
2021.8.1 Notes database design
INSUFFICIENT_ ACCESS_ ON_ CROSS_ REFERENCE_ ENTITY APEX / SALESFORCE
2 万字 + 30 张图 | 细聊 MySQL undo log、redo log、binlog 有什么用?
"MySQL things" explains the indexing principle in detail
你有没有在MySQL的order by上栽过跟头
Join query and subquery
RSA encryption and decryption (compatible with wechat applet environment)
Infrared hyperspectral survey
使用jieba、pyhanlp工具实现关键字词句的提取
Wechat applet obtains mobile number
Log4j 史诗级漏洞,京东这样的大厂都中招了
EN 1155 building hardware swing door opener - CE certification
连接查询和子查询
搭建一个简单的知识问答系统
2021.7.12 internal and external connection of notes
ValueError: Found input variables with inconsistent numbers of samples: [80019456, 26673152]【报错】
Idea 2020.1 Community Edition download experience
兆骑科创海内外引进高层次人才,创新创业项目对接
Basic operations of MySQL view









