This commit is contained in:
zjf committed 2025-03-11 00:03:14 +08:00
commit 641a61db2c
11 files changed
+191 -136

No files matched your search

+18 -18
View File
@@ -7,24 +7,24 @@ create database `pjcloudx_wallet` default character set utf8mb4 collate utf8mb4_
DROP TABLE IF EXISTS `mch_manage`;
CREATE TABLE mch_manage
(
id bigint NOT NULL COMMENT '主键',
dept_id bigint NOT NULL COMMENT '绑定的部门id',
hard_group_id bigint COMMENT '设备分组id',
name varchar(64) NOT NULL COMMENT '商户名',
types varchar(64) NOT NULL COMMENT '店铺类型,逗号分隔',
logo_pic varchar(256) NOT NULL COMMENT '商户logo图片',
collection_code varchar(256) DEFAULT '' COMMENT '商户收款码,自动生成',
swiper_pic text DEFAULT NULL COMMENT '商户轮播图,逗号分隔',
phone varchar(128) DEFAULT '' COMMENT '商户手机号',
job_start_time time DEFAULT NULL COMMENT '商户开始营业时间',
job_end_time time DEFAULT NULL COMMENT '商户结束营业时间',
address_des varchar(256) DEFAULT NULL COMMENT '商户地址',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
id bigint NOT NULL COMMENT '主键',
dept_id bigint NOT NULL COMMENT '绑定的部门id',
default_wallet_type_id bigint DEFAULT NULL COMMENT '商户默认使用的钱包类型',
hard_group_id bigint COMMENT '设备分组id',
name varchar(64) NOT NULL COMMENT '商户名',
types varchar(64) NOT NULL COMMENT '店铺类型,逗号分隔',
logo_pic varchar(256) NOT NULL COMMENT '商户logo图片',
collection_code varchar(256) DEFAULT '' COMMENT '商户收款码,自动生成',
swiper_pic text DEFAULT NULL COMMENT '商户轮播图,逗号分隔',
phone varchar(128) DEFAULT '' COMMENT '商户手机号',
job_time varchar(256) DEFAULT NULL COMMENT '商户营业时间',
address_des varchar(256) DEFAULT NULL COMMENT '商户地址',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
@@ -209,25 +209,24 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Long createOrder(HardCreateOrderDto dto) {
if (!validateCreateOrderDto(dto)) return null;
MchManageVo mch = validateCreateOrderDto(dto);
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("机器绑定的商户不存在");
// 是否需要支付
boolean isPay = isPay(dto.getOrderType(), dto.getOrderPayType());
// 是否需要支付额外金额
boolean isExtraPrice = isExtraPrice(dto.getSysType());
// 饭卡钱包
// 默认使用该商户的钱包如果没有就用饭卡钱包
WalletManageEntity wallet = null;
if (isPay) {
if (ObjectUtil.equals(dto.getOrderPayType(), HardPayTypeEnum.WALLET_QR_CODE)) {
if (ObjectUtil.isEmpty(dto.getWalletId())) throw new RuntimeException("钱包二维码支付错误");
R<WalletManageVo> walletResult = remoteWalletService.getWalletById(dto.getWalletId());
WalletManageVo walletVo = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
if (!ObjectUtil.equals(walletVo.getWalletTypeUniqueCode(), WalletTypeEnum.EAT.getCode())) {
throw new RuntimeException("请使用钱包二维码支付");
}
wallet = walletVo;
} else {
if (ObjectUtil.isNotEmpty(mch.getDefaultWalletTypeId())) {
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
} else {
R<WalletManageEntity> walletResult = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), mch.getDefaultWalletTypeId());
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
}
if (ObjectUtil.isEmpty(wallet)) {
throw new RuntimeException("用户钱包不存在");
}
}
int totalPrice = 0, extraPrice = 0, payPrice = 0;
@@ -523,7 +522,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return ObjectUtil.equals(hardType, HardTypeEnum.CANTEEN);
}
private boolean validateCreateOrderDto(HardCreateOrderDto dto) {
private MchManageVo validateCreateOrderDto(HardCreateOrderDto dto) {
R<MchManageVo> mch = remoteMchService.getById(dto.getMerchantId());
if (ObjectUtil.isEmpty(mch.getData())) {
throw new RuntimeException("商户不存在");
@@ -533,7 +532,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
throw new RuntimeException("设备不存在");
}
dto.setDeptId(hard.getDeptId());
return true;
return mch.getData();
}
// 是否有二维码
@@ -10,8 +10,6 @@ import com.bsd.pjcloud.admin.api.entity.SysUserFaceEntity;
import com.bsd.pjcloud.admin.api.vo.SysUserFaceVo;
import com.bsd.pjcloud.admin.service.SysUserFaceService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
@@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -25,114 +26,113 @@ import java.time.LocalTime;
public class MchManageEntity extends Model<MchManageEntity> {
/**
* 主键
*/
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="主键")
@Schema(description = "主键")
private Long id;
/**
* 绑定的部门id - 商户的部门id
*/
@Schema(description="商户的部门id")
/**
* 绑定的部门id - 商户的部门id
*/
@Schema(description = "商户的部门id")
private Long deptId;
/**
* 商户名
*/
@Schema(description="商户名")
/**
* 默认使用的钱包类型
*/
@Schema(description = "默认使用的钱包类型")
private Long defaultWalletTypeId;
/**
* 商户名
*/
@Schema(description = "商户名")
private String name;
/**
* 店铺类型,逗号分隔
*/
@Schema(description="店铺类型,逗号分隔")
/**
* 店铺类型,逗号分隔
*/
@Schema(description = "店铺类型,逗号分隔")
private String types;
/**
* 商户logo图片
*/
@Schema(description="商户logo图片")
/**
* 商户logo图片
*/
@Schema(description = "商户logo图片")
private String logoPic;
/**
* 商户收款码,自动生成
*/
@Schema(description="商户收款码,自动生成")
/**
* 商户收款码,自动生成
*/
@Schema(description = "商户收款码,自动生成")
private String collectionCode;
/**
* 商户轮播图,逗号分隔
*/
@Schema(description="商户轮播图,逗号分隔")
/**
* 商户轮播图,逗号分隔
*/
@Schema(description = "商户轮播图,逗号分隔")
private String swiperPic;
/**
* 商户手机号
*/
@Schema(description="商户手机号")
/**
* 商户手机号
*/
@Schema(description = "商户手机号")
private String phone;
/**
* 商户开始营业时间
*/
@Schema(description="商户开始营业时间")
@JsonFormat(pattern = DatePattern.NORM_TIME_PATTERN)
private LocalTime jobStartTime;
/**
* 商户营业时间
*/
@Schema(description = "商户营业时间")
private String jobTime;
/**
* 商户结束营业时间
*/
@Schema(description="商户结束营业时间")
@JsonFormat(pattern = DatePattern.NORM_TIME_PATTERN)
private LocalTime jobEndTime;
/**
* 商户地址
*/
@Schema(description="商户地址")
/**
* 商户地址
*/
@Schema(description = "商户地址")
private String addressDes;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -24,6 +24,10 @@ public interface RemoteWalletService {
@GetMapping("/wallet-manage/get-wallet")
R<WalletManageEntity> getWallet(@RequestParam Long userId, @RequestParam WalletTypeEnum walletTypeCode);
@NoToken
@GetMapping("/wallet-manage/get-wallet-by-wallet-id")
R<WalletManageEntity> getWalletByWalletTypeId(@RequestParam Long userId, @RequestParam Long walletTypeId);
@NoToken
@GetMapping("/wallet-manage/get-wallet-by-id")
R<WalletManageVo> getWalletById(@RequestParam Long walletId);
@@ -2,11 +2,21 @@ package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface;
import lombok.Data;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
@Data
public class MchManageVo extends MchManageEntity implements BaseDeptInterface {
public class MchManageVo extends MchManageEntity implements BaseDeptInterface, BaseWalletTypeInterface {
private String deptName;
private Long walletTypeId;
private String walletTypeName;
private String walletTypeUniqueCode;
private String walletTypeIcon;
}
@@ -61,6 +61,16 @@ public class WalletManageController {
return R.ok(wallet);
}
@Inner
@GetMapping("/get-wallet-by-wallet-id")
public R getWalletByWalletTypeId(@RequestParam Long userId, @RequestParam Long walletTypeId) {
WalletManageEntity wallet = walletManageService.getWallet(userId, walletTypeId);
if (ObjectUtil.isEmpty(wallet)) {
return R.failed("用户钱包不存在");
}
return R.ok(wallet);
}
@Inner
@GetMapping("/create-wallet")
public R getWallet(@RequestParam Long userId) {
@@ -15,15 +15,22 @@ import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
import com.bsd.pjcloud.wallet.api.vo.code.MchCollectionCodeVo;
import com.bsd.pjcloud.wallet.mapper.MchManageMapper;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.service.MchManageService;
import com.bsd.pjcloud.wallet.service.WalletThirdZyService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
@@ -58,8 +65,10 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
private final RemoteUserService remoteUserService;
private final RemoteDeptService remoteDeptService;
private final RemoteFileService remoteFileService;
@Lazy
private final WalletThirdZyService walletThirdZyService;
private final WalletTypeMapper walletTypeMapper;
private final StringRedisTemplate redisTemplate;
@@ -155,6 +164,17 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
}
}
// 饭卡类型
List<Long> walletTypeIds = list.getRecords().stream().map(MchManageVo::getDefaultWalletTypeId).distinct().toList();
if (ObjectUtil.isNotEmpty(walletTypeIds)) {
WalletTypeDto walletTypeDto = new WalletTypeDto();
walletTypeDto.setWalletTypeIds(walletTypeIds);
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(walletTypeDto);
if (ObjectUtil.isNotEmpty(walletTypeList)) {
list.getRecords().forEach(v -> v.setWalletTypeId(v.getDefaultWalletTypeId()));
WalletDataUtil.convertWalletTypeList(list.getRecords(), CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId));
}
}
}
return list;
}
@@ -57,7 +57,7 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
Page<WalletRechargeApplyCompareVo> resultVo = new Page<>();
List<WalletRechargeApplyCompareVo> resultList = new ArrayList<>();
// 刚刚倒入的数据
// 刚刚导入的数据
String monthTimeStr = LocalDateTimeUtil.format(topUpApplyDetail.getImportTime(), DatePattern.NORM_MONTH_PATTERN);
WalletRechargeImportDto importDto = new WalletRechargeImportDto();
importDto.setApplyId(dto.getId());
@@ -71,23 +71,25 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
// 本月
List<WalletRechargeApplySelectCompareVo> monthList = walletTransactionMapper.selectCompare(dto.getBizType(), monthTimeStr, userIdList);
List<WalletRechargeApplySelectCompareVo> currentMonthList = new ArrayList<>();
for (WalletRechargeImportVo v : userList) {
WalletRechargeApplySelectCompareVo item = new WalletRechargeApplySelectCompareVo();
item.setUserId(v.getUserId());
List<WalletRechargeApplySelectCompareVo> targetList = monthList.stream().filter(i -> ObjectUtil.equals(i.getUserId(), v.getUserId())).toList();
if (ObjectUtil.isNotEmpty(targetList)) {
WalletRechargeApplySelectCompareVo target = targetList.stream().findFirst().get();
if (ObjectUtil.isNotEmpty(target)) {
item.setPrice(v.getPrice());
Integer beforePrice = ObjectUtil.isEmpty(v.getBeforePrice()) ? 0 : v.getBeforePrice();
item.setTotalPrice(v.getPrice() + beforePrice);
if (ObjectUtil.isNotEmpty(monthList)) {
for (WalletRechargeImportVo v : userList) {
WalletRechargeApplySelectCompareVo item = new WalletRechargeApplySelectCompareVo();
item.setUserId(v.getUserId());
List<WalletRechargeApplySelectCompareVo> targetList = monthList.stream().filter(i -> ObjectUtil.equals(i.getUserId(), v.getUserId())).toList();
if (ObjectUtil.isNotEmpty(targetList)) {
WalletRechargeApplySelectCompareVo target = targetList.stream().findFirst().get();
if (ObjectUtil.isNotEmpty(target)) {
item.setPrice(v.getPrice());
Integer beforePrice = ObjectUtil.isEmpty(v.getBeforePrice()) ? 0 : v.getBeforePrice();
item.setTotalPrice(v.getPrice() + beforePrice);
}
}
if (ObjectUtil.isAllEmpty(item.getPrice(), item.getTotalPrice())) {
item.setPrice(v.getPrice());
item.setTotalPrice(v.getPrice());
}
currentMonthList.add(item);
}
if (ObjectUtil.isAllEmpty(item.getPrice(), item.getTotalPrice())) {
item.setPrice(v.getPrice());
item.setTotalPrice(v.getPrice());
}
currentMonthList.add(item);
}
compareMonthMap.put(monthTimeStr, currentMonthList);
@@ -97,7 +99,9 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
List<WalletRechargeApplySelectCompareVo> selectList = walletTransactionMapper.selectCompare(dto.getBizType(), v, userIdList);
selectList.forEach(j -> {
j.setMonthTimeStr(v);
WalletRechargeImportVo target = userList.stream().filter(i -> ObjectUtil.equals(i.getUserId(), j.getUserId())).findFirst().get();
WalletRechargeImportVo target = userList.stream()
.filter(i -> ObjectUtil.equals(i.getUserId(), j.getUserId()))
.findFirst().get();
if (ObjectUtil.isNotEmpty(target) && ObjectUtil.isNotEmpty(target.getPrice())) {
j.setTotalPrice(j.getPrice() + target.getPrice());
} else {
@@ -176,7 +176,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
throw new RuntimeException("请先编辑导入时间等信息");
}
// 判断之前有没有在审核的
if (isCheckData(detail.getUserId())) throw new RuntimeException("已提交申请,请勿重复提交");
if (isCheckData(detail.getUserId())) throw new RuntimeException("最多提交3个申请,请勿重复提交");
// 查询用户
UserInfo user = userService.getByUserId(detail.getUserId()).getData();
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("发起人不存在");
@@ -202,7 +202,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
updateObj.setProcessId(processId);
updateObj.setProcessStatus(TaskCheckStatusEnum.PADDING.getCode());
baseMapper.updateById(updateObj);
// 更新之间的总金额
// 更新之前的总金额
getSelf().updateBeforePrice(detail);
}
@@ -223,6 +223,8 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
list = list.stream().filter(v -> !ObjectUtil.isAllEmpty(v.getUsername(), v.getUserMobile(), v.getPrice())).toList();
if (ObjectUtil.isEmpty(list)) return R.failed();
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
List<String> usernameList = list.stream().map(WalletRechargeExcelDto::getUsername).toList();
List<String> userPoneList = list.stream().map(WalletRechargeExcelDto::getUserMobile).toList();
for (WalletRechargeExcelDto v : list) {
Set<String> errors = new LinkedHashSet<>();
if (ObjectUtil.isEmpty(v.getPrice())) {
@@ -255,6 +257,15 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
}
}
}
long userNameCount = usernameList.stream().filter(i -> ObjectUtil.equals(i, v.getUsername())).count();
if (userNameCount > 1) {
errors.add("用户名 <" + v.getUsername() + "> 重复");
}
long userPhone = userPoneList.stream().filter(i -> ObjectUtil.equals(i, v.getUserMobile())).count();
if (userPhone > 1) {
errors.add("用手机号 <" + v.getUserMobile() + "> 重复");
}
if (ObjectUtil.isNotEmpty(errors)) {
errorMessageList.add(new ErrorMessage(v.getLineNum(), errors));
}
@@ -421,7 +432,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
.eq(WalletRechargeApplyEntity::getUserId, walletId)
.eq(WalletRechargeApplyEntity::getProcessStatus, NodeStatusEnum.JXZ.getCode())
);
return count > 0;
return count >= 3;
}
private WalletRechargeApplyServiceImpl getSelf() {
@@ -2,18 +2,17 @@
<!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.MchManageMapper">
<resultMap id="mchManageMap" type="com.bsd.pjcloud.wallet.api.entity.MchManageEntity">
<resultMap id="mchManageMap" type="com.bsd.pjcloud.wallet.api.entity.MchManageEntity">
<id property="id" column="id"/>
<result property="deptId" column="dept_id"/>
<result property="defaultWalletTypeId" column="default_wallet_type_id"/>
<result property="name" column="name"/>
<result property="types" column="types"/>
<result property="logoPic" column="logo_pic"/>
<result property="collectionCode" column="collection_code"/>
<result property="swiperPic" column="swiper_pic"/>
<result property="phone" column="phone"/>
<result property="jobStartTime" column="job_start_time"/>
<result property="jobEndTime" column="job_end_time"/>
<result property="jobTime" column="job_time"/>
<result property="addressDes" column="address_des"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
@@ -21,5 +20,5 @@
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</resultMap>
</mapper>