commit
e8400322e8
@ -0,0 +1,57 @@
|
||||
package com.sky.controller.admin;
|
||||
|
||||
import com.sky.constant.MessageConstant;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.utils.AliOssUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/*
|
||||
* 通用注解
|
||||
* */
|
||||
@RestController
|
||||
@RequestMapping("/admin/common")
|
||||
@Api(tags = "通用接口")
|
||||
@Slf4j
|
||||
public class CommonController
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private AliOssUtil aliOssUtil;
|
||||
|
||||
@PostMapping("upload")
|
||||
@ApiOperation("文件上传")
|
||||
public Result<String> upload(MultipartFile file) {
|
||||
log.info("文件上传:{}",file);
|
||||
|
||||
|
||||
try {
|
||||
//原始文件名
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
//获取拓展名
|
||||
String extension = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
//新文件名称
|
||||
String objectName = UUID.randomUUID().toString() + extension;
|
||||
//文件请求路径
|
||||
String filepath = null;
|
||||
filepath = aliOssUtil.upload(file.getBytes(),objectName);
|
||||
|
||||
return Result.success(filepath);
|
||||
} catch (IOException e) {
|
||||
log.error("文件上传失败:{}",e);
|
||||
}
|
||||
|
||||
return Result.error(MessageConstant.UPLOAD_FAILED);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.sky.controller.admin;
|
||||
|
||||
import com.sky.dto.OrdersCancelDTO;
|
||||
import com.sky.dto.OrdersConfirmDTO;
|
||||
import com.sky.dto.OrdersPageQueryDTO;
|
||||
import com.sky.dto.OrdersRejectionDTO;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.OrderService;
|
||||
import com.sky.vo.OrderStatisticsVO;
|
||||
import com.sky.vo.OrderVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController("adminOrderController")
|
||||
@RequestMapping("/admin/order")
|
||||
@Api(tags = "管理端订单相关接口")
|
||||
@Slf4j
|
||||
public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@GetMapping("/conditionSearch")
|
||||
@ApiOperation("订单搜索")
|
||||
public Result<PageResult> search(OrdersPageQueryDTO ordersPageQueryDTO){
|
||||
log.info("订单搜索:{}",ordersPageQueryDTO);
|
||||
PageResult page = orderService.searchOrder(ordersPageQueryDTO);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@ApiOperation("各个状态的订单数量统计")
|
||||
public Result<OrderStatisticsVO> statistic(){
|
||||
OrderStatisticsVO orderStatisticsVO = orderService.statistics();
|
||||
return Result.success(orderStatisticsVO);
|
||||
}
|
||||
|
||||
@GetMapping("/details/{id}")
|
||||
@ApiOperation("查询订单详情")
|
||||
public Result<OrderVO> details(@PathVariable Long id){
|
||||
log.info("查询订单详情:{}",id);
|
||||
OrderVO orderVO = orderService.showDetails(id);
|
||||
return Result.success(orderVO);
|
||||
}
|
||||
|
||||
@PutMapping("/confirm")
|
||||
@ApiOperation("接单")
|
||||
public Result confirm(@RequestBody OrdersConfirmDTO ordersConfirmDTO){
|
||||
log.info("接单:{}",ordersConfirmDTO);
|
||||
orderService.confirm(ordersConfirmDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PutMapping("/rejection")
|
||||
@ApiOperation("拒单")
|
||||
public Result reject(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
|
||||
log.info("拒单:{}",ordersRejectionDTO);
|
||||
orderService.reject(ordersRejectionDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PutMapping("/cancel")
|
||||
@ApiOperation("取消订单")
|
||||
public Result cancel(@RequestBody OrdersCancelDTO ordersCancelDTO){
|
||||
log.info("取消订单:{}",ordersCancelDTO);
|
||||
orderService.adminCancel(ordersCancelDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PutMapping("/delivery/{id}")
|
||||
@ApiOperation("派送订单")
|
||||
public Result delivery(@PathVariable Long id){
|
||||
log.info("派送订单:{}",id);
|
||||
orderService.delivery(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PutMapping("/complete/{id}")
|
||||
@ApiOperation("完成订单")
|
||||
public Result complete(@PathVariable Long id){
|
||||
log.info("完成订单:{}",id);
|
||||
orderService.complete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.sky.controller.notify;
|
||||
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sky.properties.WeChatProperties;
|
||||
import com.sky.service.OrderService;
|
||||
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 支付回调相关接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/notify")
|
||||
@Slf4j
|
||||
public class PayNotifyController {
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@Autowired
|
||||
private WeChatProperties weChatProperties;
|
||||
|
||||
/**
|
||||
* 支付成功回调
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping("/paySuccess")
|
||||
public void paySuccessNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
//读取数据
|
||||
String body = readData(request);
|
||||
log.info("支付成功回调:{}", body);
|
||||
|
||||
//数据解密
|
||||
String plainText = decryptData(body);
|
||||
log.info("解密后的文本:{}", plainText);
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(plainText);
|
||||
String outTradeNo = jsonObject.getString("out_trade_no");//商户平台订单号
|
||||
String transactionId = jsonObject.getString("transaction_id");//微信支付交易号
|
||||
|
||||
log.info("商户平台订单号:{}", outTradeNo);
|
||||
log.info("微信支付交易号:{}", transactionId);
|
||||
|
||||
//业务处理,修改订单状态、来单提醒
|
||||
orderService.paySuccess(outTradeNo);
|
||||
|
||||
//给微信响应
|
||||
responseToWeixin(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String readData(HttpServletRequest request) throws Exception {
|
||||
BufferedReader reader = request.getReader();
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (result.length() > 0) {
|
||||
result.append("\n");
|
||||
}
|
||||
result.append(line);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据解密
|
||||
*
|
||||
* @param body
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String decryptData(String body) throws Exception {
|
||||
JSONObject resultObject = JSON.parseObject(body);
|
||||
JSONObject resource = resultObject.getJSONObject("resource");
|
||||
String ciphertext = resource.getString("ciphertext");
|
||||
String nonce = resource.getString("nonce");
|
||||
String associatedData = resource.getString("associated_data");
|
||||
|
||||
AesUtil aesUtil = new AesUtil(weChatProperties.getApiV3Key().getBytes(StandardCharsets.UTF_8));
|
||||
//密文解密
|
||||
String plainText = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8),
|
||||
nonce.getBytes(StandardCharsets.UTF_8),
|
||||
ciphertext);
|
||||
|
||||
return plainText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 给微信响应
|
||||
* @param response
|
||||
*/
|
||||
private void responseToWeixin(HttpServletResponse response) throws Exception{
|
||||
response.setStatus(200);
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("code", "SUCCESS");
|
||||
map.put("message", "SUCCESS");
|
||||
response.setHeader("Content-type", ContentType.APPLICATION_JSON.toString());
|
||||
response.getOutputStream().write(JSONUtils.toJSONString(map).getBytes(StandardCharsets.UTF_8));
|
||||
response.flushBuffer();
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.sky.controller.user;
|
||||
|
||||
import com.sky.dto.OrdersPaymentDTO;
|
||||
import com.sky.dto.OrdersSubmitDTO;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.OrderService;
|
||||
import com.sky.vo.OrderPaymentVO;
|
||||
import com.sky.vo.OrderSubmitVO;
|
||||
import com.sky.vo.OrderVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController("userOrderController")
|
||||
@RequestMapping("/user/order")
|
||||
@Api(tags = "用户端订单相关接口")
|
||||
@Slf4j
|
||||
public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
/*
|
||||
* 用户下单
|
||||
* */
|
||||
@PostMapping("/submit")
|
||||
@ApiOperation("用户下单")
|
||||
public Result<OrderSubmitVO> submit(@RequestBody OrdersSubmitDTO ordersSubmitDTO){
|
||||
log.info("用户下单,参数为:{}",ordersSubmitDTO);
|
||||
OrderSubmitVO orderSubmitVO = orderService.submitOrder(ordersSubmitDTO);
|
||||
return Result.success(orderSubmitVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
*
|
||||
* @param ordersPaymentDTO
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/payment")
|
||||
@ApiOperation("订单支付")
|
||||
public Result<OrderPaymentVO> payment(@RequestBody OrdersPaymentDTO ordersPaymentDTO) throws Exception {
|
||||
log.info("订单支付:",ordersPaymentDTO);
|
||||
OrderPaymentVO orderPaymentVO = orderService.payment(ordersPaymentDTO);
|
||||
log.info("生成预支付交易单:{}", orderPaymentVO);
|
||||
orderService.paySuccess(ordersPaymentDTO.getOrderNumber());
|
||||
return Result.success(orderPaymentVO);
|
||||
}
|
||||
|
||||
@GetMapping("/historyOrders")
|
||||
@ApiOperation("历史订单查询")
|
||||
public Result<PageResult> historyQueryPage(int page, int pageSize,Integer status){
|
||||
PageResult pageResult = orderService.historyQueryPage(page,pageSize,status);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/orderDetail/{id}")
|
||||
@ApiOperation("查询订单详情")
|
||||
public Result<OrderVO> details(@PathVariable Long id){
|
||||
log.info("查询订单详情:{}",id);
|
||||
OrderVO orderVO = orderService.showDetails(id);
|
||||
return Result.success(orderVO);
|
||||
}
|
||||
|
||||
@ApiOperation("取消订单")
|
||||
@PutMapping("/cancel/{id}")
|
||||
public Result cancel(@PathVariable Long id){
|
||||
log.info("取消订单:{}",id);
|
||||
orderService.cancel(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation("再来一单")
|
||||
@PostMapping("/repetition/{id}")
|
||||
public Result repetition(@PathVariable Long id){
|
||||
log.info("再来一单:{}",id);
|
||||
orderService.repetiton(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/*
|
||||
* 客户催单
|
||||
* */
|
||||
@GetMapping("/reminder/{id}")
|
||||
@ApiOperation("客户催单")
|
||||
public Result reminder(@PathVariable("id") Long id){
|
||||
log.info("客户催单:{}",id);
|
||||
orderService.reminder(id);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
public interface AddressBookMapper {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
public interface DishMapper {
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
import com.sky.entity.OrderDetail;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface OrderDetailMapper {
|
||||
/*
|
||||
* 批量插入订单明细数据
|
||||
* */
|
||||
void insertBatch(List<OrderDetail> orderDetailList);
|
||||
|
||||
@Select("select * from order_detail where order_id = #{orderId}")
|
||||
List<OrderDetail> getByOrderId(Long orderId);
|
||||
|
||||
@Delete("delete from order_detail where order_id = #{orderId}")
|
||||
void deleteBatchByOrderId(Long id);
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.sky.dto.GoodsSalesDTO;
|
||||
import com.sky.dto.OrdersPageQueryDTO;
|
||||
import com.sky.entity.Orders;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface OrderMapper {
|
||||
/*
|
||||
* 插入订单数据
|
||||
* */
|
||||
void insert(Orders orders);
|
||||
|
||||
|
||||
/**
|
||||
* 根据订单号查询订单
|
||||
* @param orderNumber
|
||||
*/
|
||||
@Select("select * from orders where number = #{orderNumber}")
|
||||
Orders getByNumber(String orderNumber);
|
||||
|
||||
/**
|
||||
* 修改订单信息
|
||||
* @param orders
|
||||
*/
|
||||
void update(Orders orders);
|
||||
|
||||
Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
|
||||
|
||||
@Select("select * from orders where id = #{id}")
|
||||
Orders getById(Long id);
|
||||
|
||||
@Delete("delete from orders where id = #{id}")
|
||||
void deleteById(Long id);
|
||||
|
||||
@Select("select count(id) from orders where status = #{status}")
|
||||
Integer countStatus(Integer status);
|
||||
|
||||
/*
|
||||
* 根据订单状态和下单时间查询订单
|
||||
* */
|
||||
@Select("select * from orders where status = #{status} and order_time < #{orderTime}")
|
||||
List<Orders> getByStatusAndOrderTimeLT(Integer status, LocalDateTime orderTime);
|
||||
|
||||
/*
|
||||
* 根据动态条件统计营业额数据
|
||||
* */
|
||||
Double sumByMap(Map map);
|
||||
|
||||
/*
|
||||
* 根据动态条件统计订单数据
|
||||
* */
|
||||
Integer countByMap(Map map);
|
||||
|
||||
/*
|
||||
* 统计指定时间内的销量排名前10
|
||||
*/
|
||||
List<GoodsSalesDTO> getSalesTop10(LocalDateTime begin,LocalDateTime end);
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
public interface SetmealMapper {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
public interface ShoppingCartMapper {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
public interface UserMapper {
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.sky.service;
|
||||
|
||||
import com.sky.vo.OrderReportVO;
|
||||
import com.sky.vo.SalesTop10ReportVO;
|
||||
import com.sky.vo.TurnoverReportVO;
|
||||
import com.sky.vo.UserReportVO;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public interface ReportService {
|
||||
|
||||
/*
|
||||
* 统计指定时间内的营业额
|
||||
* */
|
||||
TurnoverReportVO getTurnoverStatistics(LocalDate begin,LocalDate end);
|
||||
|
||||
/*
|
||||
* 统计指定时间内的用户数据
|
||||
* */
|
||||
UserReportVO getUserStatistics(LocalDate begin, LocalDate end);
|
||||
|
||||
|
||||
OrderReportVO getOrderStatistics(LocalDate begin, LocalDate end);
|
||||
|
||||
SalesTop10ReportVO getTop10(LocalDate begin, LocalDate end);
|
||||
|
||||
/*
|
||||
* 导出运营数据报表
|
||||
* */
|
||||
void exportBusinessData(HttpServletResponse response);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.sky.service;
|
||||
|
||||
import com.sky.vo.BusinessDataVO;
|
||||
import com.sky.vo.DishOverViewVO;
|
||||
import com.sky.vo.OrderOverViewVO;
|
||||
import com.sky.vo.SetmealOverViewVO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public interface WorkspaceService {
|
||||
|
||||
/**
|
||||
* 根据时间段统计营业数据
|
||||
* @param begin
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
BusinessDataVO getBusinessData(LocalDateTime begin, LocalDateTime end);
|
||||
|
||||
/**
|
||||
* 查询订单管理数据
|
||||
* @return
|
||||
*/
|
||||
OrderOverViewVO getOrderOverView();
|
||||
|
||||
/**
|
||||
* 查询菜品总览
|
||||
* @return
|
||||
*/
|
||||
DishOverViewVO getDishOverView();
|
||||
|
||||
/**
|
||||
* 查询套餐总览
|
||||
* @return
|
||||
*/
|
||||
SetmealOverViewVO getSetmealOverView();
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.sky.websocket;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* WebSocket服务
|
||||
*/
|
||||
@Component
|
||||
@ServerEndpoint("/ws/{sid}")
|
||||
public class WebSocketServer {
|
||||
|
||||
//存放会话对象
|
||||
private static Map<String, Session> sessionMap = new HashMap();
|
||||
|
||||
/**
|
||||
* 连接建立成功调用的方法
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("sid") String sid) {
|
||||
System.out.println("客户端:" + sid + "建立连接");
|
||||
sessionMap.put(sid, session);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到客户端消息后调用的方法
|
||||
*
|
||||
* @param message 客户端发送过来的消息
|
||||
*/
|
||||
@OnMessage
|
||||
public void onMessage(String message, @PathParam("sid") String sid) {
|
||||
System.out.println("收到来自客户端:" + sid + "的信息:" + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接关闭调用的方法
|
||||
*
|
||||
* @param sid
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose(@PathParam("sid") String sid) {
|
||||
System.out.println("连接断开:" + sid);
|
||||
sessionMap.remove(sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 群发
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void sendToAllClient(String message) {
|
||||
Collection<Session> sessions = sessionMap.values();
|
||||
for (Session session : sessions) {
|
||||
try {
|
||||
//服务器向客户端发送消息
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?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.sky.mapper.OrderDetailMapper">
|
||||
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into order_detail(name, image, order_id, dish_id, setmeal_id, dish_flavor, amount)
|
||||
values
|
||||
<foreach collection="orderDetailList" item="od" separator=",">
|
||||
(#{od.name},#{od.image},#{od.orderId},#{od.dishId},#{od.setmealId},#{od.dishFlavor},#{od.amount})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
</mapper>
|
@ -0,0 +1,118 @@
|
||||
<?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.sky.mapper.OrderMapper">
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into orders(number, status, user_id, address_book_id, order_time,
|
||||
checkout_time, pay_method, pay_status, amount, remark,
|
||||
phone, address, user_name, consignee, cancel_reason,
|
||||
rejection_reason, cancel_time, estimated_delivery_time,
|
||||
delivery_status, delivery_time, pack_amount,
|
||||
tableware_number, tableware_status)
|
||||
values(#{number},#{status},#{userId},#{addressBookId},#{orderTime},#{checkoutTime},
|
||||
#{payMethod},#{payStatus},#{amount},#{remark},#{phone},#{address},#{userName},
|
||||
#{consignee},#{cancelReason},#{rejectionReason},#{cancelTime},#{estimatedDeliveryTime},
|
||||
#{deliveryStatus},#{deliveryTime},#{packAmount},#{tablewareNumber},#{tablewareStatus})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.sky.entity.Orders">
|
||||
update orders
|
||||
<set>
|
||||
<if test="cancelReason != null and cancelReason!='' ">
|
||||
cancel_reason=#{cancelReason},
|
||||
</if>
|
||||
<if test="rejectionReason != null and rejectionReason!='' ">
|
||||
rejection_reason=#{rejectionReason},
|
||||
</if>
|
||||
<if test="cancelTime != null">
|
||||
cancel_time=#{cancelTime},
|
||||
</if>
|
||||
<if test="payStatus != null">
|
||||
pay_status=#{payStatus},
|
||||
</if>
|
||||
<if test="payMethod != null">
|
||||
pay_method=#{payMethod},
|
||||
</if>
|
||||
<if test="checkoutTime != null">
|
||||
checkout_time=#{checkoutTime},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="deliveryTime != null">
|
||||
delivery_time = #{deliveryTime}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<select id="pageQuery" resultType="com.sky.entity.Orders">
|
||||
select *
|
||||
from orders
|
||||
<where>
|
||||
<if test="number != null and number!=''">
|
||||
and number like concat('%',#{number},'%')
|
||||
</if>
|
||||
<if test="phone != null and phone!=''">
|
||||
and phone like concat('%',#{phone},'%')
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="beginTime != null">
|
||||
and order_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and order_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="sumByMap" resultType="java.lang.Double">
|
||||
select sum(amount)
|
||||
from orders
|
||||
<where>
|
||||
<if test="begin != null">
|
||||
and order_time > #{begin}
|
||||
</if>
|
||||
<if test="end != null">
|
||||
and order_time < #{end}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="countByMap" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from orders
|
||||
<where>
|
||||
<if test="begin != null">
|
||||
and order_time > #{begin}
|
||||
</if>
|
||||
<if test="end != null">
|
||||
and order_time < #{end}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getSalesTop10" resultType="com.sky.dto.GoodsSalesDTO">
|
||||
select od.name,sum(od.number) as number
|
||||
from order_detail od,orders o
|
||||
where
|
||||
od.order_id = o.id
|
||||
and o.status = 5
|
||||
<if test="begin != null">
|
||||
and o.order_time > #{begin}
|
||||
</if>
|
||||
<if test="end != null">
|
||||
and o.order_time < #{end}
|
||||
</if>
|
||||
group by od.name
|
||||
order by number desc
|
||||
limit 0,10
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in new issue