优化
This commit is contained in:
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.customizeExcel;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo.OrderExcelVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||
import cn.iocoder.yudao.module.member.service.customizeExcel.CustomizeExcelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 自定义表格导出")
|
||||
@RestController
|
||||
@RequestMapping("/member/export")
|
||||
@Validated
|
||||
public class CustomizeExcelController {
|
||||
|
||||
@Resource
|
||||
private CustomizeExcelService excelService;
|
||||
|
||||
@GetMapping("/orderExcel")
|
||||
@Operation(summary = "导出订单详情")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportBusinessExcel(String startTime,String endTime,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
List<OrderExcelVO> orderExcelVOS = excelService.exportOrderExcel(startTime, endTime);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "订单详情统计.xls", "数据", OrderExcelVO.class,
|
||||
orderExcelVOS);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class OrderExcelVO {
|
||||
|
||||
@ExcelProperty("日期")
|
||||
private String dayTime;
|
||||
|
||||
@ExcelProperty("用户名")
|
||||
private String nickname;
|
||||
|
||||
@ExcelProperty("手机")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("时间段")
|
||||
private String timeSlot;
|
||||
|
||||
@ExcelProperty("总价")
|
||||
private BigDecimal totalMoney;
|
||||
|
||||
@ExcelProperty("菜名")
|
||||
private String dishesName;
|
||||
|
||||
@ExcelProperty("单价(元/50g)")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ExcelProperty("重量(g)")
|
||||
private String weight;
|
||||
|
||||
@ExcelProperty("价格(元)")
|
||||
private BigDecimal price;
|
||||
|
||||
}
|
@ -128,7 +128,7 @@ public class OrderController {
|
||||
}
|
||||
|
||||
@GetMapping("/reduction")
|
||||
@Operation(summary = "根据会员编号,获得会员余额,充值金额,消费金额")
|
||||
@Operation(summary = "减免")
|
||||
public CommonResult<Boolean> reduction(Long orderId, BigDecimal money){
|
||||
orderService.reduction(orderId,money);
|
||||
return CommonResult.success(true);
|
||||
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.order.vo.OrderDetailsReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.order.vo.OrderDetailsRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderSaveReqVO;
|
||||
@ -30,6 +32,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -72,12 +75,7 @@ public class AppOrderController {
|
||||
return success(orderService.getOrder(id));
|
||||
}
|
||||
|
||||
//@GetMapping("/page")
|
||||
//@Operation(summary = "获得会员订单分页")
|
||||
//public CommonResult<PageResult<AppOrderRespVO>> getOrderPage(@Valid AppOrderPageReqVO pageReqVO) {
|
||||
// PageResult<DishOrderDO> pageResult = orderService.getOrderPage(pageReqVO);
|
||||
// return success(BeanUtils.toBean(pageResult, AppOrderRespVO.class));
|
||||
//}
|
||||
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出会员订单 Excel")
|
||||
@ -99,5 +97,18 @@ public class AppOrderController {
|
||||
return success(orderList);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得会员订单分页")
|
||||
public CommonResult<PageResult<OrderDetailsRespVO>> getPageResult(@Valid OrderDetailsReqVO reqVO){
|
||||
return CommonResult.success(orderService.getPageOrderDetails(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/reduction")
|
||||
@Operation(summary = "减免")
|
||||
public CommonResult<Boolean> reduction(Long orderId, BigDecimal money){
|
||||
orderService.reduction(orderId,money);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -12,4 +12,6 @@ import lombok.Data;
|
||||
public class AppPageVo extends PageParam {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String mobile;
|
||||
}
|
||||
|
@ -16,5 +16,6 @@ public class OtherVO {
|
||||
private String dishesImageUrl;
|
||||
private String sn;
|
||||
private BigDecimal price;
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "用户 APP - 用户个人信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ -58,4 +60,29 @@ public class AppMemberUserInfoRespVO {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 消费类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 赠送金额
|
||||
*/
|
||||
private BigDecimal giftAmount;
|
||||
|
||||
/**
|
||||
* 现金金额
|
||||
*/
|
||||
private BigDecimal cashAmount;
|
||||
|
||||
/**
|
||||
* 微信充值金额
|
||||
*/
|
||||
private BigDecimal wxAmount;
|
||||
|
||||
}
|
||||
|
@ -66,4 +66,9 @@ public class OrderDetailDO extends BaseDO {
|
||||
* 菜品价格
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 菜品单价
|
||||
*/
|
||||
private BigDecimal unitPrice;
|
||||
}
|
@ -19,6 +19,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ -154,4 +155,30 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
*/
|
||||
private Long faceId;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 消费类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 赠送金额
|
||||
*/
|
||||
private BigDecimal giftAmount;
|
||||
|
||||
/**
|
||||
* 现金金额
|
||||
*/
|
||||
private BigDecimal cashAmount;
|
||||
|
||||
/**
|
||||
* 微信充值金额
|
||||
*/
|
||||
private BigDecimal wxAmount;
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.customizeExcel;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo.OrderExcelVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CustomizeExcelMapper {
|
||||
|
||||
|
||||
List<OrderExcelVO> selectOrder(@Param("startTime")String startTime, @Param("endTime")String endTime);
|
||||
}
|
@ -65,6 +65,7 @@ public class MemberAsyncServiceImpl implements MemberAsyncService{
|
||||
orderDetail.setOrderId(otherVO.getOrderId()).setDishesName(otherVO.getDishesName()).setDishUrl(otherVO.getDishesImageUrl());
|
||||
orderDetail.setSn(otherVO.getSn());
|
||||
orderDetail.setPrice(otherVO.getPrice());
|
||||
orderDetail.setUnitPrice(otherVO.getUnitPrice());
|
||||
orderDetailMapper.insert(orderDetail);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.member.service.customizeExcel;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo.OrderExcelVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface CustomizeExcelService {
|
||||
|
||||
|
||||
List<OrderExcelVO> exportOrderExcel(String startTime,String endTime);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.member.service.customizeExcel;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo.OrderExcelVO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.customizeExcel.CustomizeExcelMapper;
|
||||
import cn.iocoder.yudao.module.member.service.devicewarn.DeviceWarnService;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@Service
|
||||
public class CustomizeExcelServiceImpl implements CustomizeExcelService {
|
||||
|
||||
@Resource
|
||||
private CustomizeExcelMapper customizeExcelMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderExcelVO> exportOrderExcel(String startTime, String endTime) {
|
||||
return customizeExcelMapper.selectOrder(startTime,endTime);
|
||||
}
|
||||
}
|
@ -95,6 +95,8 @@ public interface OrderService {
|
||||
List<DishOrderDO> getDishOrderByTime(LocalDateTime startTime ,LocalDateTime endTime );
|
||||
|
||||
PageResult<OrderDetailsRespVO> getPageOrderDetails(OrderDetailsReqVO reqVO);
|
||||
|
||||
|
||||
OrderDetailsRespVO getOrderDetailsAndUser(Long orderId);
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@ -153,7 +154,21 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
@Override
|
||||
public PageResult<AppOrderRespVO> getOrderList(AppPageVo vo) {
|
||||
PageResult<DishOrderDO> dishOrderDOPageResult = dishOrderMapper.selectPage(vo, Wrappers.<DishOrderDO>lambdaQuery().eq(DishOrderDO::getUserId, vo.getUserId()).orderByDesc(DishOrderDO::getCreateTime));
|
||||
ArrayList<Long> ids = new ArrayList<>();
|
||||
if(StrUtil.isNotEmpty(vo.getMobile())){
|
||||
List<MemberUserDO> memberUserDOS = memberUserMapper.selectList(Wrappers.<MemberUserDO>lambdaQuery().like(MemberUserDO::getMobile, vo.getMobile()));
|
||||
if(CollectionUtil.isNotEmpty(memberUserDOS)){
|
||||
List<Long> collect = memberUserDOS.stream().map(MemberUserDO::getId).collect(Collectors.toList());
|
||||
ids.addAll(collect);
|
||||
}
|
||||
}
|
||||
if(vo.getUserId()!=null){
|
||||
ids.add(vo.getUserId());
|
||||
}
|
||||
|
||||
PageResult<DishOrderDO> dishOrderDOPageResult = dishOrderMapper.selectPage(vo, Wrappers.<DishOrderDO>lambdaQuery()
|
||||
.in(CollectionUtil.isNotEmpty(ids),DishOrderDO::getUserId, ids)
|
||||
.orderByDesc(DishOrderDO::getCreateTime));
|
||||
PageResult<AppOrderRespVO> appOrderRespVOPageResult = BeanUtils.toBean(dishOrderDOPageResult, AppOrderRespVO.class);
|
||||
List<AppOrderRespVO> list = appOrderRespVOPageResult.getList();
|
||||
for (AppOrderRespVO dishOrderDO : list) {
|
||||
@ -196,7 +211,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
//根据用户属性获取ids
|
||||
List<MemberUserDO> list = memberUserMapper.selectList(new LambdaQueryWrapperX<MemberUserDO>()
|
||||
.likeIfPresent(MemberUserDO::getNickname, reqVO.getUserName())
|
||||
.eqIfPresent(MemberUserDO::getMobile, reqVO.getUserAccount())
|
||||
.likeIfPresent(MemberUserDO::getMobile, reqVO.getUserAccount())
|
||||
.eqIfPresent(MemberUserDO::getCardId, reqVO.getUserJob())
|
||||
.eqIfPresent(MemberUserDO::getId, reqVO.getUserId())
|
||||
.inIfPresent(MemberUserDO::getId, groupMapper.getMemberList(reqVO.getGroupId())));
|
||||
|
@ -91,7 +91,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
||||
otherVO.setDishesName(dish.getDishesName());
|
||||
otherVO.setDishesImageUrl(dish.getDishesImageUrl());
|
||||
otherVO.setPrice(bigDecimal1);
|
||||
|
||||
otherVO.setUnitPrice(dish.getDishesSumPrice());
|
||||
asyncService.createOrderDetail(createReqVO,otherVO);
|
||||
// 返回写死
|
||||
return 0L;
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?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="cn.iocoder.yudao.module.member.dal.mysql.customizeExcel.CustomizeExcelMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<select id="selectOrder" resultType="cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo.OrderExcelVO">
|
||||
select
|
||||
DATE_FORMAT(md.create_time, '%Y-%m-%d') as dayTime,
|
||||
mu.nickname ,
|
||||
mu.mobile ,
|
||||
CASE
|
||||
WHEN HOUR(mo.create_time) BETWEEN 0 AND 9 THEN '早'
|
||||
WHEN HOUR(mo.create_time) BETWEEN 10 AND 15 THEN '中'
|
||||
WHEN HOUR(mo.create_time) BETWEEN 16 AND 23 THEN '晚'
|
||||
ELSE '未知'
|
||||
END AS timeSlot,
|
||||
mo.total_money ,
|
||||
md.dishes_name ,
|
||||
md.unit_price ,
|
||||
md.weight ,
|
||||
md.price
|
||||
from member_order_detail md
|
||||
left join member_dish_order mo on md.order_id = mo.id
|
||||
left join member_user mu on mu.id = mo.user_id
|
||||
where DATE_FORMAT(md.create_time, '%Y%m%d') between #{startTime} and #{endTime}
|
||||
order by mo.user_id,order_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user