feat:钱包权限

This commit is contained in:
dzc committed 2026-04-30 23:47:56 +08:00
1 parent 2bb1d8ad7f
commit ff3a3258a6
16 files changed
+115 -34

No files matched your search

+1 -1
View File
@@ -172,4 +172,4 @@ CREATE TABLE `third_pay_order`
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci
ROW_FORMAT = DYNAMIC COMMENT ='第三方支付订单';
ROW_FORMAT = DYNAMIC COMMENT ='第三方支付订单';
+28
View File
@@ -150,6 +150,34 @@ CREATE TABLE mch_manage
CREATE INDEX idx_dept_id ON mch_manage (dept_id);
-- ----------------------------
-- Table structure for mch_pay_setting
-- ----------------------------
DROP TABLE IF EXISTS `mch_pay_setting`;
CREATE TABLE mch_pay_setting
(
id bigint NOT NULL COMMENT '主键',
mch_id bigint NOT NULL COMMENT '商户id',
platform_type varchar(32) NOT NULL COMMENT '平台类型',
enable varchar(32) NOT NULL COMMENT '是否启用',
use_scope varchar(256) NOT NULL COMMENT '使用范围(直接支付,钱包充值)',
setting_json text DEFAULT NULL COMMENT '支付json配置',
fz_ratio int NOT NULL COMMENT '分账比例(最高100%即分给对方商户的%)',
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
COLLATE = utf8mb4_general_ci COMMENT ='商户管理';
CREATE INDEX idx_dept_id ON mch_manage (dept_id);
-- ----------------------------
-- Table structure for mch_take_out_setting
-- ----------------------------
@@ -20,9 +20,9 @@ public class SelectCountByScope extends AbstractMethod {
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
SqlMethod sqlMethod = SqlMethod.SELECT_COUNT;
SqlMethod sqlMethod = SqlMethod.SELECT_LIST;
String sql = String.format(sqlMethod.getSql(), this.sqlFirst(), "*",
String sql = String.format(sqlMethod.getSql(), this.sqlFirst(), this.sqlSelectColumns(tableInfo, true),
tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo), this.sqlOrderBy(tableInfo),
this.sqlComment());
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
@@ -74,6 +74,8 @@ public class ThirdAppPlusWechatServiceImpl implements ThirdAppPlusWechatService
params.put("appid", wechatConfig.getAppId());
// 商户号
params.put("mch_id", wechatConfig.getMerchantId());
// 设备号
params.put("device_info", "WEB");
// 随机字符串
params.put("nonce_str", getNonceStr());
// 签名
@@ -91,7 +93,7 @@ public class ThirdAppPlusWechatServiceImpl implements ThirdAppPlusWechatService
// 终端IP
params.put("spbill_create_ip", wechatConfig.getSpbillCreateIp());
// 交易类型
params.put("trade_type", "JSAPI");
params.put("trade_type", "APP");
// 用户标识
params.put("openid", dto.getOpenid());
// 生成签名
@@ -15,7 +15,7 @@ import javax.net.ssl.SSLSocketFactory;
*/
public class ThirdAppPlusWechantPayConstant {
public static final Api WECHAT_PAY = Api.builder().summary("微信小程序支付").url("/pay/unifiedorder").method(HttpMethod.POST).isNeedCertificate(false).build();
public static final Api WECHAT_PAY = Api.builder().summary("微信统一下单").url("/pay/unifiedorder").method(HttpMethod.POST).isNeedCertificate(false).build();
public static final Api APY = Api.builder().summary("付款码支付").url("/pay/micropay").method(HttpMethod.POST).isNeedCertificate(false).build();
@@ -109,11 +109,11 @@ ad:
app-plus:
pay:
wechat-config:
app-id: wx11771c7bf2913cb2
app-id: wx9f2c53067b4520a4
app-secret: a6b0d036b229117595687a7c1705d332
merchant-id: 1106210589
api-v2-key: qr0w9WkAu6GG3uuxPjDT7bcdIVoBr0rw
merchant-serial-path: /Users/dengzhangchen/Desktop/backups/pay/third_cert/apiclient_cert.p12
merchant-id: 1744678188
api-v2-key: xJNdavRG55ynCEAp6J5uGzxPWSFSGUWE
merchant-serial-path: /Users/dengzhangchen/Desktop/backups/pay/zax_wx_v2/apiclient_cert.p12
pay-callback-url: https://dzc-test-1.fy.takin.cc/third/third-app-pay/app/pay-callback
refund-callback-url: https://dzc-test-1.fy.takin.cc/third/third-app-pay/app/refund-callback
spbill-create-ip: 59.202.170.152
@@ -20,4 +20,6 @@ public class WalletManageBalanceDto implements BaseIsIncludeTreeInterface {
private List<Long> deptIds;
private List<Long> scopeDeptIds;
}
@@ -53,6 +53,8 @@ public class WalletTransactionDto extends WalletTransactionEntity implements Bas
*/
private List<Long> deptIds;
private List<Long> scopeDeptIds;
/**
* 是否包含部门ids
*/
@@ -14,6 +14,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 支付设置
*
@@ -45,6 +47,7 @@ public class WalletSettingController {
/* ************************************* end app end ************************************* */
/* ************************************* start android start ************************************* */
@GetMapping("/ad/get-setting")
public R<WalletSettingVo> androidGet() {
return R.ok(walletSettingService.getSetting());
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
@@ -127,7 +128,7 @@ public class WalletTransactionController {
if (ObjectUtil.isNotEmpty(dto.getPriceList())) {
dto.setPriceList(dto.getPriceList().stream().map(item -> item * 100).toList());
}
walletTransactionService.exportCzTotal(response, dto, null);
walletTransactionService.exportCzTotal(response, dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
}
@Operation(summary = "后台充值统计按照个人(导出)", description = "后台充值统计按照个人(导出)")
@@ -141,7 +142,7 @@ public class WalletTransactionController {
if (ObjectUtil.isNotEmpty(dto.getPriceList())) {
dto.setPriceList(dto.getPriceList().stream().map(item -> item * 100).toList());
}
walletTransactionService.exportCzTotalPerson(response, dto, null);
walletTransactionService.exportCzTotalPerson(response, dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
}
@Operation(summary = "后台充值统计", description = "后台充值统计")
@@ -250,11 +251,10 @@ public class WalletTransactionController {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_INCOME);
DataScope dataScope = null;
Long count = walletTransactionMapper.count(dto, dataScope);
Long count = walletTransactionMapper.count(dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list);
}
@@ -263,8 +263,7 @@ public class WalletTransactionController {
public R<WalletTypeTotalVo> czTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_INCOME);
DataScope dataScope = null;
return R.ok(walletTransactionService.walletTypetotal(dto, dataScope));
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
}
@Operation(summary = "记账扣款导出", description = "记账扣款导出")
@@ -274,11 +273,10 @@ public class WalletTransactionController {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_EXPENSE);
DataScope dataScope = null;
Long count = walletTransactionMapper.count(dto, dataScope);
Long count = walletTransactionMapper.count(dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人记账扣款明细.xlsx", list);
}
@@ -287,7 +285,7 @@ public class WalletTransactionController {
public R<WalletTypeTotalVo> jzTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_EXPENSE);
DataScope dataScope = null;
DataScope dataScope = DataScope.of().func(DataScopeFuncEnum.COUNT);
return R.ok(walletTransactionService.walletTypetotal(dto, dataScope));
}
@@ -298,11 +296,10 @@ public class WalletTransactionController {
public void exportXf(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
DataScope dataScope = null;
Long count = walletTransactionMapper.count(dto, dataScope);
Long count = walletTransactionMapper.count(dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人消费明细.xlsx", list);
}
@@ -310,7 +307,7 @@ public class WalletTransactionController {
@PostMapping("/xf-total")
public R<WalletTypeTotalVo> xfTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
DataScope dataScope = null;
DataScope dataScope = DataScope.of().func(DataScopeFuncEnum.COUNT);
return R.ok(walletTransactionService.walletTypetotal(dto, dataScope));
}
@@ -321,11 +318,10 @@ public class WalletTransactionController {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
DataScope dataScope = null;
Long count = walletTransactionMapper.count(dto, dataScope);
Long count = walletTransactionMapper.count(dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人退款明细.xlsx", list);
}
@@ -334,7 +330,7 @@ public class WalletTransactionController {
public R<WalletTypeTotalVo> tkTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
DataScope dataScope = null;
DataScope dataScope = DataScope.of().func(DataScopeFuncEnum.COUNT);
return R.ok(walletTransactionService.walletTypetotal(dto, dataScope));
}
@@ -345,11 +341,10 @@ public class WalletTransactionController {
dto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
dto.setIsFindOrder(false);
DataScope dataScope = null;
Long count = walletTransactionMapper.count(dto, dataScope);
Long count = walletTransactionMapper.count(dto, DataScope.of().func(DataScopeFuncEnum.COUNT));
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/退还各自食堂明细.xlsx", list);
}
@@ -358,7 +353,7 @@ public class WalletTransactionController {
public R<WalletTypeTotalVo> thTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
dto.setIsFindOrder(false);
DataScope dataScope = null;
DataScope dataScope = DataScope.of().func(DataScopeFuncEnum.COUNT);
return R.ok(walletTransactionService.walletTypetotal(dto, dataScope));
}
@@ -83,6 +83,8 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
return selectCountByScope(commonWrapperQuery(dto), dataScope);
}
// Long count(WalletTransactionDto dto, DataScope dataScope);
Page<WalletTransactionVo> scopeJzPageList(Page page, @Param("dto") WalletTransactionDto dto, DataScope dataScope);
Integer getTransactionPriceCount(@Param("month") String importTimeStr, @Param("walletId") Long walletId,
@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteDataScopeService;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
@@ -29,6 +30,7 @@ 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.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudDefaultDataScopeHandle;
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.common.data.tenant.TenantContextHolder;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
@@ -79,6 +81,8 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
static private final String TAG = "钱包管理";
private final RemoteDataScopeService dataScopeService;
private final WalletTypeMapper walletTypeMapper;
private final WalletTypeService walletTypeService;
@@ -314,6 +318,12 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
@Override
public WalletQbTotalVo qbTotal(WalletManageBalanceDto dto, DataScope dataScope) {
new PjcloudDefaultDataScopeHandle(dataScopeService).calcScope(dataScope);
if (ObjectUtil.isNotEmpty(dataScope.getDeptList())) {
dto.setScopeDeptIds(dataScope.getDeptList());
}
WalletQbTotalVo result = new WalletQbTotalVo();
// 查询钱包类表
List<WalletTypeEntity> walletTypeList = walletTypeService.list();
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteDataScopeService;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
@@ -22,6 +23,7 @@ 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.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudDefaultDataScopeHandle;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
@@ -76,6 +78,8 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
static private final String TAG = "会员钱包流水";
private final RemoteDataScopeService dataScopeService;
private final WalletManageService walletManageService;
private final WalletThirdZyService walletThirdZyService;
@@ -292,7 +296,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
// 查询部门的充值情况
WalletTransactionDto totalQuery = BeanUtils.toBean(dto, WalletTransactionDto.class);
totalQuery.setTotalDpetIds(resultList.stream().map(WalletCzTotalVo::getDeptId).toList());
List<WalletTypeCountVo> deptTotalList = baseMapper.walletTypetotalByDept(totalQuery, null);
List<WalletTypeCountVo> deptTotalList = baseMapper.walletTypetotalByDept(totalQuery, dataScope);
for (WalletCzTotalVo item : resultList) {
Long deptId = item.getDeptId();
@@ -326,6 +330,11 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
@Override
public WalletTypeTotalVo walletTypetotal(WalletTransactionDto dto, DataScope dataScope) {
new PjcloudDefaultDataScopeHandle(dataScopeService).calcScope(dataScope);
if (ObjectUtil.isNotEmpty(dataScope.getDeptList())) {
dto.setScopeDeptIds(dataScope.getDeptList());
}
WalletTypeTotalVo result = new WalletTypeTotalVo();
// 查询钱包类型
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(new WalletTypeDto());
@@ -333,7 +342,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
for (WalletTypeEntity v : walletTypeList) {
WalletTransactionDto queryDto = BeanUtils.toBean(dto, WalletTransactionDto.class);
queryDto.setWalletTypeId(v.getId());
WalletTypeCountVo total = baseMapper.walletTypetotal(queryDto, dataScope);
WalletTypeCountVo total = baseMapper.walletTypetotal(queryDto, null);
if (ObjectUtil.isEmpty(total)) continue;
if (ObjectUtil.equals(v.getUniqueCode(), WalletTypeEnum.EAT.getCode())) {
result.setEatTotalPrice(total.getPriceTotal());
@@ -208,6 +208,12 @@
<where>
a.del_flag = '0'
AND DATE_FORMAT(a.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}
<if test="dto.scopeDeptIds != null and dto.scopeDeptIds.size() != 0">
and m.dept_id IN
<foreach collection="dto.scopeDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.userId != null">
AND a.user_id = #{dto.userId}
</if>
@@ -83,6 +83,12 @@
#{v}
</foreach>
</if>
<if test="dto.scopeDeptIds != null and dto.scopeDeptIds.size() != 0">
and a.dept_id IN
<foreach collection="dto.scopeDeptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
@@ -282,4 +288,19 @@
and t.dept_id not in (1875013738914156546, 1910218102049226753, 1910218128624336898, 1942046316044144642)
order by v.mchId, v.deptId
</select>
<select id="count" resultType="java.lang.Long">
select count(*) as total from (
<include refid="selectA"/>
1
from wallet_transaction a
<where>
<include refid="whereA"/>
<if test="dto.walletTypeId != null">
and m.wallet_type_id = #{dto.walletTypeId}
</if>
order by create_time desc, user_id desc
</where>
)
</select>
</mapper>
@@ -67,6 +67,7 @@
<include refid="selectA"/>
t.user_id,
t.dept_id as userDeptId,
t.dept_id,
sourceWalletType.name as sourceWalletTypeName,
sourceWalletType.unique_code as sourceWalletTypeCode,
targetWalletType.name as targetWalletTypeName,