订餐喜好分析部分接口,商户部分功能
This commit is contained in:
1 parent
5d2d7b07be
commit
58f2ac053b
11 files changed
+286
-3
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.canteen.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 每日菜谱用户订餐喜好分析DTO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class UserPageDTO{
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
@DateTimeFormat(pattern ="yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDate[] times;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", example = "21292")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "用户名")
|
||||
private String userName;
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.bsd.pjcloud.canteen.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 用户订餐喜好vo
|
||||
*/
|
||||
@Data
|
||||
public class LikeFoodVO {
|
||||
|
||||
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
private Integer totalNum;
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
private BigDecimal unitPrice;
|
||||
/**
|
||||
* 支付总金额
|
||||
*/
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
private String spuName;
|
||||
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
private String picUrl;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.canteen.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MerchantCollectMoneyCodeDto {
|
||||
/**
|
||||
* 商户Id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 商户名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 商户类型
|
||||
*/
|
||||
private String merchantType;
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.bsd.pjcloud.canteen.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.UserPageDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity;
|
||||
import com.bsd.pjcloud.canteen.service.CanteenCategoryService;
|
||||
import com.bsd.pjcloud.canteen.service.OrderingPreferencesService;
|
||||
import com.bsd.pjcloud.canteen.vo.LikeFoodVO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户订餐喜好分析
|
||||
*
|
||||
* @author zhangjifu
|
||||
* @date 2024-12-05 17:54:19
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/orderingPreferences" )
|
||||
@Tag(description = "orderingPreferences" , name = "订餐喜好分析" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class CanteenOrderingPreferencesController {
|
||||
|
||||
private final OrderingPreferencesService orderingPreferencesService;
|
||||
|
||||
|
||||
/**
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "用户订餐喜好分析分页")
|
||||
public R getPage(@ParameterObject Page page,UserPageDTO userPageDTO) {
|
||||
|
||||
return R.ok(orderingPreferencesService.getPage(page,userPageDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
@@ -125,4 +125,5 @@ public class CanteenSpuController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+32
-2
@@ -3,16 +3,22 @@ package com.bsd.pjcloud.canteen.controller;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.canteen.vo.MerchantCollectMoneyCodeDto;
|
||||
import com.bsd.pjcloud.canteen.vo.MerchantInfoVO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.file.core.FileTemplate;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.canteen.entity.MerchantInfoEntity;
|
||||
import com.bsd.pjcloud.canteen.service.MerchantInfoService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -23,6 +29,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -45,6 +52,9 @@ public class MerchantInfoController {
|
||||
|
||||
private final RemoteDeptService remoteDeptService;
|
||||
|
||||
@Autowired
|
||||
private FileTemplate template;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
@@ -87,7 +97,7 @@ public class MerchantInfoController {
|
||||
@SysLog("新增商户管理" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_add')" )
|
||||
public R save(@RequestBody MerchantInfoEntity merchantInfo) {
|
||||
public R save(@RequestBody MerchantInfoEntity merchantInfo) throws Exception {
|
||||
|
||||
LambdaQueryWrapper<MerchantInfoEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MerchantInfoEntity::getName, merchantInfo.getName());
|
||||
@@ -103,9 +113,29 @@ public class MerchantInfoController {
|
||||
if (isDepartmentAlreadyBound) {
|
||||
return R.failed("部门已被绑定");
|
||||
}
|
||||
return R.ok(merchantInfoService.save(merchantInfo));
|
||||
merchantInfoService.save(merchantInfo);
|
||||
// 生成二维码
|
||||
MerchantCollectMoneyCodeDto merchantCollectMoneyCodeDto = new MerchantCollectMoneyCodeDto();
|
||||
BeanUtils.copyProperties(merchantInfo, merchantCollectMoneyCodeDto);
|
||||
String collectMoneyCodeImg = this.generateMerchantCollectMoneyCode(merchantCollectMoneyCodeDto);
|
||||
|
||||
MerchantInfoEntity merchantInfoEntity = new MerchantInfoEntity();
|
||||
merchantInfoEntity.setCollectMoneyCode(collectMoneyCodeImg);
|
||||
merchantInfoEntity.setId(merchantInfo.getId());
|
||||
merchantInfoService.updateById(merchantInfoEntity);
|
||||
// /admin/sys-file/oss/file?fileName=76109ebb7ecb4a0ca3a58d7444eebe04.png
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
// 生成商户收款码
|
||||
private String generateMerchantCollectMoneyCode(MerchantCollectMoneyCodeDto dto) throws Exception {
|
||||
String fileName = "merchant_collect_money_code" + dto.getId();
|
||||
byte[] image = QrCodeUtil.generatePng(JSON.toJSONString(dto), 300, 300);
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(image);
|
||||
template.putObject("canteen",fileName + ".png", inputStream);
|
||||
return "/admin/sys-file/oss/file?fileName=76109ebb7ecb4a0ca3a58d7444eebe04.png";
|
||||
}
|
||||
/**
|
||||
* 修改商户管理
|
||||
* @param merchantInfo 商户管理
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.bsd.pjcloud.canteen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.UserPageDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.MerchantInfoEntity;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface OrderingPreferencesMapper extends PjcloudBaseMapper {
|
||||
|
||||
|
||||
|
||||
|
||||
IPage getPage(Page page, @Param("query")UserPageDTO userPageDTO, DataScope dataScope);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.canteen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.UserPageDTO;
|
||||
|
||||
public interface OrderingPreferencesService {
|
||||
|
||||
|
||||
IPage getPage(Page page, UserPageDTO userPageDTO);
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class MerchantInfoServiceImpl extends ServiceImpl<MerchantInfoMapper, Mer
|
||||
public List<MerchantInfoVO> selectMerchantList(String type) {
|
||||
LambdaQueryWrapper<MerchantInfoEntity> merchantInfoEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
merchantInfoEntityLambdaQueryWrapper.eq(StrUtil.isNotBlank(type), MerchantInfoEntity::getMerchantType, type);
|
||||
List<MerchantInfoEntity> result = baseMapper.selectListByScope(merchantInfoEntityLambdaQueryWrapper, new DataScope());
|
||||
List<MerchantInfoEntity> result = baseMapper.selectListByScope(merchantInfoEntityLambdaQueryWrapper, DataScope.of());
|
||||
|
||||
List<MerchantInfoVO> voList = result.stream()
|
||||
.map(entity -> {
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.canteen.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.dto.UserPageDTO;
|
||||
import com.bsd.pjcloud.canteen.mapper.OrderingPreferencesMapper;
|
||||
import com.bsd.pjcloud.canteen.service.OrderingPreferencesService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class OrderingPreferencesServiceImpl implements OrderingPreferencesService {
|
||||
|
||||
|
||||
private final OrderingPreferencesMapper orderingPreferencesMapper;
|
||||
|
||||
@Override
|
||||
public IPage getPage(Page page, UserPageDTO userPageDTO) {
|
||||
return orderingPreferencesMapper.getPage(page,userPageDTO,DataScope.of());
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?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.bsd.pjcloud.canteen.mapper.OrderingPreferencesMapper">
|
||||
|
||||
<resultMap id="LikeFoodMap" type="com.bsd.pjcloud.canteen.vo.LikeFoodVO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="totalNum" column="totalNum"/>
|
||||
<result property="totalPrice" column="totalPrice"/>
|
||||
<result property="categoryName" column="merchant_type"/>
|
||||
<result property="spuName" column="spu_name"/>
|
||||
<result property="picUrl" column="pic_url"/>
|
||||
<result property="unitPrice" column="swiper"/>
|
||||
</resultMap>
|
||||
<select id="getPage" resultMap="LikeFoodMap">
|
||||
SELECT
|
||||
sum(ca.product_count) as totalNum,
|
||||
s.price / 100,
|
||||
sum(ca.total_price) / 100 as totalPrice,
|
||||
s.id,
|
||||
s.NAME as spu_name,
|
||||
s.pic_url,
|
||||
c.NAME as category_name
|
||||
FROM hardware_order o
|
||||
LEFT JOIN hardware_parent_car pc ON o.parent_car_id = pc.id
|
||||
LEFT JOIN hardware_car ca ON pc.id = ca.parent_car_id
|
||||
LEFT JOIN food_spu s ON ca.product_id = s.id
|
||||
LEFT JOIN food_category c ON s.category_id = c.id
|
||||
WHERE
|
||||
o.order_status = 5
|
||||
AND s.system_type = 3
|
||||
AND ca.deleted = 0
|
||||
AND pc.deleted = 0
|
||||
<if test="user.times != null and user.times.length > 1">
|
||||
AND to_char(o.pay_time, 'yyyy-mm-dd') BETWEEN to_char(#{user.times[0]}, 'yyyy-mm-dd')
|
||||
AND to_char(#{user.times[1]}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
GROUP BY s.id, s.price, s.NAME, s.pic_url, c.NAME;
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user