feat:H5商户、订单

This commit is contained in:
dzc committed 2025-01-07 10:17:18 +08:00
1 parent e85f331755
commit 14b8f8b434
16 files changed
+173 -57

No files matched your search

@@ -9,7 +9,7 @@ import lombok.RequiredArgsConstructor;
public enum MerchantTypeEnum {
CANTEEN("1", "食堂"),
SUPERMARKET("2", "超市"),
;
;
/**
* 类型
@@ -56,7 +56,7 @@ public class HardApiController {
@GetMapping("/get-order")
@Operation(summary = "获取订单详情")
public R<HardOrderVo> getOrderJoin(@RequestParam Long id) {
return R.ok(hardwareOrderService.getOrderDetail(id));
return R.ok(hardwareOrderService.join(id));
}
@PostMapping("/create-order")
@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
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.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.service.HardOrderService;
@@ -33,10 +35,26 @@ import java.util.List;
@RequestMapping("/hard-order")
@Tag(description = "hard-order", name = "订单表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardwareOrderController {
public class HardOrderController {
private final HardOrderService hardwareOrderService;
/* ************************************* start app start ************************************* */
@Operation(summary = "app查询订单列表", description = "app查询订单列表")
@GetMapping("/app/page-join")
public R appPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(hardwareOrderService.pageJoin(page, dto));
}
@Operation(summary = "app查询订单详情", description = "app查询订单详情")
@GetMapping("/app/detail")
public R appDetail(@RequestParam Long id) {
return R.ok(hardwareOrderService.join(id));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_view')")
@@ -13,7 +13,7 @@ public interface HardOrderService extends IService<HardOrderEntity> {
Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto);
HardOrderVo getOrderDetail(Long id);
HardOrderVo join(Long id);
Long createOrder(HardCreateOrderDto dto);
@@ -67,12 +67,13 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
}
@Override
public HardOrderVo getOrderDetail(Long id) {
public HardOrderVo join(Long id) {
HardOrderDto dto = new HardOrderDto();
dto.setId(id);
return baseMapper.join(dto);
}
/* ************************************* start 支付相关 start ************************************* */
@Override
@Transactional(rollbackFor = Exception.class)
@@ -38,16 +38,23 @@ public class SysUserFaceController {
private final SysUserFaceService sysUserFaceService;
/**
* 分页查询
*
* @param page 分页对象
* @param sysUserFace 人脸样本表
* @return
*/
/* ************************************* start app start ************************************* */
@Operation(summary = "app查询人脸列表", description = "app查询人脸列表")
@GetMapping("/app/page-join")
public R appPageJoin(@ParameterObject Page page, @ParameterObject SysUserFaceDto dto) {
return R.ok(sysUserFaceService.pageJoin(page, dto));
}
@Operation(summary = "app查询人脸列表", description = "app查询人脸列表")
@GetMapping("/app/detail")
public R appDetail(@ParameterObject Page page, @ParameterObject SysUserFaceDto dto) {
return R.ok(sysUserFaceService.pageJoin(page, dto));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
public R getSysUserFacePage(@ParameterObject Page page, @ParameterObject SysUserFaceEntity sysUserFace) {
LambdaQueryWrapper<SysUserFaceEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(sysUserFaceService.page(page, wrapper));
@@ -55,80 +62,47 @@ public class SysUserFaceController {
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
@GetMapping("/page-join")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
public R getSysUserFacePageJoin(@ParameterObject Page page, @ParameterObject SysUserFaceDto dto) {
return R.ok(sysUserFaceService.pageJoin(page, dto));
}
/**
* 通过id查询人脸样本表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysUserFaceService.getById(id));
}
/**
* 新增人脸样本表
*
* @param sysUserFace 人脸样本表
* @return R
*/
@Operation(summary = "新增人脸样本表", description = "新增人脸样本表")
@SysLog("新增人脸样本表")
@PostMapping
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_add')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_add')")
public R save(@RequestBody SysUserFaceEntity sysUserFace) {
return R.ok(sysUserFaceService.create(sysUserFace));
}
/**
* 修改人脸样本表
*
* @param sysUserFace 人脸样本表
* @return R
*/
@Operation(summary = "修改人脸样本表", description = "修改人脸样本表")
@SysLog("修改人脸样本表")
@PutMapping
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_edit')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_edit')")
public R updateById(@RequestBody SysUserFaceEntity sysUserFace) {
sysUserFaceService.edit(sysUserFace);
return R.ok(true);
}
/**
* 通过id删除人脸样本表
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除人脸样本表", description = "通过id删除人脸样本表")
@SysLog("通过id删除人脸样本表")
@DeleteMapping
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_del')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_del')")
public R removeById(@RequestBody Long[] ids) {
sysUserFaceService.delByIds(CollUtil.toList(ids));
return R.ok(true);
}
/**
* 导出excel 表格
*
* @param sysUserFace 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_export')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_export')")
public List<SysUserFaceEntity> export(SysUserFaceEntity sysUserFace, Long[] ids) {
return sysUserFaceService.list(Wrappers.lambdaQuery(sysUserFace).in(ArrayUtil.isNotEmpty(ids), SysUserFaceEntity::getId, ids));
}
@@ -18,4 +18,6 @@ public class MchManageDto extends MchManageEntity {
private List<Long> ids;
private String type;
}
@@ -0,0 +1,28 @@
package com.bsd.pjcloud.wallet.api.dto.recharge.app;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.util.Objects;
@Data
public class WalletAppRechargeDto {
@Schema(description = "支付金额")
@Min(value = 1, message = "支付金额必须大于零")
private Integer payPrice;
@Schema(description = "充值套餐编号")
private Long packageId;
@Schema(description = "钱包Id")
private Long walletId;
@AssertTrue(message = "充值金额和充钱套餐不能同时为空")
public boolean isValidPayPriceAndPackageId() {
return Objects.nonNull(payPrice) || Objects.nonNull(packageId);
}
}
@@ -42,7 +42,6 @@ public class MchManageController {
private final MchManageService mchManageService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-by-id")
public R<MchManageVo> getById(@RequestParam Long id) {
@@ -82,9 +81,22 @@ public class MchManageController {
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(mchManage);
}
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@Operation(summary = "app查询商铺", description = "app查询商铺")
@GetMapping("/app/page-join")
public R<Page<MchManageVo>> appPageJoin(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
return R.ok(mchManageService.pageJoin(page, dto));
}
@Operation(summary = "app查询店铺详情", description = "app查询店铺详情")
@GetMapping("/app/detail")
public R<MchManageVo> appPageJoin(@RequestParam Long id) {
return R.ok(mchManageService.join(id));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeDto;
import com.bsd.pjcloud.wallet.api.dto.recharge.app.WalletAppRechargeDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeEntity;
import com.bsd.pjcloud.wallet.service.WalletRechargeService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -37,6 +38,14 @@ public class WalletRechargeController {
private final WalletRechargeService walletRechargeService;
/* ************************************* start app start ************************************* */
@Operation(summary = "模拟充值", description = "模拟充值")
@PostMapping("/app/create")
public R<WalletRechargeEntity> appRecharge(@RequestBody WalletAppRechargeDto dto) {
return R.ok(walletRechargeService.createWalletRecharge(dto));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletRecharge_view')")
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -19,7 +20,8 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
MPJLambdaQueryWrapper<MchManageEntity> wrapper = new MPJLambdaQueryWrapper<MchManageEntity>()
.selectAll(MchManageEntity.class)
.likeIfExists(MchManageEntity::getName, dto.getName())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), MchManageEntity::getDeptId, dto.getDeptIds());
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), MchManageEntity::getDeptId, dto.getDeptIds())
.apply(ObjectUtil.isNotEmpty(dto.getType()), "FIND_IN_SET({0}, types)", dto.getType());
return selectJoinPage(page, MchManageVo.class, wrapper);
}
@@ -9,4 +9,11 @@ import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargePackageVo;
public interface WalletRechargePackageService extends IService<WalletRechargePackageEntity> {
Page<WalletRechargePackageVo> pageJoin(Page page, WalletRechargePackageDto dto);
/**
* 校验是否有效
* @param packageId
* @return
*/
WalletRechargePackageEntity validEffective(Long packageId);
}
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeDto;
import com.bsd.pjcloud.wallet.api.dto.recharge.app.WalletAppRechargeDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeEntity;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeVo;
@@ -10,4 +11,10 @@ public interface WalletRechargeService extends IService<WalletRechargeEntity> {
Page<WalletRechargeVo> pageJoin(Page page, WalletRechargeDto dto);
/**
* app充值
* @param dto
* @return
*/
WalletRechargeEntity createWalletRecharge(WalletAppRechargeDto dto);
}
@@ -134,7 +134,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
MchManageVo detail = baseMapper.join(id);
if (ObjectUtil.isNotEmpty(detail)) {
// 部门
SysDept dept = remoteDeptService.getDeptByDeptId(id).getData();
SysDept dept = remoteDeptService.getDeptByDeptId(detail.getDeptId()).getData();
if (ObjectUtil.isNotEmpty(dept)) {
DataUtil.convertDept(detail, dept);
}
@@ -1,7 +1,9 @@
package com.bsd.pjcloud.wallet.service.impl.recharge;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargePackageDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargePackageEntity;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargePackageVo;
@@ -23,4 +25,15 @@ public class WalletRechargePackageServiceImpl extends ServiceImpl<WalletRecharge
return baseMapper.pageJoin(page, dto);
}
@Override
public WalletRechargePackageEntity validEffective(Long packageId) {
WalletRechargePackageEntity packageEntity = baseMapper.selectById(packageId);
if (ObjectUtil.isEmpty(packageEntity)) {
throw new RuntimeException("钱包充值套餐不存在");
}
if (ObjectUtil.equals(packageEntity.getStatus(), YesNoEnum.NO.getCode())) {
throw new RuntimeException("钱包充值套餐已禁用");
}
return packageEntity;
}
}
@@ -1,13 +1,28 @@
package com.bsd.pjcloud.wallet.service.impl.recharge;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeDto;
import com.bsd.pjcloud.wallet.api.dto.recharge.app.WalletAppRechargeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeEntity;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargePackageEntity;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeVo;
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeMapper;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletRechargePackageService;
import com.bsd.pjcloud.wallet.service.WalletRechargeService;
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
/**
* 会员钱包充值
@@ -15,13 +30,41 @@ import org.springframework.stereotype.Service;
* @author dzc
* @date 2025-01-03 18:36:02
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class WalletRechargeServiceImpl extends ServiceImpl<WalletRechargeMapper, WalletRechargeEntity> implements WalletRechargeService {
@Lazy
private final WalletRechargeService walletRechargeService;
private final WalletRechargePackageService walletRechargePackageService;
private final WalletManageService walletManageService;
private final WalletTransactionService walletTransactionService;
@Override
public Page<WalletRechargeVo> pageJoin(Page page, WalletRechargeDto dto) {
return baseMapper.pageJoin(page, dto);
}
@Override
@Transactional(rollbackFor = Exception.class)
public WalletRechargeEntity createWalletRecharge(WalletAppRechargeDto dto) {
// 计算充值金额
int payPrice = 0, bonusPrice = 0;
if (ObjectUtil.isNotEmpty(dto.getPackageId())) {
WalletRechargePackageEntity rechargePackage = walletRechargePackageService.validEffective(dto.getPackageId());
payPrice = rechargePackage.getPayPrice();
bonusPrice = rechargePackage.getBonusPrice();
} else {
payPrice = dto.getPayPrice();
}
// 插入充值记录
WalletManageEntity wallet = walletManageService.getWallet(dto.getWalletId());
WalletRechargeEntity rechargeObj = WalletRechargeEntity.builder().walletId(wallet.getId()).payPrice(payPrice).bonusPrice(bonusPrice).totalPrice(payPrice + bonusPrice).packageId(dto.getPackageId()).build();
walletRechargeService.save(rechargeObj);
// 增加余额
walletTransactionService.addWalletBalance(wallet.getId(), rechargeObj.getTotalPrice(), String.valueOf(rechargeObj.getId()), WalletBizEnum.RECHARGE);
return rechargeObj;
}
}