feat:商城支付、时间段选择

This commit is contained in:
dzc committed 2026-06-23 19:07:28 +08:00
1 parent d435283d06
commit 0f7c3c496b
31 files changed
+536 -51

No files matched your search

@@ -3,6 +3,11 @@ package com.bsd.pjcloud.hard.api.dto;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import lombok.Data;
import java.util.List;
@Data
public class HardApptDto extends HardApptEntity {
private List<String> reserveTimeList;
}
@@ -4,6 +4,7 @@ import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@Data
@@ -13,6 +14,8 @@ public class HardCarDto extends HardCarEntity {
private String createTimeStr;
private String orderApptUseDateStr;
private LocalDate[] createTimeList;
private List<String> orderStatusCodes;
@@ -23,4 +26,6 @@ public class HardCarDto extends HardCarEntity {
private List<Long> mchIds;
private LocalDateTime[] apptUseDateTimeList;
}
@@ -42,6 +42,8 @@ public class HardOrderDto extends HardOrderEntity implements BaseIsIncludeTreeIn
private LocalDateTime[] refundTimeList;
private LocalDateTime[] apptUseDateTimeList;
private List<String> orderTypeCodes;
private List<String> orderPayTypeCodes;
@@ -67,6 +69,8 @@ public class HardOrderDto extends HardOrderEntity implements BaseIsIncludeTreeIn
private String createTimeStr;
private String orderApptUseDateStr;
private List<String> saleStatusCodes;
/**
@@ -50,6 +50,9 @@ public class HardAppCreateOrderDto {
// 预约id
private Long apptId;
// 预约时间类型
private String apptTimeType;
// 地址
private HardAppTakeOutAddressDto address;
@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -27,6 +27,12 @@ public class HardApptTimeEntity extends Model<HardApptTimeEntity> {
@Schema(description = "编号")
private Long id;
/**
* 商户ID
*/
@Schema(description = "商户ID")
private Long mchId;
/**
* appt_id
*/
@@ -35,6 +41,7 @@ public class HardApptTimeEntity extends Model<HardApptTimeEntity> {
/**
* 预约时间类型(昨天、今天、明天、自定义)
*
* @see com.bsd.pjcloud.hard.api.constant.HardApptTimeTypeEnum
*/
@Schema(description = "预约时间类型(昨天、今天、明天、自定义)")
@@ -105,6 +105,12 @@ public class HardUserMapAddressEntity extends Model<HardUserMapAddressEntity> {
@Schema(description = "tag")
private String tag;
/**
* 是否为默认地址
*/
@Schema(description = "是否为默认地址")
private String isDefault;
/**
* 创建人
*/
@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
@@ -68,7 +69,6 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
@Schema(description = "商户绑定的部门id")
private Long merchantDeptId;
/**
* 设备id
*/
@@ -129,6 +129,12 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
@Schema(description = "预约时间段id")
private Long apptId;
/**
* 预约使用时间(天)
*/
@Schema(description = "预约使用时间(天)")
private LocalDate apptUseDate;
/**
* 订单设备类型
*/
@@ -0,0 +1,18 @@
package com.bsd.pjcloud.hard.api.vo;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Data
public class HardApptTimeCascadeVo {
private String apptTimeType;
private LocalDate apptTimeWeekStr;
private List<HardApptEntity> apptList;
}
@@ -0,0 +1,12 @@
package com.bsd.pjcloud.hard.api.vo;
import lombok.Data;
@Data
public class HardApptTimeTypeVo {
private Long mchId;
private Long type;
}
@@ -3,6 +3,11 @@ package com.bsd.pjcloud.hard.api.vo;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import lombok.Data;
import java.util.List;
@Data
public class HardApptVo extends HardApptEntity {
private List<String> reserveTimeList;
}
@@ -12,9 +12,15 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.hard.api.constant.HardApptTimeTypeEnum;
import com.bsd.pjcloud.hard.api.dto.HardApptDto;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.api.entity.HardApptTimeEntity;
import com.bsd.pjcloud.hard.api.vo.HardApptTimeCascadeVo;
import com.bsd.pjcloud.hard.api.vo.HardApptTimeTypeVo;
import com.bsd.pjcloud.hard.api.vo.HardApptVo;
import com.bsd.pjcloud.hard.service.HardApptService;
import com.bsd.pjcloud.hard.service.HardApptTimeService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -25,7 +31,12 @@ import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 设备预约管理
@@ -38,6 +49,7 @@ import java.util.List;
public class HardApptController {
private final HardApptService hardApptService;
private final HardApptTimeService hardApptTimeService;
/* ************************************* start app start ************************************* */
@@ -54,12 +66,50 @@ public class HardApptController {
return R.ok(list);
}
@Operation(summary = "app预约时间列表v2", description = "app预约时间列表v2")
@ApiCryptoAes
@GetMapping("/app/v2/list")
public R<List<HardApptTimeCascadeVo>> appV2List(@ParameterObject HardApptDto dto) {
if (ObjectUtil.isEmpty(dto.getMchId())) throw new RuntimeException("商户ID不能为空");
ArrayList<HardApptTimeCascadeVo> resultList = new ArrayList<>();
List<HardApptTimeEntity> apptTimeList = hardApptTimeService.list(new LambdaQueryWrapper<HardApptTimeEntity>()
.eq(HardApptTimeEntity::getMchId, dto.getMchId())
);
if (ObjectUtil.isEmpty(apptTimeList)) return R.ok(resultList);
// 查询mch商户下所有的预约
List<HardApptEntity> apptList = hardApptService.list(new LambdaQueryWrapper<HardApptEntity>().eq(HardApptEntity::getMchId, dto.getMchId()));
// 分组
Map<String, List<HardApptTimeEntity>> apptTimeTypeMap = apptTimeList.stream().collect(Collectors.groupingBy(HardApptTimeEntity::getType));
LocalDate now = LocalDate.now();
for (Map.Entry<String, List<HardApptTimeEntity>> entries : apptTimeTypeMap.entrySet()) {
String key = entries.getKey();
HardApptTimeCascadeVo entity = new HardApptTimeCascadeVo();
HardApptTimeTypeEnum apptTimeType = HardApptTimeTypeEnum.valueOfByTypeOrToday(key);
entity.setApptTimeType(apptTimeType.getType());
entity.setApptTimeWeekStr(now.plusDays(apptTimeType.getDay()));
List<Long> appTIdList = apptTimeList.stream().filter(v -> ObjectUtil.equals(key, v.getType())).map(HardApptTimeEntity::getApptId).toList();
List<HardApptEntity> targetApptList = apptList.stream().filter(v -> appTIdList.contains(v.getId())).toList();
entity.setApptList(targetApptList);
resultList.add(entity);
}
return R.ok(resultList);
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('hard_hardAppt_view')")
public R getHardApptPage(@ParameterObject Page page, @ParameterObject HardApptDto dto) {
public R<Page<HardApptVo>> getHardApptPage(@ParameterObject Page page, @ParameterObject HardApptDto dto) {
return R.ok(hardApptService.scopePage(page, dto, DataScope.of()));
}
@@ -74,7 +124,7 @@ public class HardApptController {
@SysLog("新增设备预约管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('hard_hardAppt_add')")
public R save(@RequestBody HardApptEntity hardAppt) {
public R save(@RequestBody HardApptDto hardAppt) {
return R.ok(hardApptService.create(hardAppt));
}
@@ -82,7 +132,7 @@ public class HardApptController {
@SysLog("修改设备预约管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('hard_hardAppt_edit')")
public R updateById(@RequestBody HardApptEntity hardAppt) {
public R updateById(@RequestBody HardApptDto hardAppt) {
return R.ok(hardApptService.edit(hardAppt));
}
@@ -50,6 +50,14 @@ public class HardUserMapAddressController {
return R.ok(hardUserMapAddressService.scopePageList(page, dto, null));
}
@Operation(summary = "app查询默认地址(没有默认地址就查询第一个地址)", description = "查询默认地址(没有默认地址就查询第一个地址)")
@ApiCryptoAes
@GetMapping("/app/default-address")
public R<HardUserMapAddressVo> appDefaultAddress() {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardUserMapAddressService.defaultAddress(user.getId()));
}
@Operation(summary = "app新增或者修改地址", description = "app新增或者修改地址")
@ApiCryptoAes
@PostMapping("/app/createOrUpdate")
@@ -0,0 +1,60 @@
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.constant.enums.MerchantTypeEnum;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.service.HardCanteenApptTotalService;
import com.bsd.pjcloud.hard.service.HardCanteenTotalService;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
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.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 食堂预约统计
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/hard-canteen-appt-total-log")
@Tag(description = "hard-canteen-appt-total-log", name = "食堂预约统计")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardCanteenApptTotalController {
private final HardCanteenApptTotalService canteenApptTotalService;
private final RemoteMchService remoteMchService;
@Operation(summary = "食堂菜品预约统计", description = "食堂菜品预约统计")
@PostMapping("/proudct-reserv-total")
public R<Page<HardCanteenProductTotalVo>> productReservTotal(@ParameterObject Page page, @RequestBody HardOrderDto dto) {
// 查询商户
MchManageDto mchManageDto = new MchManageDto();
mchManageDto.setTypesList(List.of(MerchantTypeEnum.CANTEEN.getType()));
List<MchManageVo> mchList = remoteMchService.scopeList(mchManageDto).getData();
if (ObjectUtil.isNotEmpty(mchList) && ObjectUtil.isEmpty(dto.getMchIds())) {
dto.setMchIds(mchList.stream().map(MchManageVo::getId).toList());
}
dto.setOrderType(HardOrderTypeEnum.RESERVE.getType());
dto.setApptIdNotNull(true);
return R.ok(canteenApptTotalService.productReservTotal(page, dto, null));
}
}
@@ -1,4 +1,5 @@
package com.bsd.pjcloud.hard.controller.order;
import com.bsd.pjcloud.common.api.encrypt.annotation.crypto.ApiCryptoAes;
import com.bsd.pjcloud.common.core.util.R;
@@ -42,6 +43,7 @@ public class HardCanteenDeptTotalController {
PjcloudUser user = SecurityUtils.getUser();
dto.setTotalIsFindChildren(true);
dto.setApptIdNotNull(true);
return R.ok(canteenTotalService.listByDept(dto, user, dataScope));
}
@@ -142,5 +142,4 @@ public class HardCanteenTotalController {
}
return R.ok(canteenTotalService.proudctMchQuery(page, dto));
}
}
@@ -2,10 +2,15 @@ package com.bsd.pjcloud.hard.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.entity.HardApptTimeEntity;
import com.bsd.pjcloud.hard.api.vo.HardApptTimeTypeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface HardApptTimeMapper extends PjcloudBaseMapper<HardApptTimeEntity> {
List<HardApptTimeTypeVo> getTypeListByMchId(@Param("mchId") Long mchId);
}
@@ -35,6 +35,8 @@ public interface HardCarMapper extends PjcloudBaseMapper<HardCarEntity> {
Page<HardCanteenProductTotalVo> productTotal(Page page, @Param("dto") HardOrderDto dto, DataScope dataScope);
Page<HardCanteenProductTotalVo> productTotalByApptUseDate(Page page, @Param("dto") HardOrderDto dto, DataScope dataScope);
Page<HardCarVo> proudctQuery(Page page, @Param("dto") HardCarDto dto);
/**
@@ -9,18 +9,19 @@ import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.api.vo.HardApptVo;
import java.util.ArrayList;
import java.util.List;
public interface HardApptService extends IService<HardApptEntity> {
/**
* 新增
*/
Long create(HardApptEntity hardAppt);
Long create(HardApptDto hardAppt);
/**
* 修改
*/
Long edit(HardApptEntity hardAppt);
Long edit(HardApptDto hardAppt);
/**
* 删除
@@ -31,4 +32,6 @@ public interface HardApptService extends IService<HardApptEntity> {
* 分页查询
*/
Page<HardApptVo> scopePage(Page page, HardApptDto dto, DataScope of);
List<HardApptVo> scopeList(HardApptDto dto, DataScope of);
}
@@ -2,7 +2,12 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.entity.HardApptTimeEntity;
import com.bsd.pjcloud.hard.api.vo.HardApptTimeTypeVo;
import java.util.List;
public interface HardApptTimeService extends IService<HardApptTimeEntity> {
List<HardApptTimeTypeVo> getTypeListByMchId(Long mchId);
}
@@ -0,0 +1,12 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
public interface HardCanteenApptTotalService {
Page<HardCanteenProductTotalVo> productReservTotal(Page page, HardOrderDto dto, DataScope dataScope);
}
@@ -14,4 +14,9 @@ public interface HardUserMapAddressService extends IService<HardUserMapAddressEn
Long createOrUpdate(HardUserMapAddressDto dto);
Long del(Long id, Long userId);
/**
* 查询默认地址(没有默认地址就查询第一个地址)
*/
HardUserMapAddressVo defaultAddress(Long userId);
}
@@ -1,14 +1,18 @@
package com.bsd.pjcloud.hard.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.HardApptDto;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.api.entity.HardApptTimeEntity;
import com.bsd.pjcloud.hard.api.vo.HardApptVo;
import com.bsd.pjcloud.hard.mapper.HardApptMapper;
import com.bsd.pjcloud.hard.mapper.HardApptTimeMapper;
import com.bsd.pjcloud.hard.service.HardApptService;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
@@ -18,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
import java.util.List;
/**
* 设备预约管理
@@ -28,13 +33,15 @@ import java.util.ArrayList;
@Service
public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEntity> implements HardApptService {
private final HardApptTimeMapper hardApptTimeMapper;
private final RemoteMchService remoteMchService;
/**
* 新增
*/
@Override
public Long create(HardApptEntity dto) {
public Long create(HardApptDto dto) {
// title不能重复
if (existTitle(dto.getTitle(), dto.getMchId(), null)) {
throw new RuntimeException("标题不能重复");
@@ -45,14 +52,15 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
dto.setDeptId(mchDeatil.getDeptId());
}
baseMapper.insert(dto);
return 0L;
createApptTime(dto, dto.getReserveTimeList());
return dto.getId();
}
/**
* 修改
*/
@Override
public Long edit(HardApptEntity dto) {
public Long edit(HardApptDto dto) {
// title不能重复
if (existTitle(dto.getTitle(), dto.getMchId(), dto.getId())) {
throw new RuntimeException("标题不能重复");
@@ -63,6 +71,7 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
dto.setDeptId(mchDeatil.getDeptId());
}
baseMapper.updateById(dto);
createApptTime(dto, dto.getReserveTimeList());
return dto.getId();
}
@@ -84,7 +93,51 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), HardApptEntity::getDeptId, dto.getDeptId())
.like(ObjectUtil.isNotEmpty(dto.getTitle()), HardApptEntity::getTitle, dto.getTitle())
.orderByAsc(HardApptEntity::getHourType);
return baseMapper.selectPageByScope(page, wrapper, of);
Page pageList = baseMapper.selectPageByScope(page, wrapper, of);
List<HardApptVo> hardApptVos = BeanUtil.copyToList(pageList.getRecords(), HardApptVo.class);
pageList.setRecords(hardApptVos);
if (ObjectUtil.isNotEmpty(pageList)) {
disposePageList(pageList.getRecords());
}
return pageList;
}
@Override
public List<HardApptVo> scopeList(HardApptDto dto, DataScope of) {
LambdaQueryWrapper<HardApptEntity> wrapper = new LambdaQueryWrapper<HardApptEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), HardApptEntity::getDeptId, dto.getDeptId())
.like(ObjectUtil.isNotEmpty(dto.getTitle()), HardApptEntity::getTitle, dto.getTitle())
.orderByAsc(HardApptEntity::getHourType);
List<HardApptEntity> list = baseMapper.selectListByScope(wrapper, of);
List<HardApptVo> resultList = BeanUtil.copyToList(list, HardApptVo.class);
if (ObjectUtil.isNotEmpty(resultList)) {
disposePageList(resultList);
}
return resultList;
}
// 创建预约时间
private void createApptTime(HardApptEntity apptEntity, List<String> reserveTimeList) {
if (!ObjectUtil.isAllNotEmpty(apptEntity.getId(), apptEntity.getMchId(), reserveTimeList)) {
return;
}
hardApptTimeMapper.delete(new LambdaQueryWrapper<HardApptTimeEntity>()
.eq(HardApptTimeEntity::getApptId, apptEntity.getId())
.eq(HardApptTimeEntity::getMchId, apptEntity.getMchId())
);
ArrayList<HardApptTimeEntity> addList = new ArrayList<>();
reserveTimeList.forEach(v -> {
HardApptTimeEntity entity = new HardApptTimeEntity();
entity.setMchId(apptEntity.getMchId());
entity.setApptId(apptEntity.getId());
entity.setType(v);
addList.add(entity);
});
hardApptTimeMapper.insert(addList);
}
private boolean existTitle(String title, Long mchId, Long id) {
@@ -99,4 +152,19 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
return count > 0;
}
private void disposePageList(List<HardApptVo> records) {
if (ObjectUtil.isEmpty(records)) return;
List<Long> ids = records.stream().map(HardApptVo::getId).filter(ObjectUtil::isNotNull).distinct().toList();
if (ObjectUtil.isNotEmpty(ids)) {
List<HardApptTimeEntity> targetList = hardApptTimeMapper.selectList(new LambdaQueryWrapper<HardApptTimeEntity>().in(HardApptTimeEntity::getApptId, ids));
for (HardApptVo item : records) {
List<HardApptTimeEntity> apptTimeList = targetList.stream().filter(v -> ObjectUtil.equals(item.getId(), v.getApptId())).toList();
if (ObjectUtil.isNotEmpty(apptTimeList)) {
List<String> typeList = apptTimeList.stream().map(HardApptTimeEntity::getType).toList();
item.setReserveTimeList(typeList);
}
}
}
}
}
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.hard.api.entity.HardApptTimeEntity;
import com.bsd.pjcloud.hard.api.vo.HardApptTimeTypeVo;
import com.bsd.pjcloud.hard.mapper.HardApptTimeMapper;
import com.bsd.pjcloud.hard.service.HardApptTimeService;
import lombok.RequiredArgsConstructor;
@@ -9,6 +10,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
/**
* 设备预约时间管理
*/
@@ -18,4 +21,9 @@ import org.springframework.validation.annotation.Validated;
@Service
public class HardApptTimeServiceImpl extends ServiceImpl<HardApptTimeMapper, HardApptTimeEntity> implements HardApptTimeService {
@Override
public List<HardApptTimeTypeVo> getTypeListByMchId(Long mchId) {
return baseMapper.getTypeListByMchId(mchId);
}
}
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.address.HardUserMapAddressDto;
@@ -72,4 +73,26 @@ public class HardUserMapAddressServiceImpl extends ServiceImpl<HardUserMapAddres
baseMapper.deleteById(id);
return id;
}
@Override
public HardUserMapAddressVo defaultAddress(Long userId) {
HardUserMapAddressEntity defaultAddress = baseMapper.selectOne(new LambdaQueryWrapper<HardUserMapAddressEntity>()
.eq(HardUserMapAddressEntity::getUserId, userId)
.eq(HardUserMapAddressEntity::getIsDefault, YesNoEnum.YES.getCode())
.last("limit 1")
);
if (ObjectUtil.isNotEmpty(defaultAddress)) {
return BeanUtils.toBean(defaultAddress, HardUserMapAddressVo.class);
}
// 没有默认就查询第一个
HardUserMapAddressEntity firstAddress = baseMapper.selectOne(new LambdaQueryWrapper<HardUserMapAddressEntity>()
.eq(HardUserMapAddressEntity::getUserId, userId)
.orderByDesc(HardUserMapAddressEntity::getCreateTime)
.last("limit 1")
);
if (ObjectUtil.isNotEmpty(firstAddress)) {
return BeanUtils.toBean(firstAddress, HardUserMapAddressVo.class);
}
return null;
}
}
@@ -0,0 +1,42 @@
package com.bsd.pjcloud.hard.service.impl.order;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
import com.bsd.pjcloud.hard.mapper.order.HardCarMapper;
import com.bsd.pjcloud.hard.service.HardCanteenApptTotalService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDate;
/**
* 食堂统计
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardCanteenApptTotalServiceImpl implements HardCanteenApptTotalService {
private final HardCarMapper hardCarMapper;
@Override
public Page<HardCanteenProductTotalVo> productReservTotal(Page page, HardOrderDto dto, DataScope dataScope) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
Page<HardCanteenProductTotalVo> pageList = hardCarMapper.productTotalByApptUseDate(page, dto, null);
if (ObjectUtil.isNotEmpty(pageList)) {
for (HardCanteenProductTotalVo v : pageList.getRecords()) {
LocalDate localDate = v.getCreateTime().toLocalDate();
v.setUniqueCode(localDate + "_" + v.getHourType());
}
}
return pageList;
}
}
@@ -573,6 +573,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}).toList();
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
String subject = hardCarService.computerCarSubject(hardType, dto.getOrderType(), carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.userId(userDetail.getSysUser().getUserId())
@@ -598,6 +599,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
if (ObjectUtil.isEmpty(hardAppt)) throw new RuntimeException("预约时间段不存在");
orderObj.setHourType(hardAppt.getHourType());
orderObj.setApptId(hardAppt.getId());
orderObj.setApptUseDate(getApptTime(dto.getApptTimeType()));
}
if (isPay) orderObj.setWalletId(wallet.getId());
baseMapper.insert(orderObj);
@@ -2046,11 +2048,17 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
LocalDate now = LocalDate.now();
LocalDateTime startTime = apptDetail.getStartTime().atDate(now).plus(startTimeType.getDay(), ChronoUnit.DAYS);
LocalDateTime endTime = apptDetail.getEndTime().atDate(now).plus(endTimeType.getDay(), ChronoUnit.DAYS);
LocalDateTime startTime = apptDetail.getStartTime().atDate(now).plusDays(startTimeType.getDay());
LocalDateTime endTime = apptDetail.getEndTime().atDate(now).plusDays(endTimeType.getDay());
return LocalDateTime.now().isAfter(startTime) && LocalDateTime.now().isBefore(endTime);
}
private LocalDate getApptTime(String apptTimeType) {
if (ObjectUtil.isEmpty(apptTimeType)) return LocalDate.now();
HardApptTimeTypeEnum apptTimeTypeEnum = HardApptTimeTypeEnum.valueOfByTypeOrToday(apptTimeType);
return LocalDate.now().plusDays(apptTimeTypeEnum.getDay());
}
/* ************************************* end 支付相关 end ************************************* */
private HardOrderServiceImpl getSelf() {
@@ -3,4 +3,13 @@
<mapper namespace="com.bsd.pjcloud.hard.mapper.HardApptTimeMapper">
<select id="getTypeListByMchId" resultType="com.bsd.pjcloud.hard.api.vo.HardApptTimeTypeVo">
select a.mch_id, a.type
from hard_appt_time a
where a.del_flag = '0'
and a.mch_id = #{mchId}
group by a.type
order by a.type
</select>
</mapper>
@@ -18,6 +18,7 @@
a.username,
a.user_moblie,
a.tag,
a.is_default,
a.create_by,
a.create_time,
a.update_by,
@@ -47,6 +47,12 @@
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and o.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
<if test="dto.apptUseDateTimeList != null and dto.apptUseDateTimeList.length == 2">
and o.appt_use_date between #{dto.apptUseDateTimeList[0]} and #{dto.apptUseDateTimeList[1]}
</if>
<if test="dto.orderApptUseDateStr != null and dto.orderApptUseDateStr != '' ">
and DATE_FORMAT(o.appt_use_date, '%Y-%m-%d') = #{dto.orderApptUseDateStr}
</if>
</sql>
<select id="productTotalByDept" resultType="com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo">
@@ -90,6 +96,22 @@
#{v}
</foreach>
</if>
<if test="dto.userDeptIds != null and dto.userDeptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and o.user_dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and o.user_dept_id NOT IN
</when>
<otherwise>
and o.user_dept_id IN
</otherwise>
</choose>
<foreach collection="dto.userDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.merchantDeptIds != null and dto.merchantDeptIds.size() != 0">
and o.merchant_dept_id in
<foreach collection="dto.merchantDeptIds" item="v" open="(" close=")" separator=",">
@@ -169,6 +191,22 @@
#{v}
</foreach>
</if>
<if test="dto.userDeptIds != null and dto.userDeptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and o.user_dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and o.user_dept_id NOT IN
</when>
<otherwise>
and o.user_dept_id IN
</otherwise>
</choose>
<foreach collection="dto.userDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.merchantDeptIds != null and dto.merchantDeptIds.size() != 0">
and o.merchant_dept_id in
<foreach collection="dto.merchantDeptIds" item="v" open="(" close=")" separator=",">
@@ -198,6 +236,104 @@
order by DATE_FORMAT(a.create_time, '%Y-%m-%d') desc, o.hour_type;
</select>
<select id="productTotalByApptUseDate" resultType="com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo">
select DATE_FORMAT(o.appt_use_date, '%Y-%m-%d') as createTime,
o.hour_type,
SUM(a.product_count) as payCount,
SUM(a.total_price) as totalPrice,
count(distinct o.id) as timeCount,
count(distinct o.user_id) as payUserCount
from hard_car a
inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0'
inner join 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')
<where>
<include refid="whereA"/>
<if test="dto.apptIdNotNull != null and dto.apptIdNotNull == true ">
and o.appt_id is not null
</if>
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and o.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
<if test="dto.hourType != null and dto.hourType != '' ">
and o.hour_type = #{dto.hourType}
</if>
<if test="dto.orderType != null and dto.orderType != '' ">
and o.order_type = #{dto.orderType}
</if>
<if test="dto.merchantId != null">
and o.merchant_id = #{dto.merchantId}
</if>
<if test="dto.isOfflineOrder != null">
and o.is_offline_order = #{dto.isOfflineOrder}
</if>
<if test="dto.scopeDeptIds != null and dto.scopeDeptIds.size() != 0">
and o.dept_id IN
<foreach collection="dto.scopeDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and o.dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and o.dept_id NOT IN
</when>
<otherwise>
and o.dept_id IN
</otherwise>
</choose>
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.userDeptIds != null and dto.userDeptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and o.user_dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and o.user_dept_id NOT IN
</when>
<otherwise>
and o.user_dept_id IN
</otherwise>
</choose>
<foreach collection="dto.userDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.merchantDeptIds != null and dto.merchantDeptIds.size() != 0">
and o.merchant_dept_id in
<foreach collection="dto.merchantDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.mchIds != null and dto.mchIds.size() != 0">
and o.merchant_id in
<foreach collection="dto.mchIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.orderStatusCodes != null and dto.orderStatusCodes.size() != 0">
and o.order_status in
<foreach collection="dto.orderStatusCodes" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
and o.merchant_type in
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
</where>
group by DATE_FORMAT(o.appt_use_date, '%Y-%m-%d'), o.hour_type
order by DATE_FORMAT(o.appt_use_date, '%Y-%m-%d') desc, o.hour_type
</select>
<select id="proudctQuery" resultType="com.bsd.pjcloud.hard.api.vo.order.HardCarVo">
select a.product_id,
a.product_name,
@@ -2,44 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.hard.mapper.order.HardOrderMapper">
<resultMap id="hardwareOrderMap" type="com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity">
<id property="id" column="id"/>
<result property="orderNo" column="order_no"/>
<result property="userId" column="user_id"/>
<result property="userDeptId" column="user_dept_id"/>
<result property="merchantId" column="merchant_id"/>
<result property="merchantType" column="merchant_type"/>
<result property="merchantDeptId" column="merchant_dept_id"/>
<result property="hardId" column="hard_id"/>
<result property="deptId" column="dept_id"/>
<result property="walletId" column="wallet_id"/>
<result property="parentCarId" column="parent_car_id"/>
<result property="orderSourceTypeId" column="order_source_type_id"/>
<result property="orderType" column="order_type"/>
<result property="orderStatus" column="order_status"/>
<result property="payType" column="pay_type"/>
<result property="hourType" column="hour_type"/>
<result property="sysType" column="sys_type"/>
<result property="totalPrice" column="total_price"/>
<result property="extraPrice" column="extra_price"/>
<result property="payPrice" column="pay_price"/>
<result property="payTime" column="pay_time"/>
<result property="payRefundId" column="pay_refund_id"/>
<result property="refundPrice" column="refund_price"/>
<result property="refundTime" column="refund_time"/>
<result property="refundStatus" column="refund_status"/>
<result property="applyCancelTime" column="apply_cancel_time"/>
<result property="androidOrderCode" column="android_order_code"/>
<result property="isOfflineOrder" column="is_offline_order"/>
<result property="productDesc" column="product_desc"/>
<result property="offlinePaySuccess" column="offline_pay_success"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<sql id="selectA">
select a.id,
@@ -59,6 +22,7 @@
a.pay_type,
a.hour_type,
a.appt_id,
a.appt_use_date,
a.sys_type,
a.total_price,
a.extra_price,
@@ -204,6 +168,9 @@
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
<if test="dto.apptUseDateTimeList != null and dto.apptUseDateTimeList.length == 2">
and a.appt_use_date between #{dto.apptUseDateTimeList[0]} and #{dto.apptUseDateTimeList[1]}
</if>
<if test="dto.payTimeList != null and dto.payTimeList.length == 2">
and a.pay_time between #{dto.payTimeList[0]} and #{dto.payTimeList[1]}
</if>