Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-01-06 14:13:46 +08:00
commit 015a660e15
44 files changed
+997 -95

No files matched your search

+25 -1
View File
@@ -348,4 +348,28 @@ create table wallet_recharge
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='会员钱包充值';
DEFAULT CHARSET = utf8mb4 COMMENT ='会员钱包充值';
-- ----------------------------
-- Table structure for wallet_setting
-- ----------------------------
DROP TABLE IF EXISTS wallet_setting;
CREATE TABLE wallet_setting
(
id bigint NOT NULL AUTO_INCREMENT COMMENT '创建者',
pay_amount_meal_limit int COMMENT '每一餐的上限(分)',
pay_amount_meal_times decimal(10, 2) COMMENT '每一餐的倍数',
pay_amount_enable char(1) DEFAULT '0' NOT NULL COMMENT '是否开启每一餐的额外缴费',
refresh_qr_code_enable char(1) DEFAULT '0' COMMENT '是否开启钱包二维码刷新',
refresh_qr_code_fre int COMMENT '二维码刷新频率',
off_line_order_apply_enable char(1) DEFAULT '0' NOT NULL COMMENT '是否开启离线订单的审批',
after_sale_refund_reasons varchar(2048) COMMENT '退款理由',
after_sale_return_reasons varchar(2048) 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 ='支付设置';
@@ -36,51 +36,54 @@ import java.util.Objects;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/canteenSpu" )
@Tag(description = "canteenSpu" , name = "菜品spu管理" )
@RequestMapping("/canteenSpu")
@Tag(description = "canteenSpu", name = "菜品spu管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CanteenSpuController {
private final CanteenSpuService canteenSpuService;
private final CanteenSpuService canteenSpuService;
/**
* 分页查询
* @param page 分页对象
*
* @param page 分页对象
* @param canteenSpu 菜品spu
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')" )
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')")
public R getCanteenSpuPage(@ParameterObject Page page, @ParameterObject CanteenSpuEntity canteenSpu) {
LambdaQueryWrapper<CanteenSpuEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(canteenSpu.getName()),CanteenSpuEntity::getName,canteenSpu.getName());
wrapper.eq(Objects.nonNull(canteenSpu.getCategoryId()),CanteenSpuEntity::getCategoryId,canteenSpu.getCategoryId());
wrapper.like(StrUtil.isNotBlank(canteenSpu.getName()), CanteenSpuEntity::getName, canteenSpu.getName());
wrapper.eq(Objects.nonNull(canteenSpu.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenSpu.getCategoryId());
return R.ok(canteenSpuService.page(page, wrapper));
}
/**
* 通过id查询菜品spu
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')" )
public R getById(@PathVariable("id" ) Long id) {
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(canteenSpuService.getById(id));
}
/**
* 新增菜品spu
*
* @param canteenSpu 菜品spu
* @return R
*/
@Operation(summary = "新增菜品spu" , description = "新增菜品spu" )
@SysLog("新增菜品spu" )
@Operation(summary = "新增菜品spu", description = "新增菜品spu")
@SysLog("新增菜品spu")
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_add')" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_add')")
public R save(@RequestBody CanteenSpuEntity canteenSpu) {
canteenSpu.setDeptId(SecurityUtils.getUser().getDeptId());
return R.ok(canteenSpuService.save(canteenSpu));
@@ -88,26 +91,28 @@ public class CanteenSpuController {
/**
* 修改菜品spu
*
* @param canteenSpu 菜品spu
* @return R
*/
@Operation(summary = "修改菜品spu" , description = "修改菜品spu" )
@SysLog("修改菜品spu" )
@Operation(summary = "修改菜品spu", description = "修改菜品spu")
@SysLog("修改菜品spu")
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')")
public R updateById(@RequestBody CanteenSpuEntity canteenSpu) {
return R.ok(canteenSpuService.updateById(canteenSpu));
}
/**
* 通过id删除菜品spu
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除菜品spu" , description = "通过id删除菜品spu" )
@SysLog("通过id删除菜品spu" )
@Operation(summary = "通过id删除菜品spu", description = "通过id删除菜品spu")
@SysLog("通过id删除菜品spu")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_del')" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(canteenSpuService.removeBatchByIds(CollUtil.toList(ids)));
}
@@ -115,37 +120,37 @@ public class CanteenSpuController {
/**
* 导出excel 表格
*
* @param canteenSpu 查询条件
* @param ids 导出指定ID
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_export')" )
public List<CanteenSpuEntity> export(CanteenSpuEntity canteenSpu,Long[] ids) {
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_export')")
public List<CanteenSpuEntity> export(CanteenSpuEntity canteenSpu, Long[] ids) {
return canteenSpuService.list(Wrappers.lambdaQuery(canteenSpu).in(ArrayUtil.isNotEmpty(ids), CanteenSpuEntity::getId, ids));
}
// --------------APP-----------------
/**
* 获取菜品列表
*
* @param categoryId 分类编号,不传默认查询全部
* @return
*/
@GetMapping("/ad/getCanteenSpuList")
public R getCanteenSpuList(@RequestParam(value = "categoryId",required = false)String categoryId){
public R getCanteenSpuList(@RequestParam(value = "categoryId", required = false) String categoryId) {
return canteenSpuService.getCanteenSpuList(categoryId);
}
@PostMapping("/ad/updateSkuStock")
@SysLog("更新菜品库存")
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')" )
public R updateSkuStock(@RequestBody CanteenSpuUpdateStockReqDTO updateStockReqDTO){
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')")
public R updateSkuStock(@RequestBody CanteenSpuUpdateStockReqDTO updateStockReqDTO) {
return canteenSpuService.updateSkuStock(updateStockReqDTO);
}
@@ -128,5 +128,7 @@ public interface CacheConstants {
String WALLET_TYPE_DETAIL = "wallet:detail:type";
String WALLET_SETTING_DETAIL = "wallet:detail:setting";
/* ************************************* end 钱包相关 end ************************************* */
}
@@ -48,5 +48,9 @@
<version>5.7.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>
@@ -13,12 +13,12 @@ import java.util.Arrays;
@Getter
public enum HardTypeEnum {
SUPERMARKET(1, "超市"),
CANTEEN(2, "食堂"),
READ_CARD(3, "读卡器"),
DOOR(4, "生鲜柜"),
SUPERMARKET("1", "超市"),
CANTEEN("2", "食堂"),
READ_CARD("3", "读卡器"),
DOOR("4", "生鲜柜"),
;
private final Integer type;
private final String type;
private final String description;
public static HardTypeEnum valueOfByType(Integer type) {
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.hard.api.dto.hard;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class HardBindDto {
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "设备ID")
private Long id;
@Schema(description = "mac地址", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "mac地址")
private String uniqueCode;
}
@@ -0,0 +1,71 @@
package com.bsd.pjcloud.hard.api.dto.hard;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Data
public class HardCreateOrderDto {
@Schema(description = "安卓订单code")
@NotNull(message = "安卓订单code不能为空")
private String androidOrderCode;
@Schema(description = "设备类型")
@NotNull(message = "设备类型不能为空")
private HardTypeEnum sysType;
@Schema(description = "商户id")
@NotNull(message = "商户id不能为空")
private Long merchantId;
@Schema(description = "设备id")
@NotNull(message = "设备id不能为空")
private Long hardwareId;
@Schema(description = "设备名")
private String hardwareName;
@Schema(description = "用餐类型")
@NotNull(message = "用餐类型不能为空")
private Integer hourType;
@Schema(description = "用户id")
@NotNull(message = "用户id不能为空")
private Long userId;
@Schema(description = "订单类型")
@NotNull(message = "订单类型不能为空")
private HardOrderTypeEnum orderType;
@Schema(description = "订单类型渠道id")
private Long orderSourceTypeId;
@Schema(description = "支付类型")
@NotNull(message = "支付类型不能为空")
private HardPayTypeEnum orderPayType;
@Schema(description = "购物车")
@NotEmpty(message = "购物车不能为空")
private List<HardCreateCarDto> list;
@Schema(description = "是否是离线订单")
private Boolean isOfflineOrder;
@Schema(description = "商品的简短描述")
private String productDesc;
private String clientIP;
private Long deptId;
@Schema(description = "离线支付是否成功")
private Boolean offlinePaySuccess;
}
@@ -0,0 +1,23 @@
package com.bsd.pjcloud.hard.api.dto.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class HardCreateCarDto {
@Schema(description = "父购物车id", requiredMode = Schema.RequiredMode.REQUIRED)
private Long parentCarId;
@Schema(description = "商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1034")
private Long productId;
// TODO 食堂特有
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20798")
private Integer productCount;
// TODO 超市特有
@Schema(description = "重量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20798")
private BigDecimal productWeight;
}
@@ -4,5 +4,5 @@ import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import lombok.Data;
@Data
public class HardwareOrderDto extends HardwareOrderEntity {
public class HardOrderDto extends HardwareOrderEntity {
}
@@ -3,8 +3,7 @@ package com.bsd.pjcloud.hard.api.entity.order;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -15,6 +14,9 @@ import java.time.LocalDateTime;
* @author dzc
* @date 2025-01-05 16:44:54
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@TenantTable
@TableName("hard_car")
@@ -3,8 +3,7 @@ package com.bsd.pjcloud.hard.api.entity.order;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
@@ -14,6 +13,9 @@ import java.time.LocalDateTime;
* @author dzc
* @date 2025-01-05 16:45:33
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@TenantTable
@TableName("hard_parent_car")
@@ -6,11 +6,14 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.tuple.ImmutablePair;
import javax.xml.stream.events.StartDocument;
@UtilityClass
public class HardUtil {
public Pair<String, String> generate(QRCodeDto dto) {
public ImmutablePair<String, String> generate(QRCodeDto dto) {
String fileName = "qrcode";
if (ObjectUtil.isEmpty(dto.getId())) {
fileName += "_unknown";
@@ -38,7 +41,7 @@ public class HardUtil {
fileName += "_" + dto.getPayType().toString();
}
String coeContent = Base64.encode(JSONUtil.toJsonStr(dto));
return new Pair<>(fileName, coeContent);
return ImmutablePair.of(fileName, coeContent);
}
}
@@ -4,5 +4,5 @@ import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import lombok.Data;
@Data
public class HardwareOrderVo extends HardwareOrderEntity {
public class HardOrderVo extends HardwareOrderEntity {
}
@@ -100,6 +100,16 @@
<version>5.7.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-idempotent</artifactId>
</dependency>
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-canteen-biz</artifactId>
<version>5.7.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
@@ -0,0 +1,69 @@
package com.bsd.pjcloud.hard.controller.hard;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.service.HardCarService;
import com.bsd.pjcloud.hard.service.HardManagerService;
import com.bsd.pjcloud.hard.service.HardwareOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.hutool.extra.servlet.JakartaServletUtil.getClientIP;
@RestController
@RequiredArgsConstructor
@RequestMapping("/hard-api")
@Tag(description = "hard-api", name = "硬件")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardApiController {
private final HardManagerService hardManagerService;
private final HardCarService hardCarService;
private final HardwareOrderService hardwareOrderService;
@PostMapping("/bind")
@Operation(summary = "绑定服务端设备")
public R<HardManagerVo> bind(@RequestBody HardBindDto dto) {
return R.ok(hardManagerService.bind(dto));
}
@GetMapping("/get")
@Operation(summary = "获取硬件配置信息")
public R<HardManagerVo> get(@RequestParam Long id) {
return R.ok(BeanUtils.toBean(hardManagerService.getById(id), HardManagerVo.class));
}
@GetMapping("/get-by-order-id")
@Operation(summary = "根据订单id查询购物车详情")
public R<List<HardCarVo>> getByOrderId(@RequestParam Long orderId) {
return R.ok(hardCarService.getByOrderId(orderId));
}
@GetMapping("/get-order")
@Operation(summary = "获取订单详情")
public R<HardOrderVo> getOrderJoin(@RequestParam Long id) {
return R.ok(hardwareOrderService.getOrderDetail(id));
}
@PostMapping("/create-order")
@Operation(summary = "创建订单")
@Idempotent(expireTime = 10, info = "正在创建订单中,请勿重复操作")
public R<Long> createOrder(HttpServletRequest request, @RequestBody HardCreateOrderDto dto) {
dto.setClientIP(getClientIP(request));
return R.ok(hardwareOrderService.createOrder(dto));
}
}
@@ -7,7 +7,7 @@ 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.hard.api.dto.order.HardwareOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import com.bsd.pjcloud.hard.service.HardwareOrderService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -30,8 +30,8 @@ import java.util.List;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/hardware-order")
@Tag(description = "hardware-order", name = "订单表管理")
@RequestMapping("/hard-order")
@Tag(description = "hard-order", name = "订单表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardwareOrderController {
@@ -48,7 +48,7 @@ public class HardwareOrderController {
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_view')")
public R pageJoin(@ParameterObject Page page, @ParameterObject HardwareOrderDto dto) {
public R pageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
return R.ok(hardwareOrderService.pageJoin(page, dto));
}
@@ -0,0 +1,24 @@
package com.bsd.pjcloud.hard.mapper.order;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HardOrderMapper extends PjcloudBaseMapper<HardwareOrderEntity> {
default Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto) {
MPJLambdaWrapper<HardwareOrderEntity> wrapper = new MPJLambdaWrapper<HardwareOrderEntity>()
.selectAll(HardwareOrderEntity.class);
return selectJoinPage(page, HardOrderVo.class, wrapper);
}
default HardOrderVo join(HardOrderDto dto) {
MPJLambdaWrapper<HardwareOrderEntity> wrapper = new MPJLambdaWrapper<HardwareOrderEntity>()
.selectAll(HardwareOrderEntity.class);
return selectJoinOne(HardOrderVo.class, wrapper);
}
}
@@ -1,19 +0,0 @@
package com.bsd.pjcloud.hard.mapper.order;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.dto.order.HardwareOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardwareOrderVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HardwareOrderMapper extends PjcloudBaseMapper<HardwareOrderEntity> {
default Page<HardwareOrderVo> pageJoin(Page page, HardwareOrderDto dto) {
MPJLambdaWrapper<HardwareOrderEntity> wrapper = new MPJLambdaWrapper<HardwareOrderEntity>()
.selectAll(HardwareOrderEntity.class);
return selectJoinPage(page, HardwareOrderVo.class, wrapper);
}
}
@@ -2,11 +2,30 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
public interface HardCarService extends IService<HardCarEntity> {
Page<HardCarVo> pageJoin(Page page, HardCarDto dto);
List<HardCarVo> getByOrderId(Long orderId);
Integer computerCarTotalPrice(@NotNull HardTypeEnum sysType, @NotEmpty List<HardCreateCarDto> list);
/**
* @param userId 用户id
* @param merchantId 商户id
* @param sysType 硬件设备类型
* @param list g购物车类表
* @return 父购物车id
*/
Long createCard(Long userId, Long merchantId, HardTypeEnum sysType, List<HardCreateCarDto> list);
}
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
@@ -14,4 +15,5 @@ public interface HardManagerService extends IService<HardManagerEntity> {
void edit(HardManagerDto dto);
HardManagerVo bind(HardBindDto dto);
}
@@ -2,11 +2,24 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.dto.order.HardwareOrderDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardwareOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
public interface HardwareOrderService extends IService<HardwareOrderEntity> {
Page<HardwareOrderVo> pageJoin(Page page, HardwareOrderDto dto);
Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto);
HardOrderVo getOrderDetail(Long id);
Long createOrder(HardCreateOrderDto dto);
/**
* 计算额外金额
*
* @param price 购物车总价
* @return
*/
Integer computeExtraPrice(Integer price);
}
@@ -7,7 +7,10 @@ import com.bsd.pjcloud.hard.api.entity.HardInvoiceEntity;
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
import com.bsd.pjcloud.hard.mapper.HardInvoiceMapper;
import com.bsd.pjcloud.hard.service.HardInvoiceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* 发票记录
@@ -15,6 +18,9 @@ import org.springframework.stereotype.Service;
* @author dzc
* @date 2025-01-05 14:17:32
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardInvoiceServiceImpl extends ServiceImpl<HardInvoiceMapper, HardInvoiceEntity> implements HardInvoiceService {
@@ -7,21 +7,20 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
import com.bsd.pjcloud.hard.service.HardManagerService;
import com.bsd.pjcloud.hard.common.config.MqttConfig;
import com.bsd.pjcloud.hard.utils.MqTopicUtil;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.utils.MchDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -102,6 +101,17 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
baseMapper.updateById(dto);
}
@Override
public HardManagerVo bind(HardBindDto dto) {
HardManagerEntity detail = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(detail)) {
throw new RuntimeException("设备不存在");
}
HardManagerEntity updateObj = HardManagerEntity.builder().id(detail.getId()).uniqueCode(dto.getUniqueCode()).build();
baseMapper.updateById(updateObj);
return BeanUtils.toBean(baseMapper.selectById(dto.getId()), HardManagerVo.class);
}
private String createMqConfigByAction(Long deptId, Long hardId, Integer action) {
MqTopicUtil eventDto = MqTopicUtil.builder().deptId(deptId).hardId(hardId).build();
if (ObjectUtil.equals(action, 1)) {
@@ -1,24 +1,101 @@
package com.bsd.pjcloud.hard.service.impl.order;
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.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.mapper.order.HardCarMapper;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.mapper.order.HardParentCarMapper;
import com.bsd.pjcloud.hard.service.HardCarService;
import com.bsd.pjcloud.hard.service.HardParentCarService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 购物车表
*
* @author dzc
* @date 2025-01-05 16:44:54
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity> implements HardCarService {
private final HardOrderMapper hardCarMapper;
private final HardParentCarMapper hardParentCarMapper;
@Override
public Page<HardCarVo> pageJoin(Page page, HardCarDto dto) {
return baseMapper.pageJoin(page,dto);
return baseMapper.pageJoin(page, dto);
}
@Override
public List<HardCarVo> getByOrderId(Long orderId) {
HardwareOrderEntity order = hardCarMapper.selectById(orderId);
if (ObjectUtil.isEmpty(order)) return null;
List<HardCarEntity> list = baseMapper.selectList(new LambdaQueryWrapper<HardCarEntity>()
.eq(HardCarEntity::getParentCarId, order.getParentCarId())
);
return BeanUtils.toBean(list, HardCarVo.class);
}
@Override
public Integer computerCarTotalPrice(HardTypeEnum sysType, List<HardCreateCarDto> list) {
return switch (sysType) {
case CANTEEN -> {
int canteenTotalPrice = 0;
for (HardCreateCarDto v : list) {
}
yield canteenTotalPrice;
}
case SUPERMARKET -> {
int supermarketTotalPrice = 0;
for (HardCreateCarDto v : list) {
}
yield supermarketTotalPrice;
}
default -> null;
};
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long createCard(Long userId, Long merchantId, HardTypeEnum sysType, List<HardCreateCarDto> list) {
HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(userId).merchantId(merchantId).orderStatus(sysType.getType()).build();
hardParentCarMapper.insert(parentCarObj);
List<HardCarEntity> carObjectList = new ArrayList<>();
for (HardCreateCarDto v : list) {
HardCarEntity item = HardCarEntity.builder().parentCarId(parentCarObj.getId()).build();
if (ObjectUtil.equals(sysType, HardTypeEnum.SUPERMARKET)) {
item.setProductCount(1);
item.setProductWeight(v.getProductWeight());
}
if (ObjectUtil.equals(sysType, HardTypeEnum.CANTEEN)) {
item.setProductCount(v.getProductCount());
item.setProductWeight(new BigDecimal(0));
}
}
baseMapper.insert(carObjectList);
return parentCarObj.getId();
}
}
@@ -4,13 +4,20 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
import com.bsd.pjcloud.hard.mapper.order.HardParentCarMapper;
import com.bsd.pjcloud.hard.service.HardParentCarService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* 父订单表
*
* @author dzc
* @date 2025-01-05 16:45:33
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardParentCarServiceImpl extends ServiceImpl<HardParentCarMapper, HardParentCarEntity> implements HardParentCarService {
}
@@ -1,13 +1,34 @@
package com.bsd.pjcloud.hard.service.impl.order;
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.hard.api.dto.order.HardwareOrderDto;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardwareOrderVo;
import com.bsd.pjcloud.hard.mapper.order.HardwareOrderMapper;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.service.HardCarService;
import com.bsd.pjcloud.hard.service.HardManagerService;
import com.bsd.pjcloud.hard.service.HardwareOrderService;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.Optional;
/**
* 订单表
@@ -15,11 +36,101 @@ import org.springframework.stereotype.Service;
* @author dzc
* @date 2025-01-05 16:46:25
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardwareOrderServiceImpl extends ServiceImpl<HardwareOrderMapper, HardwareOrderEntity> implements HardwareOrderService {
public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardwareOrderEntity> implements HardwareOrderService {
private final HardManagerService hardManagerService;
private final HardCarService hardCarService;
private final RemoteMchService remoteMchService;
private final RemoteCodeUseService remoteCodeUseService;
private final RemoteWalletService remoteWalletService;
@Override
public Page<HardwareOrderVo> pageJoin(Page page, HardwareOrderDto dto) {
public Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto) {
return baseMapper.pageJoin(page, dto);
}
@Override
public HardOrderVo getOrderDetail(Long id) {
HardOrderDto dto = new HardOrderDto();
dto.setId(id);
return baseMapper.join(dto);
}
/* ************************************* start 支付相关 start ************************************* */
@Override
@Transactional(rollbackFor = Exception.class)
public Long createOrder(HardCreateOrderDto dto) {
if (!validateCreateOrderDto(dto)) return null;
if (!validateCodeIsCancel(dto.getOrderType(), dto.getOrderSourceTypeId())) return null;
// 是否需要支付
boolean isPay = isPay(dto.getOrderType(), dto.getOrderPayType());
// 是否需要支付额外金额
boolean isExtraPrice = isExtraPrice(dto.getSysType());
// 饭卡钱包
WalletManageEntity wallet = null;
if (isPay) {
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeCodeEnum.CANTEEN);
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
}
int totalPrice = 0, extraPrice = 0, payPrice = 0;
totalPrice = hardCarService.computerCarTotalPrice(dto.getSysType(), dto.getList());
if (isExtraPrice) extraPrice = computeExtraPrice(totalPrice);
payPrice = totalPrice + extraPrice;
// 判断余额够不够支付
if (isPay && wallet.getBalance() < payPrice) throw new RuntimeException("钱包余额不足");
// 添加购物车
Long parentCarId = hardCarService.createCard(dto.getUserId(), dto.getMerchantId(), dto.getSysType(), dto.getList());
return 0L;
}
@Override
public Integer computeExtraPrice(Integer price) {
return 0;
}
// 是否需要支付(目前只有线下的现金是不走平台扣款)
private boolean isPay(HardOrderTypeEnum type, HardPayTypeEnum payType) {
return ObjectUtil.equals(type, HardOrderTypeEnum.BELOW) && !ObjectUtil.equals(payType, HardPayTypeEnum.CASH);
}
// 是否需要额外支付(目前只有食堂需要)
private boolean isExtraPrice(HardTypeEnum hardType) {
return ObjectUtil.equals(hardType, HardTypeEnum.CANTEEN);
}
// 二维码类型的订单是否被核销
private boolean validateCodeIsCancel(HardOrderTypeEnum orderType, Long orderSourceTypeId) {
Boolean flag = switch (orderType) {
case RESERVE -> false;
case FOREIGN_TICKET, STRIDE_DEPT -> {
R<Boolean> result = remoteCodeUseService.isCancelCode(orderSourceTypeId);
if (ObjectUtil.isEmpty(result.getData())) yield false;
yield result.getData();
}
default -> false;
};
if (!flag) throw new RuntimeException("该二维码已被核销");
return flag;
}
private boolean validateCreateOrderDto(HardCreateOrderDto dto) {
R<MchManageVo> mch = remoteMchService.getById(dto.getMerchantId());
if (ObjectUtil.isEmpty(mch.getData())) {
throw new RuntimeException("商户不存在");
}
HardManagerEntity hard = hardManagerService.getById(dto.getHardwareId());
if (ObjectUtil.isEmpty(hard)) {
throw new RuntimeException("设备不存在");
}
dto.setDeptId(hard.getDeptId());
return true;
}
/* ************************************* end 支付相关 end ************************************* */
}
@@ -1,7 +1,7 @@
<?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.hard.mapper.order.HardwareOrderMapper">
<mapper namespace="com.bsd.pjcloud.hard.mapper.order.HardOrderMapper">
<resultMap id="hardwareOrderMap" type="com.bsd.pjcloud.hard.api.entity.order.HardwareOrderEntity">
<id property="id" column="id"/>
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import lombok.Data;
@Data
public class WalletSettingDto extends WalletSettingEntity {
}
@@ -0,0 +1,122 @@
package com.bsd.pjcloud.wallet.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 支付设置
*
* @author dzc
* @date 2025-01-06 10:52:31
*/
@Data
@TenantTable
@TableName("wallet_setting")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "支付设置")
public class WalletSettingEntity extends Model<WalletSettingEntity> {
/**
* 创建者
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="创建者")
private Long id;
/**
* 每一餐的上限(分)
*/
@Schema(description="每一餐的上限(分)")
private Integer payAmountMealLimit;
/**
* 每一餐的倍数
*/
@Schema(description="每一餐的倍数")
private BigDecimal payAmountMealTimes;
/**
* 是否开启每一餐的额外缴费
*/
@Schema(description="是否开启每一餐的额外缴费")
private String payAmountEnable;
/**
* 是否开启钱包二维码刷新
*/
@Schema(description="是否开启钱包二维码刷新")
private String refreshQrCodeEnable;
/**
* 二维码刷新频率
*/
@Schema(description="二维码刷新频率")
private Integer refreshQrCodeFre;
/**
* 是否开启离线订单的审批
*/
@Schema(description="是否开启离线订单的审批")
private String offLineOrderApplyEnable;
/**
* 退款理由
*/
@Schema(description="退款理由")
private String afterSaleRefundReasons;
/**
* 退货理由
*/
@Schema(description="退货理由")
private String afterSaleReturnReasons;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
private Long tenantId;
}
@@ -0,0 +1,31 @@
package com.bsd.pjcloud.wallet.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(contextId = "remoteCodeUseService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteCodeUseService {
/**
* 核销二维码
*
* @param id 二维码id
* @return
*/
@NoToken
@GetMapping("/wallet-code-use/cancel-code")
R<Boolean> cancelCode(@RequestParam Long id);
/**
* 二维码是否核销
*
* @param id 二维码id
* @return
*/
@NoToken
@GetMapping("/wallet-code-use/is-cancel-code")
R<Boolean> isCancelCode(@RequestParam Long id);
}
@@ -0,0 +1,20 @@
package com.bsd.pjcloud.wallet.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@FeignClient(contextId = "remoteWalletSettingService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteWalletSettingService {
/**
* 获取支付配置
*
* @return
*/
@NoToken
@GetMapping("/wallet-setting/get-setting")
R<WalletSettingVo> get();
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import lombok.Data;
@Data
public class WalletSettingVo extends WalletSettingEntity {
}
@@ -1,2 +1,4 @@
com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
com.bsd.pjcloud.wallet.api.feign.RemoteMchService
com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService
com.bsd.pjcloud.wallet.api.feign.RemoteMchService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService
@@ -0,0 +1,39 @@
package com.bsd.pjcloud.wallet.controller;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-code-use")
@Tag(description = "wallet-code-use", name = "二维码使用")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletCodeUseController {
private final WalletCodeUseService walletCodeUseService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/cancel-code")
public R<Boolean> cancelCode(@RequestParam Long id) {
return R.ok(walletCodeUseService.cancelCode(id));
}
@Inner
@GetMapping("/is-cancel-code")
public R<Boolean> isCancelCode(@RequestParam Long id) {
return R.ok(walletCodeUseService.isCancelCode(id));
}
/* ************************************* end 远程调用 end ************************************* */
}
@@ -2,9 +2,11 @@ package com.bsd.pjcloud.wallet.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
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.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
@@ -12,7 +14,9 @@ import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.wallet.api.dto.WalletFreezeDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.service.WalletFreezeService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
@@ -42,13 +46,11 @@ public class WalletFreezeController {
private final WalletFreezeService walletFreezeService;
/* ************************************* start flow callback start ************************************* */
@Inner(value = false)
@PostMapping("/apply-callback")
public void applyCallback(@RequestBody ProcessNodeRecordAssignUserParamDto dto) {
walletFreezeService.applyCallback(dto);
}
/* ************************************* start flow callback start ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@@ -0,0 +1,67 @@
package com.bsd.pjcloud.wallet.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
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.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.api.dto.WalletSettingDto;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.service.WalletSettingService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 支付设置
*
* @author dzc
* @date 2025-01-06 10:52:31
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-setting")
@Tag(description = "wallet-setting", name = "支付设置管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletSettingController {
private final WalletSettingService walletSettingService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-setting")
public R<WalletSettingVo> get() {
return R.ok(walletSettingService.getSetting());
}
/* ************************************* start 远程调用 start ************************************* */
@Operation(summary = "获取支付配置", description = "获取支付配置")
@GetMapping("")
public R getSetting() {
return R.ok(walletSettingService.getSetting());
}
@Operation(summary = "更新支付配置", description = "更新支付配置")
@SysLog("更新支付配置")
@PutMapping
public R updateById(@RequestBody WalletSettingDto dto) {
walletSettingService.edit(dto);
return R.ok(true);
}
}
@@ -47,15 +47,12 @@ public class WalletStrideController {
private final WalletStrideService walletStrideService;
private final WalletCodeUseService walletCodeUseService;
/* ************************************* start flow callback start ************************************* */
@Inner(value = false)
@PostMapping("/apply-callback")
public void applyCallback(@RequestBody ProcessNodeRecordAssignUserParamDto dto) {
walletStrideService.applyCallback(dto);
}
/* ************************************* start flow callback start ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.wallet.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WalletSettingMapper extends PjcloudBaseMapper<WalletSettingEntity> {
}
@@ -13,4 +13,18 @@ public interface WalletCodeUseService extends IService<WalletCodeUseEntity> {
void generate(@NotNull Long id, @NotNull Long userId, @NotNull WalletCodeBizEnum walletCodeBizEnum, @NotNull Integer count);
Page<WalletCodeUseVo> pageJoin(Page page, WalletCodeUseDto dto);
/**
* 核销二维码
* @param id useCodeId
* @return
*/
Boolean cancelCode(Long id);
/**
* 二维码是否核销
* @param id useCodeId
* @return
*/
Boolean isCancelCode(Long id);
}
@@ -0,0 +1,13 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.dto.WalletSettingDto;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
public interface WalletSettingService extends IService<WalletSettingEntity> {
WalletSettingVo getSetting();
void edit(WalletSettingDto dto);
}
@@ -9,6 +9,7 @@ import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteFileService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
import com.bsd.pjcloud.common.core.util.R;
@@ -24,6 +25,7 @@ import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +33,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -68,14 +71,14 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
if (insert > 0) {
QRCodeDto dto = QRCodeDto.builder().id(id).itemId(item.getId()).userId(item.getUserId()).orderType(orderType.getType()).payType(payType.getType()).exceedTime(-1L).build();
try {
Pair<String, String> code = HardUtil.generate(dto);
byte[] bytes = QRCodeImageGenerator.generateQrCodeImage(code.getValue(), 1024);
MultipartFile multipartFile = new MockMultipartFile("file", code.getKey() + ".png", "image/png", new ByteArrayInputStream(bytes));
ImmutablePair<String, String> code = HardUtil.generate(dto);
byte[] bytes = QRCodeImageGenerator.generateQrCodeImage(code.getRight(), 1024);
MultipartFile multipartFile = new MockMultipartFile("file", code.getLeft() + ".png", "image/png", new ByteArrayInputStream(bytes));
R upload = remoteFileService.innerUpload(multipartFile, null, null, null);
Map data = (Map) upload.getData();
String url = (String) data.get("url");
// 更新
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().code(url).codeContent(code.getValue()).build();
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().code(url).codeContent(code.getRight()).build();
baseMapper.updateById(updateObj);
} catch (Exception e) {
e.printStackTrace();
@@ -98,4 +101,20 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
}
return list;
}
@Override
public Boolean cancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
if (ObjectUtil.isEmpty(codeUse)) return false;
if (ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode())) return false;
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().id(id).status(YesNoEnum.YES.getCode()).useTime(LocalDateTime.now()).build();
return baseMapper.updateById(updateObj) > 0;
}
@Override
public Boolean isCancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
if (ObjectUtil.isEmpty(codeUse)) return false;
return ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode());
}
}
@@ -18,12 +18,10 @@ import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletFreezeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletForeignEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletStrideEntity;
import com.bsd.pjcloud.wallet.api.entity.*;
import com.bsd.pjcloud.wallet.api.vo.WalletFreezeVo;
import com.bsd.pjcloud.wallet.mapper.WalletFreezeMapper;
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
import com.bsd.pjcloud.wallet.service.WalletFreezeService;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
@@ -34,6 +32,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -58,6 +57,7 @@ public class WalletFreezeServiceImpl extends ServiceImpl<WalletFreezeMapper, Wal
private final FlowUtil flowUtil;
private final WalletManageService walletManageService;
private final WalletCodeUseService walletCodeUseService;
@Override
public Page<WalletFreezeVo> pageJoin(Page page, WalletFreezeDto dto) {
@@ -0,0 +1,45 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.wallet.api.dto.WalletSettingDto;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.mapper.WalletSettingMapper;
import com.bsd.pjcloud.wallet.service.WalletSettingService;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
/**
* 支付设置
*
* @author dzc
* @date 2025-01-06 10:52:31
*/
@Service
public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, WalletSettingEntity> implements WalletSettingService {
@Override
@Cacheable(value = CacheConstants.WALLET_SETTING_DETAIL, unless = "#result == null")
public WalletSettingVo getSetting() {
WalletSettingEntity setting = baseMapper.selectOne(new QueryWrapper<>());
return BeanUtils.toBean(setting, WalletSettingVo.class);
}
@Override
@CachePut(value = CacheConstants.WALLET_SETTING_DETAIL, condition = "dto.getId() != null", unless = "#result == null")
public void edit(WalletSettingDto dto) {
WalletSettingEntity setting = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(setting)) {
throw new RuntimeException("支付配置不存在");
}
WalletSettingEntity updateObj = BeanUtils.toBean(dto, WalletSettingEntity.class);
baseMapper.updateById(updateObj);
}
}
@@ -0,0 +1,22 @@
<?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.wallet.mapper.WalletSettingMapper">
<resultMap id="walletSettingMap" type="com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity">
<id property="id" column="id"/>
<result property="payAmountMealLimit" column="pay_amount_meal_limit"/>
<result property="payAmountMealTimes" column="pay_amount_meal_times"/>
<result property="payAmountEnable" column="pay_amount_enable"/>
<result property="refreshQrCodeEnable" column="refresh_qr_code_enable"/>
<result property="refreshQrCodeFre" column="refresh_qr_code_fre"/>
<result property="offLineOrderApplyEnable" column="off_line_order_apply_enable"/>
<result property="afterSaleRefundReasons" column="after_sale_refund_reasons"/>
<result property="afterSaleReturnReasons" column="after_sale_return_reasons"/>
<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>
</mapper>