Merge branch 'master' of https://gitea.zianxin.com/zax/biz-api-cloud
This commit is contained in:
commit
d7f3d0c4f1
21 files changed
+347
-58
No files matched your search
@@ -388,6 +388,28 @@ CREATE TABLE hard_appt
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB COMMENT ='设备预约管理';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for hard_table_manage
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS hard_table_manage;
|
||||
CREATE TABLE hard_table_manage
|
||||
(
|
||||
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
merchant_id bigint COMMENT '商户id',
|
||||
code varchar(128) NOT NULL COMMENT '编号',
|
||||
enable char(1) NOT NULL COMMENT '是否启用',
|
||||
qr_code varchar(256) DEFAULT NULL COMMENT '二维码',
|
||||
remark varchar(256) DEFAULT NULL COMMENT '备注',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
|
||||
update_time datetime DEFAULT NULL COMMENT '修改时间',
|
||||
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB COMMENT ='预约桌子管理';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for hard_auth
|
||||
-- ----------------------------
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public class CanteenCategoryController {
|
||||
wrapper.like(StringUtils.isNotBlank(name), CanteenCategoryEntity::getName, name);
|
||||
wrapper.orderByAsc(CanteenCategoryEntity::getSort);
|
||||
wrapper.apply(StringUtils.isNotEmpty(categoryType), "FIND_IN_SET({0}, your_column_name)", categoryType);
|
||||
List<CanteenCategoryEntity> list = canteenCategoryService.listScope(wrapper);
|
||||
List<CanteenCategoryEntity> list = canteenCategoryService.list(wrapper);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,6 +21,6 @@ public enum HardHourTypeEnum {
|
||||
|
||||
public static HardHourTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
+2
@@ -26,6 +26,8 @@ public enum HardPayTypeEnum {
|
||||
HARD_DOOR_FREE_PAY("9", "智能柜免密支付"),
|
||||
WECHANT_SELF_QR_CODE_PAY("10", "微信付款码支付"),
|
||||
ALI_SELF_QR_CODE_PAY("11", "支付宝付款码支付"),
|
||||
ZYY("12", "中医院"),
|
||||
RMYY("13", "人民医院"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
+4
-3
@@ -1,11 +1,9 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order.app;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.constant.total.DateRangeTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -14,8 +12,11 @@ import java.util.List;
|
||||
@Data
|
||||
public class HardAppProductByCanteenDto {
|
||||
|
||||
@Schema(description = "用户Id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "食堂id")
|
||||
private List<String> canteenIdList;
|
||||
private List<Long> canteenIdList;
|
||||
|
||||
@Schema(description = "用餐时间段")
|
||||
private String hourType;
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ import java.util.List;
|
||||
@Data
|
||||
public class HardAppProductByClassifyDto {
|
||||
|
||||
@Schema(description = "用户Id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "食堂id")
|
||||
private List<String> canteenIdList;
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order.app;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 个人菜品喜好排行
|
||||
*/
|
||||
@Data
|
||||
public class HardAppProductLikeTopDto {
|
||||
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
+7
-4
@@ -1,17 +1,15 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.order;
|
||||
|
||||
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
|
||||
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
|
||||
import com.bsd.pjcloud.admin.api.vo.base.BaseUserDeptInterface;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, BaseDeptInterface, BaseMchInterface, BaseHardInterface {
|
||||
public class HardOrderVo extends HardOrderEntity implements BaseUserDeptInterface, BaseMchInterface, BaseHardInterface {
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
@@ -26,6 +24,11 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 用户部门
|
||||
*/
|
||||
private String userDeptName;
|
||||
|
||||
/**
|
||||
* 商户相关
|
||||
*/
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.order.app;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 菜品销量按照分类查询
|
||||
*/
|
||||
@Data
|
||||
public class HardAppProductLikeTopVo {
|
||||
|
||||
@Schema(description = "分类id")
|
||||
private Long classifyId;
|
||||
|
||||
@Schema(description = "分类名")
|
||||
private String classifyName;
|
||||
|
||||
@Schema(description = "商品id")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "商品名")
|
||||
private String productName;
|
||||
|
||||
@Schema(description = "购买总数")
|
||||
private Long payCount;
|
||||
|
||||
}
|
||||
+3
@@ -24,6 +24,9 @@ public class HardOrderExcelVo {
|
||||
@ExcelProperty("部门")
|
||||
private String deptName;
|
||||
|
||||
@ExcelProperty("部门")
|
||||
private String userDeptName;
|
||||
|
||||
@ExcelProperty("支付方式")
|
||||
private String payType;
|
||||
|
||||
|
||||
+28
-2
@@ -1,17 +1,22 @@
|
||||
package com.bsd.pjcloud.hard.controller.order;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByClassifyDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductLikeTopDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByCanteenVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByClassifyVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductLikeTopVo;
|
||||
import com.bsd.pjcloud.hard.service.HardCanteenTotalService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -22,6 +27,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 食堂统计
|
||||
@@ -43,19 +49,39 @@ public class HardCanteenTotalController {
|
||||
@Operation(summary = "菜品销量按照分类查询", description = "菜品销量按照分类查询")
|
||||
@PostMapping("/app/product-by-classify")
|
||||
public R<List<HardAppProductByClassifyVo>> productByClassify(@RequestBody HardAppProductByClassifyDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
if (ObjectUtil.isNotEmpty(user)) {
|
||||
dto.setUserId(user.getId());
|
||||
}
|
||||
return R.ok(canteenTotalService.productByClassify(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 近一周各个食堂菜品购买统计
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@Operation(summary = "近一周各个食堂菜品购买统计", description = "近一周各个食堂菜品购买统计")
|
||||
@PostMapping("/app/product-by-canteen")
|
||||
public R<List<HardAppProductByCanteenVo>> productByCanteen(@RequestBody HardAppProductByCanteenDto dto) {
|
||||
public R<List<Map<String, List<HardAppProductByCanteenVo>>>> productByCanteen(@RequestBody HardAppProductByCanteenDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
if (ObjectUtil.isNotEmpty(user)) {
|
||||
dto.setUserId(user.getId());
|
||||
}
|
||||
return R.ok(canteenTotalService.productByCanteen(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人菜品喜好排行
|
||||
*/
|
||||
@Operation(summary = "个人菜品喜好排行", description = "个人菜品喜好排行")
|
||||
@PostMapping("/app/product-like-top")
|
||||
public R<List<HardAppProductLikeTopVo>> productLikeTop(@RequestBody HardAppProductLikeTopDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
if (ObjectUtil.isNotEmpty(user)) {
|
||||
dto.setUserId(user.getId());
|
||||
}
|
||||
return R.ok(canteenTotalService.productLikeTop(dto));
|
||||
}
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
@Operation(summary = "根据部门 食堂菜品购买统计", description = "根据部门 食堂菜品购买统计")
|
||||
@PostMapping("/proudct-total-by-dept")
|
||||
|
||||
+2
@@ -309,6 +309,8 @@ public class HardOrderController {
|
||||
HardHourTypeEnum hardHourTypeEnum = HardHourTypeEnum.valueOfByType(v.getHourType());
|
||||
if (ObjectUtil.isNotEmpty(hardHourTypeEnum)) {
|
||||
v.setHourType(hardHourTypeEnum.getDescription());
|
||||
} else {
|
||||
v.setHourType("");
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getPayType())) {
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.bsd.pjcloud.hard.controller.sync;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.hard.service.HardSyncService;
|
||||
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.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 设备同步
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/hard-sync")
|
||||
@Tag(description = "hard-sync", name = "设备同步")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class HardSyncController {
|
||||
|
||||
private final HardSyncService hardSyncService;
|
||||
|
||||
@Operation(summary = "同步超市分类商品和同步", description = "同步超市分类商品和同步")
|
||||
@SysLog("同步超市分类商品和同步")
|
||||
@Idempotent(expireTime = 3, info = "正在同步中,请勿重复操作")
|
||||
@GetMapping("/sync-supermarket")
|
||||
public R syncSupermarket() {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
hardSyncService.syncSupermarket(user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -5,6 +5,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByClassifyDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductLikeTopDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
@@ -12,6 +13,7 @@ import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByCanteenVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByClassifyVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductLikeTopVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -47,4 +49,9 @@ public interface HardCarMapper extends PjcloudBaseMapper<HardCarEntity> {
|
||||
* 各个食堂菜品购买统计
|
||||
*/
|
||||
List<HardAppProductByCanteenVo> productByCanteen(@Param("dto") HardAppProductByCanteenDto dto);
|
||||
|
||||
/**
|
||||
* 个人菜品喜好排行
|
||||
*/
|
||||
List<HardAppProductLikeTopVo> productLikeTop(@Param("dto") HardAppProductLikeTopDto dto);
|
||||
}
|
||||
+9
-1
@@ -6,13 +6,16 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByClassifyDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductLikeTopDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByCanteenVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByClassifyVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductLikeTopVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface HardCanteenTotalService {
|
||||
|
||||
@@ -24,7 +27,12 @@ public interface HardCanteenTotalService {
|
||||
/**
|
||||
* 近一周各个食堂菜品购买统计
|
||||
*/
|
||||
List<HardAppProductByCanteenVo> productByCanteen(HardAppProductByCanteenDto dto);
|
||||
List<Map<String, List<HardAppProductByCanteenVo>>> productByCanteen(HardAppProductByCanteenDto dto);
|
||||
|
||||
/**
|
||||
* 个人菜品喜好排行
|
||||
*/
|
||||
List<HardAppProductLikeTopVo> productLikeTop(HardAppProductLikeTopDto dto);
|
||||
|
||||
/**
|
||||
* 根据部门 食堂菜品购买统计
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
|
||||
public interface HardSyncService {
|
||||
|
||||
/**
|
||||
* 同步超市分类商品和同步
|
||||
*/
|
||||
void syncSupermarket(PjcloudUser user);
|
||||
|
||||
}
|
||||
+86
-24
@@ -3,23 +3,28 @@ package com.bsd.pjcloud.hard.service.impl.order;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
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.api.feign.RemoteCanteenCategoryService;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.total.DateRangeTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByClassifyDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductLikeTopDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByCanteenVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByClassifyVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductLikeTopVo;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardCarMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardCanteenTotalService;
|
||||
@@ -83,7 +88,15 @@ public class HardCanteenTotalServiceImpl implements HardCanteenTotalService {
|
||||
* 近一周各个食堂菜品购买统计
|
||||
*/
|
||||
@Override
|
||||
public List<HardAppProductByCanteenVo> productByCanteen(HardAppProductByCanteenDto dto) {
|
||||
public List<Map<String, List<HardAppProductByCanteenVo>>> productByCanteen(HardAppProductByCanteenDto dto) {
|
||||
// 查询自营食堂并且在移动端显示的
|
||||
List<MchManageVo> canteenList = remoteMchService.getByTypes(List.of(MerchantTypeEnum.CANTEEN.getType())).getData();
|
||||
if (ObjectUtil.isEmpty(canteenList)) return null;
|
||||
canteenList = canteenList.stream().filter(v -> ObjectUtil.equals(v.getVisibleMobile(), YesNoEnum.YES.getCode())).toList();
|
||||
if (ObjectUtil.isNotEmpty(canteenList)) {
|
||||
List<Long> canteenIdList = canteenList.stream().map(MchManageVo::getId).toList();
|
||||
dto.setCanteenIdList(canteenIdList);
|
||||
}
|
||||
dto.setPayTimeList(new LocalDate[]{LocalDate.now().minusWeeks(1), LocalDate.now()});
|
||||
// 查询近一周的时间
|
||||
List<HardAppProductByCanteenVo> dateList = new LinkedList<>();
|
||||
@@ -95,22 +108,52 @@ public class HardCanteenTotalServiceImpl implements HardCanteenTotalService {
|
||||
dateList.add(entity);
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
|
||||
// 查询自营食堂
|
||||
List<Map<String, List<HardAppProductByCanteenVo>>> result = new ArrayList<>();
|
||||
for (MchManageVo vo : canteenList) {
|
||||
// 为每个食堂创建dateList的副本
|
||||
List<HardAppProductByCanteenVo> canteenDateList = new LinkedList<>();
|
||||
for (HardAppProductByCanteenVo item : dateList) {
|
||||
// 创建每个日期项的副本
|
||||
HardAppProductByCanteenVo copy = BeanUtil.toBean(item, HardAppProductByCanteenVo.class);
|
||||
canteenDateList.add(copy);
|
||||
}
|
||||
result.add(Map.of(vo.getName(), canteenDateList));
|
||||
}
|
||||
|
||||
List<HardAppProductByCanteenVo> totalList = hardCarMapper.productByCanteen(dto);
|
||||
disposeProductByCanteen(totalList);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(totalList)) {
|
||||
for (HardAppProductByCanteenVo vo : totalList) {
|
||||
if (ObjectUtil.isEmpty(vo.getTime())) continue;
|
||||
dateList.stream().filter(item -> ObjectUtil.equals(item.getTime(), vo.getTime())).findFirst().ifPresent(target -> {
|
||||
target.setCanteenId(vo.getCanteenId());
|
||||
target.setPayCount(vo.getPayCount());
|
||||
target.setTotalPrice(vo.getTotalPrice());
|
||||
target.setTimeCount(vo.getTimeCount());
|
||||
target.setPayUserCount(vo.getPayUserCount());
|
||||
});
|
||||
for (Map<String, List<HardAppProductByCanteenVo>> map : result) {
|
||||
for (Map.Entry<String, List<HardAppProductByCanteenVo>> entry : map.entrySet()) {
|
||||
String canteenName = entry.getKey();
|
||||
for (HardAppProductByCanteenVo vo : entry.getValue()) {
|
||||
totalList.stream().filter(item -> ObjectUtil.equals(item.getCanteenName(), canteenName) && ObjectUtil.equals(item.getTime(), vo.getTime())).findFirst().ifPresent(target -> {
|
||||
vo.setCanteenId(target.getCanteenId());
|
||||
vo.setCanteenName(canteenName);
|
||||
vo.setPayCount(target.getPayCount());
|
||||
vo.setTotalPrice(target.getTotalPrice());
|
||||
vo.setTimeCount(target.getTimeCount());
|
||||
vo.setPayUserCount(target.getPayUserCount());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理一下
|
||||
disposeProductByCanteen(dateList);
|
||||
return dateList;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人菜品喜好排行
|
||||
*/
|
||||
@Override
|
||||
public List<HardAppProductLikeTopVo> productLikeTop(HardAppProductLikeTopDto dto) {
|
||||
List<HardAppProductLikeTopVo> totalList = hardCarMapper.productLikeTop(dto);
|
||||
disposeProductLikeTop(totalList);
|
||||
return totalList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,22 +330,41 @@ public class HardCanteenTotalServiceImpl implements HardCanteenTotalService {
|
||||
}
|
||||
}
|
||||
|
||||
private void disposeProductByCanteen(List<HardAppProductByCanteenVo> list) {
|
||||
private void disposeProductLikeTop(List<HardAppProductLikeTopVo> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 处理商户
|
||||
List<Long> canteenIdList = list.stream().map(HardAppProductByCanteenVo::getCanteenId).toList();
|
||||
if (ObjectUtil.isNotEmpty(canteenIdList)) {
|
||||
List<MchManageVo> mchList = remoteMchService.getByIds(canteenIdList).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
Map<Long, MchManageVo> categoryMap = mchList.stream().collect(Collectors.toMap(MchManageVo::getId, v -> v));
|
||||
for (HardAppProductByCanteenVo i : list) {
|
||||
MchManageVo category = categoryMap.get(i.getCanteenId());
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
i.setCanteenName(category.getName());
|
||||
// 处理菜品分类
|
||||
List<Long> classifyList = list.stream().map(HardAppProductLikeTopVo::getClassifyId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(classifyList)) {
|
||||
List<CanteenCategoryEntity> categoryList = canteenCategoryService.getAllSimple(null, null).getData();
|
||||
if (ObjectUtil.isNotEmpty(categoryList)) {
|
||||
Map<Long, CanteenCategoryEntity> categoryMap = categoryList.stream().collect(Collectors.toMap(CanteenCategoryEntity::getId, v -> v));
|
||||
if (ObjectUtil.isNotEmpty(categoryMap)) {
|
||||
for (HardAppProductLikeTopVo i : list) {
|
||||
CanteenCategoryEntity category = categoryMap.get(i.getClassifyId());
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
i.setClassifyName(category.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disposeProductByCanteen(List<HardAppProductByCanteenVo> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 处理商户
|
||||
List<Long> canteenIdList = list.stream().map(HardAppProductByCanteenVo::getCanteenId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(canteenIdList)) {
|
||||
List<MchManageVo> mchList = remoteMchService.getByIds(canteenIdList).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
Map<Long, MchManageVo> mchMap = CollectionUtils.convertMap(mchList, MchManageVo::getId);
|
||||
for (HardAppProductByCanteenVo i : list) {
|
||||
MchManageVo mch = mchMap.get(i.getCanteenId());
|
||||
if (ObjectUtil.isNotEmpty(mch)) {
|
||||
i.setCanteenName(mch.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-22
@@ -14,6 +14,7 @@ import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.admin.api.vo.UserVO;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteOnlineCanteenSpuService;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
@@ -167,16 +168,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (ObjectUtil.isNotEmpty(detail)) {
|
||||
// 用户
|
||||
if (ObjectUtil.isNotEmpty(detail.getUserId())) {
|
||||
R<UserInfo> user = userService.getInnerByUserId(detail.getUserId());
|
||||
if (ObjectUtil.isNotEmpty(user.getData())) {
|
||||
DataUtil.convertUser(detail, user.getData().getSysUser());
|
||||
}
|
||||
}
|
||||
// 部门
|
||||
if (ObjectUtil.isNotEmpty(detail.getDeptId())) {
|
||||
R<SysDept> dept = deptService.getDeptByDeptId(detail.getDeptId());
|
||||
if (ObjectUtil.isNotEmpty(dept.getData())) {
|
||||
DataUtil.convertDept(detail, dept.getData());
|
||||
List<UserVO> userVoList = userService.getUserDeptByIds(List.of(detail.getUserId())).getData();
|
||||
if (ObjectUtil.isNotEmpty(userVoList) && ObjectUtil.isNotEmpty(userVoList.get(0))) {
|
||||
DataUtil.convertUserDept(detail, userVoList.get(0));
|
||||
}
|
||||
}
|
||||
// 商户
|
||||
@@ -1069,20 +1063,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
|
||||
private void disposeList(List<HardOrderVo> list, HardOrderDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 用户
|
||||
// 用户部门
|
||||
List<Long> userIds = list.stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
R<List<SysUser>> userList = userService.getInnerUserById(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
}
|
||||
}
|
||||
// 部门
|
||||
List<Long> deptIds = list.stream().map(HardOrderVo::getUserDeptId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list, deptList.getData());
|
||||
List<UserVO> userList = userService.getUserDeptByIds(new ArrayList<>(userIds)).getData();
|
||||
if (ObjectUtil.isNotEmpty(userList)) {
|
||||
DataUtil.convertUserDeptList(list, CollectionUtils.convertMap(userList, UserVO::getUserId));
|
||||
}
|
||||
}
|
||||
// 商户
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.bsd.pjcloud.hard.service.impl.sync;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.hard.service.HardSyncService;
|
||||
import com.bsd.pjcloud.mqtt.api.feign.RemoteMqttEventService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class HardSyncServiceImpl implements HardSyncService {
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteMqttEventService mqttEventService;
|
||||
|
||||
/**
|
||||
* 同步超市分类商品和同步
|
||||
*/
|
||||
@Override
|
||||
public void syncSupermarket(PjcloudUser user) {
|
||||
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("当前登录用户错误");
|
||||
Long deptId = user.getDeptId();
|
||||
// 查询该用户属于的超市
|
||||
MchManageVo targetMch = remoteMchService.getFirstMchByDeptId(deptId, MerchantTypeEnum.CANTEEN).getData();
|
||||
if (ObjectUtil.isEmpty(targetMch) || ObjectUtil.notEqual(targetMch.getTypes(), MerchantTypeEnum.CANTEEN.getType())) {
|
||||
throw new RuntimeException("您不是超市用户,无法操作");
|
||||
}
|
||||
mqttEventService.sendSupermarketClassifyChangeMsg(deptId);
|
||||
mqttEventService.sendSupermarketProductChangeMsg(deptId);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
+31
@@ -300,6 +300,10 @@
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
and s.category_id is not null
|
||||
<if test="dto.userId != null and dto.userId != '' ">
|
||||
and o.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
@@ -315,6 +319,7 @@
|
||||
</where>
|
||||
group by s.category_id
|
||||
order by s.category_id
|
||||
limit 5
|
||||
</select>
|
||||
|
||||
<select id="productByCanteen" resultType="com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByCanteenVo">
|
||||
@@ -332,6 +337,10 @@
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
and o.pay_time is not null
|
||||
and o.merchant_id is not null
|
||||
<if test="dto.userId != null and dto.userId != '' ">
|
||||
and o.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.canteenIdList != null and dto.canteenIdList.size() != 0">
|
||||
and o.merchant_id in
|
||||
<foreach collection="dto.canteenIdList" item="v" open="(" close=")" separator=",">
|
||||
@@ -349,4 +358,26 @@
|
||||
order by DATE_FORMAT(o.pay_time, '%Y-%m-%d')
|
||||
</select>
|
||||
|
||||
<select id="productLikeTop" resultType="com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductLikeTopVo">
|
||||
select
|
||||
a.product_id as productId,
|
||||
a.product_name as productName,
|
||||
s.category_id as classifyId,
|
||||
SUM(a.product_count) as payCount
|
||||
from pjcloudx_hardware.hard_car a
|
||||
inner join pjcloudx_hardware.hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0'
|
||||
inner join pjcloudx_hardware.hard_order o
|
||||
on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and
|
||||
o.hour_type not in ('-1')
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.userId != null and dto.userId != '' ">
|
||||
and o.user_id = #{dto.userId}
|
||||
</if>
|
||||
</where>
|
||||
group by a.product_id
|
||||
order by SUM(a.product_count) desc
|
||||
limit 10;
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user