feat:正元余额不足

This commit is contained in:
dzc committed 2025-03-26 18:40:14 +08:00
1 parent 8aa9265874
commit 182dacc855
13 files changed
+134 -100

No files matched your search

+1 -1
View File
@@ -95,7 +95,7 @@ CREATE TABLE wallet_rule_price_config
id bigint NOT NULL COMMENT '主键',
rule_price_type varchar(64) NOT NULL COMMENT '规则类型',
base_price bigint NOT NULL COMMENT '基础金额',
multiple bigint NOT NULL COMMENT '金额的倍数必须大于1',
multiple bigint NOT 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 '修改人',
@@ -7,8 +7,8 @@ import lombok.RequiredArgsConstructor;
@Getter
public enum MerchantTypeEnum {
CANTEEN("1", "食堂"),
SUPERMARKET("3", "合作超市"),
SELF_SUPERMARKET("2", "自营超市"),
SUPERMARKET("3", "合作超市"),
;
/**
@@ -1,7 +1,6 @@
package com.bsd.pjcloud.hard.api.dto.hard;
import cn.hutool.core.util.ObjectUtil;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
import lombok.Data;
import java.util.ArrayList;
@@ -29,10 +28,11 @@ public class CurrentUserHardTypeInfoDto {
List<String> list = new ArrayList<>();
if (isAll()) return list;
if (this.getCanteenView() != null && this.getCanteenView()) {
list.add(HardTypeEnum.CANTEEN.getType());
list.add(MerchantTypeEnum.CANTEEN.getType());
}
if (this.getSupermarket() != null && this.getSupermarket()) {
list.add(HardTypeEnum.SUPERMARKET.getType());
list.add(MerchantTypeEnum.SELF_SUPERMARKET.getType());
list.add(MerchantTypeEnum.CANTEEN.getType());
}
return list;
}
@@ -23,12 +23,12 @@ public class HardOrderDto extends HardOrderEntity implements BaseIsIncludeTreeIn
private List<Long> hardIds;
private List<String> hardTypeCodes;
private String hardTypeCode;
private List<Long> mchIds;
private List<String> mchTypeCodes;
private List<String> orderStatusCodes;
private LocalDate[] createTimeList;
@@ -56,6 +56,13 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
@Schema(description = "商户id")
private Long merchantId;
/**
* 商户类型
*/
@Schema(description = "商户类型")
private String merchantType;
/**
* 设备id
*/
@@ -40,6 +40,8 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B
private String hardType;
private List<String> hardTypeCodes;
/**
* 购物车
*/
@@ -155,7 +155,7 @@ public class HardOrderController {
dataScope.setScopeDeptName("user_dept_id");
PjcloudUser user = SecurityUtils.getUser();
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
dto.setHardTypeCodes(hardTypeInfo.getHardTypeList());
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
return R.ok(hardwareOrderService.scopePageList(page, dto, dataScope));
}
@@ -264,6 +264,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
.hardId(dto.getHardwareId())
.orderStatus(HardOrderStatusEnum.CREATE.getType())
.merchantId(dto.getMerchantId())
.merchantType(mch.getTypes())
.deptId(dto.getDeptId())
.orderType(dto.getOrderType().getType())
.payType(dto.getOrderPayType().getType())
@@ -298,6 +299,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
// 查询父订单
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
if (ObjectUtil.isEmpty(parentCar)) throw new RuntimeException("购物车不存在");
// 查询商户
MchManageVo hardManager = remoteMchService.getById(dto.getMerchantId()).getData();
if (ObjectUtil.isEmpty(hardManager)) throw new RuntimeException("商户不存在");
// 查询父购物车
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("购物车不存在");
@@ -327,6 +331,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
.sysType(dto.getHardType().getType())
.orderStatus(HardOrderStatusEnum.CREATE.getType())
.merchantId(parentCar.getMerchantId())
.merchantType(hardManager.getTypes())
.orderType(dto.getOrderType().getType())
.payType(dto.getPayType().getType())
.orderSourceTypeId(dto.getOrderSourceTypeId())
@@ -352,9 +357,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
@Transactional(rollbackFor = Exception.class)
public Long appCreateOrderScancode(HardAppCreateOrderDto dto) {
MchManageVo mch = remoteMchService.getById(dto.getMerchantId()).getData();
if (ObjectUtil.isEmpty(mch)) {
throw new RuntimeException("商户不存在");
}
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("商户不存在");
// 查询用户
UserInfo userDetail = userService.getByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
@@ -372,6 +375,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
.userId(dto.getUserId())
.userDeptId(userDetail.getSysUser().getDeptId())
.merchantId(mch.getId())
.merchantType(mch.getTypes())
.parentCarId(dto.getCarParentId())
.sysType(dto.getHardType().getType())
.orderStatus(HardOrderStatusEnum.CREATE.getType())
@@ -70,7 +70,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
PjcloudUser user = SecurityUtils.getUser();
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
dto.setHardTypeCodes(hardTypeInfo.getHardTypeList());
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
// 查询总流水
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
@@ -132,7 +132,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
dataScope.setScopeDeptName("user_dept_id");
PjcloudUser user = SecurityUtils.getUser();
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
dto.setHardTypeCodes(hardTypeInfo.getHardTypeList());
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
// 查询总流水
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
@@ -427,7 +427,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
dataScope.setScopeDeptName("user_dept_id");
PjcloudUser user = SecurityUtils.getUser();
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
dto.setHardTypeCodes(hardTypeInfo.getHardTypeList());
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
// 查询总流水
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
@@ -8,6 +8,7 @@
<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="hardId" column="hard_id"/>
<result property="deptId" column="dept_id"/>
<result property="walletId" column="wallet_id"/>
@@ -45,6 +46,7 @@
a.user_id,
a.user_dept_id,
a.merchant_id,
a.merchant_type,
a.hard_id,
a.dept_id,
a.wallet_id,
@@ -78,6 +80,9 @@
<sql id="whereA">
a.del_flag = '0'
<if test="dto.merchantType != null and dto.merchantType != '' ">
and a.merchant_type = #{dto.merchantType}
</if>
<if test="dto.hourType != null and dto.hourType != '' ">
and a.hour_type = #{dto.hourType}
</if>
@@ -174,6 +179,12 @@
#{v}
</foreach>
</if>
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
and a.merchant_type in
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
</where>
order by a.create_time desc, a.user_id desc
</select>
@@ -137,32 +137,37 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
refundDto.setSerialNum(dto.getSerialNum());
HardCallbackRefundVo refundRes = hardCallback.refund(refundDto).getData();
result.setCode(refundRes.getCode().getType());
result.setCode(refundRes.getCode().getDescription());
ZySelfPayVo zySelfPayVo = new ZySelfPayVo();
// 人员编号
ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getBySelfId(ThirdZyBizEnumType.SYNC_ACCOUNT_INFO, String.valueOf(refundRes.getUserId()));
String userZyId = userIdDict.getZyId();
zySelfPayVo.setAccNum(userZyId);
zySelfPayVo.setAccName(refundRes.getUsername());
zySelfPayVo.setPerCode(userZyId);
zySelfPayVo.setSerialNum(refundRes.getOrderNo());
zySelfPayVo.setRecDate(LocalDateTimeUtil.format(refundRes.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN));
switch (refundRes.getCode()) {
case SUCCESS -> {
ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getBySelfId(ThirdZyBizEnumType.SYNC_ACCOUNT_INFO, String.valueOf(refundRes.getUserId()));
String userZyId = userIdDict.getZyId();
ZySelfPayVo success = new ZySelfPayVo();
success.setAccNum(userZyId);
success.setAccName(refundRes.getUsername());
success.setPerCode(userZyId);
success.setPlatformSerialNum(String.valueOf(refundRes.getRefundId()));
success.setSerialNum(refundRes.getOrderNo());
success.setRecDate(LocalDateTimeUtil.format(refundRes.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN));
success.setAmount(dto.getAmount());
result.setMsg(ZyBaseVo.selfSuccessMsg);
Map<String, Object> resMap = BeanUtil.beanToMap(result);
Map<String, Object> dataMap = BeanUtil.beanToMap(success);
dataMap.put("sign", zyApiTool.generateSign(dataMap, false));
resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap)));
entity.setOrgRes(JSONUtil.toJsonStr(success));
entity.setEncipherRes(JSONUtil.toJsonStr(resMap));
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
thirdZyLogService.save(entity);
return resMap;
}
default -> throw new RuntimeException();
default -> {
zySelfPayVo.setPlatformSerialNum("temporary_" + dto.getSerialNum());
}
}
Map<String, Object> resMap = BeanUtil.beanToMap(result);
Map<String, Object> dataMap = BeanUtil.beanToMap(zySelfPayVo);
dataMap.put("sign", zyApiTool.generateSign(dataMap, false));
resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap)));
entity.setOrgRes(JSONUtil.toJsonStr(zySelfPayVo));
entity.setEncipherRes(JSONUtil.toJsonStr(resMap));
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
thirdZyLogService.save(entity);
return resMap;
} catch (Exception e) {
String error = String.format("|%s||correct|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
log.error(error);
@@ -229,30 +234,32 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
payDto.setOrderNo(dto.getSerialNum());
HardCallbackPayVo payRes = hardCallback.pay(payDto).getData();
result.setCode(payRes.getCode().getType());
result.setMsg(payRes.getCode().getDescription());
ZySelfPayVo zySelfPayVo = new ZySelfPayVo();
zySelfPayVo.setSerialNum(dto.getSerialNum());
zySelfPayVo.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN));
switch (payRes.getCode()) {
case SUCCESS -> {
ZySelfPayVo success = new ZySelfPayVo();
success.setAccNum(payRes.getUserId().toString());
success.setAccName(payRes.getUsername());
success.setPerCode(payRes.getUserId().toString());
success.setPlatformSerialNum(payRes.getOrderId().toString());
success.setSerialNum(dto.getSerialNum());
success.setAmount(amount);
success.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN));
result.setMsg(ZyBaseVo.selfSuccessMsg);
Map<String, Object> resMap = BeanUtil.beanToMap(result);
Map<String, Object> dataMap = BeanUtil.beanToMap(success);
dataMap.put("sign", zyApiTool.generateSign(dataMap, false));
resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap)));
entity.setOrgRes(JSONUtil.toJsonStr(success));
entity.setEncipherRes(JSONUtil.toJsonStr(resMap));
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
thirdZyLogService.save(entity);
return resMap;
zySelfPayVo.setAccNum(payRes.getUserId().toString());
zySelfPayVo.setAccName(payRes.getUsername());
zySelfPayVo.setPerCode(payRes.getUserId().toString());
zySelfPayVo.setPlatformSerialNum(payRes.getOrderId().toString());
zySelfPayVo.setAmount(amount);
}
default -> {
zySelfPayVo.setPlatformSerialNum("temporary_" + dto.getSerialNum());
}
default -> throw new RuntimeException();
}
Map<String, Object> resMap = BeanUtil.beanToMap(result);
Map<String, Object> dataMap = BeanUtil.beanToMap(zySelfPayVo);
dataMap.put("sign", zyApiTool.generateSign(dataMap, false));
resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap)));
entity.setOrgRes(JSONUtil.toJsonStr(zySelfPayVo));
entity.setEncipherRes(JSONUtil.toJsonStr(resMap));
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
thirdZyLogService.save(entity);
return resMap;
} catch (Exception e) {
String error = String.format("|%s||pay|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
log.error(error);
@@ -6,6 +6,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;
/**
@@ -22,69 +23,70 @@ import java.time.LocalDateTime;
public class WalletRuleMchConfigEntity extends Model<WalletRuleMchConfigEntity> {
/**
* 主键
*/
@Schema(description="主键")
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private Long id;
/**
* 源商户id
*/
@Schema(description="源商户id")
/**
* 源商户id
*/
@Schema(description = "源商户id")
private Long sourceMchId;
/**
* 目标商户id
*/
@Schema(description="目标商户id")
/**
* 目标商户id
*/
@Schema(description = "目标商户id")
private Long tragetMchId;
/**
* 规则配置id
*/
@Schema(description="规则配置id")
/**
* 规则配置id
*/
@Schema(description = "规则配置id")
private Long rulePriceConfigId;
/**
* 创建人
*/
@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;
}
@@ -21,6 +21,7 @@ public class WalletRulePriceConfigEntity extends Model<WalletRulePriceConfigEnti
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private Long id;
@@ -37,9 +38,9 @@ public class WalletRulePriceConfigEntity extends Model<WalletRulePriceConfigEnti
private Long basePrice;
/**
* 金额的倍数必须大于1
* 额外需要支付的倍数
*/
@Schema(description = "金额的倍数必须大于1")
@Schema(description = "额外支付的倍数")
private Long multiple;
/**