Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-10-21 16:53:20 +08:00
commit fbaf8d150d
24 files changed
+438 -61

No files matched your search

@@ -20,9 +20,9 @@ public class SelectCountByScope extends AbstractMethod {
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
SqlMethod sqlMethod = SqlMethod.SELECT_LIST;
SqlMethod sqlMethod = SqlMethod.SELECT_COUNT;
String sql = String.format(sqlMethod.getSql(), this.sqlFirst(), this.sqlSelectColumns(tableInfo, true),
String sql = String.format(sqlMethod.getSql(), this.sqlFirst(), "*",
tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo), this.sqlOrderBy(tableInfo),
this.sqlComment());
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
@@ -20,8 +20,9 @@ public enum HardTypeEnum {
READ_CARD("3", "读卡器"),
DOOR("4", "生鲜柜"),
MERCHANT_QR_CODE("5", "商户二维码扣款牌"),
OTHER("6","其他支付方式(第三方接口对接)"),
OTHER("6", "其他支付方式(第三方接口对接)"),
MERCHANT_ACT("7", "商户活动"),
FARMER("8", "共富商城(助农)"),
;
private final String type;
private final String description;
@@ -19,6 +19,7 @@ public enum HardOrderTypeEnum {
STRIDE_DEPT("4", "跨单位"),
ZY("5", "正元公务餐"),
LB("6", "宁波银行(美好生活)"),
FARMER("7", "共富商城(助农)"),
;
private final String type;
private final String description;
@@ -0,0 +1,36 @@
package com.bsd.pjcloud.hard.api.dto.order.app;
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.wallet.api.constant.WalletTypeEnum;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class HardAppCreateFarmerOrderDto {
@NotNull(message = "购物车id不能为空")
private Long carParentId;
@NotNull(message = "钱包类型id")
private Long walletTypeId;
@NotNull(message = "自提点id不能为空")
private Long pickUpId;
private HardOrderTypeEnum orderType;
private HardPayTypeEnum payType;
private HardTypeEnum hardType;
private Long userId;
}
@@ -35,16 +35,15 @@ public class HardApptController {
private final HardApptService hardApptService;
/* ************************************* start app start ************************************* */
@Operation(summary = "app预约时间列表", description = "app预约时间列表")
@GetMapping("/app/list")
public R<List<HardApptEntity>> appList() {
List<HardApptEntity> list = hardApptService.list(new LambdaQueryWrapper<HardApptEntity>()
.eq(HardApptEntity::getStatus, YesNoEnum.YES.getCode())
.orderByDesc(HardApptEntity::getSort)
);
.eq(HardApptEntity::getStatus, YesNoEnum.YES.getCode())
.orderByDesc(HardApptEntity::getSort)
);
return R.ok(list);
}
@@ -32,6 +32,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardOfflinePayDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderPreferencesDto;
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
@@ -188,6 +189,18 @@ public class HardOrderController {
return R.ok(hardwareOrderService.appCreateSupermarketReserveOrder(dto));
}
@Operation(summary = "创建共富商城预约订单", description = "app创建线上超市预定订单")
@PostMapping("/app/create-farmer-order")
@Idempotent(expireTime = 3, key = "'/app/hard-order/app/create-farmer-order' + #body.getCarParentId() ", info = "正在创建订单中,请勿重复操作")
public R<Long> appCreateFarmerReserveOrder(@RequestBody HardAppCreateFarmerOrderDto body) {
PjcloudUser user = SecurityUtils.getUser();
body.setHardType(HardTypeEnum.FARMER);
body.setUserId(user.getId());
body.setOrderType(HardOrderTypeEnum.FARMER);
body.setPayType(HardPayTypeEnum.WALLET_DEFAULT);
return R.ok(hardwareOrderService.appCreateFarmerReserveOrder(body));
}
@Operation(summary = "app创建订单扫一扫", description = "app创建订单扫一扫")
@PostMapping("/app/create-order-scan-qrcode")
@Idempotent(expireTime = 5, info = "正在创建订单中,请勿重复操作")
@@ -15,6 +15,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
@@ -66,6 +67,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
*/
Long appCreateSupermarketReserveOrder(HardAppCreateOrderDto dto);
/**
* 创建共富商城预约订单
*/
Long appCreateFarmerReserveOrder(HardAppCreateFarmerOrderDto dto);
/**
* 创建app订单
*/
@@ -44,6 +44,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
import com.bsd.pjcloud.hard.api.dto.wechat.WechantReverseDto;
@@ -89,6 +90,7 @@ import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
import jakarta.validation.Valid;
import lombok.Locked;
@@ -135,6 +137,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final AlipayService alipayService;
private final RemoteMchService remoteMchService;
private final RemoteMchPickUpService remoteMchPickUpService;
private final RemoteCodeUseService remoteCodeUseService;
private final RemoteWalletService remoteWalletService;
private final RemoteWalletTransactionService walletTransactionService;
@@ -630,6 +633,77 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return orderObj.getId();
}
/**
* 创建共富商城预约订单
*/
@Override
public Long appCreateFarmerReserveOrder(HardAppCreateFarmerOrderDto dto) {
// 查询用户
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
// 钱包
WalletManageEntity wallet = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), dto.getWalletTypeId()).getData();
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
// 查询父订单
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
if (ObjectUtil.isEmpty(parentCar)) throw new RuntimeException("购物车不存在");
// 查询商户
MchManageVo hardManager = remoteMchService.getById(parentCar.getMerchantId()).getData();
if (ObjectUtil.isEmpty(hardManager)) throw new RuntimeException("商户不存在");
// 查询自提点
MchPickUpVo mchPickUp = remoteMchPickUpService.remoteDetail(dto.getPickUpId()).getData();
if (ObjectUtil.isEmpty(mchPickUp)) throw new RuntimeException("查询自提点不存在");
// 查询父购物车
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("购物车不存在");
Integer balance = wallet.getBalance();
int totalPrice = (int) carList.stream().mapToLong(HardCarEntity::getTotalPrice).sum();
if (balance < totalPrice) {
throw new RuntimeException("钱包余额不足");
}
// 获取商品描述
List<HardCreateCarDto> carListDto = carList.stream().map(v -> {
HardCreateCarDto entity = new HardCreateCarDto();
entity.setParentCarId(dto.getCarParentId());
entity.setProductId(v.getProductId());
entity.setProductWeight(v.getProductWeight());
entity.setProductCount(v.getProductCount());
return entity;
}).toList();
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
String subject = hardCarService.computerCarSubject(hardType, dto.getOrderType(), carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.userId(dto.getUserId())
.userDeptId(userDetail.getSysUser().getDeptId())
.parentCarId(dto.getCarParentId())
.sysType(dto.getHardType().getType())
.orderStatus(HardOrderStatusEnum.CREATE.getType())
.merchantId(parentCar.getMerchantId())
.merchantType(hardManager.getTypes())
.merchantDeptId(hardManager.getDeptId())
.orderType(dto.getOrderType().getType())
.payType(dto.getPayType().getType())
.orderSourceTypeId(mchPickUp.getId())
.totalPrice(totalPrice)
.extraPrice(0)
.payPrice(totalPrice)
.isOfflineOrder(YesNoEnum.NO.getCode())
.productDesc(subject)
.walletId(wallet.getId())
.build();
baseMapper.insert(orderObj);
// 钱包扣款
getSelf().fastReduceBalance(orderObj);
// 创建二维码
getSelf().generateCode(orderObj);
// 发送mq消息
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
// 扣减库存
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
return orderObj.getId();
}
@Override
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
@@ -0,0 +1,19 @@
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.mch.MchPickUpVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(contextId = "remoteMchPickUpService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteMchPickUpService {
@NoToken
@GetMapping("/mch-pick-up/remotedetail")
R<MchPickUpVo> remoteDetail(@RequestParam("id") Long id);
}
@@ -0,0 +1,18 @@
package com.bsd.pjcloud.wallet.api.vo;
import lombok.Data;
@Data
public class WalletTypeCountVo {
/**
* 充值次数
*/
private Long timeTotal;
/**
* 充值次数
*/
private Long priceTotal;
}
@@ -0,0 +1,38 @@
package com.bsd.pjcloud.wallet.api.vo;
import lombok.Data;
@Data
public class WalletTypeTotalVo {
/**
* 总金额
*/
private Long totalPrice;
/**
* 总次数
*/
private Long totalTime;
/**
* 消费钱包总金额
*/
private Long xfTotalPrice;
/**
* 消费钱包总次数
*/
private Long xfTotalTime;
/**
* 饭卡钱包总金额
*/
private Long eatTotalPrice;
/**
* 饭卡钱包总次数
*/
private Long eatTotalTime;
}
@@ -1,5 +1,6 @@
com.bsd.pjcloud.wallet.api.feign.RemoteActCancelService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
com.bsd.pjcloud.wallet.api.feign.RemoteMchPickUpService
com.bsd.pjcloud.wallet.api.feign.RemoteMchRuleJoinService
com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargeService
@@ -15,6 +15,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionSumAndCountDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo;
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
@@ -189,47 +190,112 @@ public class WalletTransactionController {
public void exportCz(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_INCOME);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = walletTransactionMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list);
}
@Operation(summary = "充值统计", description = "充值统计")
@PostMapping("/cz-total")
public R<WalletTypeTotalVo> czTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_INCOME);
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
}
@Operation(summary = "记账扣款导出", description = "记账扣款导出")
@PostMapping("/export-jz")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportJz(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_EXPENSE);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = walletTransactionMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
walletTransactionService.exportByTemplate(response, dto, "file/个人记账扣款明细.xlsx", list);
}
@Operation(summary = "记账扣款统计", description = "记账扣款统计")
@PostMapping("/jz-total")
public R<WalletTypeTotalVo> jzTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
dto.setType(WalletTransactionDto.TYPE_EXPENSE);
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
}
@Operation(summary = "消费导出", description = "消费导出")
@PostMapping("/export-xf")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportXf(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = walletTransactionMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
walletTransactionService.exportByTemplate(response, dto, "file/个人消费明细.xlsx", list);
}
@Operation(summary = "消费统计", description = "消费统计")
@PostMapping("/xf-total")
public R<WalletTypeTotalVo> xfTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
}
@Operation(summary = "退款导出", description = "退款导出")
@PostMapping("/export-tk")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportTk(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = walletTransactionMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
walletTransactionService.exportByTemplate(response, dto, "file/个人退款明细.xlsx", list);
}
@Operation(summary = "退款统计", description = "退款统计")
@PostMapping("/tk-total")
public R<WalletTypeTotalVo> tkTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
}
@Operation(summary = "后台退还各自食堂记录导出", description = "后台退还各自食堂记录导出")
@PostMapping("/export-th")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportTh(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
dto.setIsFindOrder(false);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = walletTransactionMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
walletTransactionService.exportByTemplate(response, dto, "file/退还各自食堂明细.xlsx", list);
}
@Operation(summary = "退还各自食堂统计", description = "退还各自食堂统计")
@PostMapping("/th-total")
public R<WalletTypeTotalVo> thTotal(@RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
dto.setIsFindOrder(false);
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
}
}
@@ -2,15 +2,16 @@ package com.bsd.pjcloud.wallet.controller.mch;
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.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchPickUpStatusEnum;
import com.bsd.pjcloud.wallet.api.dto.mch.MchPickUpDto;
import com.bsd.pjcloud.wallet.api.entity.mch.MchPickUpEntity;
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
import com.bsd.pjcloud.wallet.service.MchPickUpService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
@@ -36,18 +37,28 @@ public class MchPickUpController {
private final MchPickUpService mchPickUpService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/remotedetail")
public R<MchPickUpVo> remoteDetail(@RequestParam("id") Long id) {
return R.ok(mchPickUpService.join(id));
}
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("app/page")
public R appPage(@ParameterObject Page page, @ParameterObject MchPickUpDto dto) {
@GetMapping("/app/page")
public R<Page<MchPickUpVo>> appPage(@ParameterObject Page page, @ParameterObject MchPickUpDto dto) {
dto.setStatus(WalletMchPickUpStatusEnum.COOPERATION_SUCCESS.getCode());
return R.ok(mchPickUpService.scopPageJoin(page, dto, null));
}
@Operation(summary = "查询详情", description = "查询详情")
@GetMapping("app/detail")
public R appDetail(@RequestParam("id") Long id) {
@GetMapping("/app/detail")
public R<MchPickUpVo> appDetail(@RequestParam("id") Long id) {
return R.ok(mchPickUpService.join(id));
}
@@ -12,6 +12,7 @@ import com.alibaba.excel.write.metadata.fill.FillConfig;
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.exception.ServiceException;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
@@ -21,6 +22,7 @@ import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper;
import com.bsd.pjcloud.wallet.service.WalletRechargeImportService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -54,6 +56,7 @@ import java.util.Map;
public class WalletRechargeImportController {
private final WalletRechargeImportService walletRechargeImportService;
private final WalletRechargeImportMapper walletRechargeImportMapper;
@Operation(summary = "恢复", description = "恢复")
@Idempotent(expireTime = 5, info = "正在处理中,请勿重复操作")
@@ -113,7 +116,10 @@ public class WalletRechargeImportController {
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeImport_export')")
public void export(HttpServletResponse response, @RequestBody WalletRechargeImportDto dto) throws IOException {
List<WalletRechargeImportVo> list = walletRechargeImportService.scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = walletRechargeImportMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletRechargeImportVo> list = walletRechargeImportService.scopeList(dto, dataScope);
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/批量充值扣款流水明细.xlsx")).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
@@ -148,10 +148,4 @@ public class WalletRuleTransactionController {
return R.ok(walletRuleTransactionService.removeBatchByIds(CollUtil.toList(ids)));
}
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_export')")
public List<WalletRuleTransactionEntity> export(WalletRuleTransactionEntity walletRuleTransaction, Long[] ids) {
return walletRuleTransactionService.list(Wrappers.lambdaQuery(walletRuleTransaction).in(ArrayUtil.isNotEmpty(ids), WalletRuleTransactionEntity::getId, ids));
}
}
@@ -153,6 +153,10 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
return list;
}
default Long count(WalletManageDto dto, DataScope dataScope) {
return selectCountByScope(commonQuery(dto), dataScope);
}
default List<WalletManageVo> scopeList(WalletManageDto dto, DataScope dataScope) {
List<WalletManageEntity> list = selectListByScope(commonQuery(dto), dataScope);
return BeanUtils.toBean(list, WalletManageVo.class);
@@ -13,6 +13,8 @@ import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo;
import com.bsd.pjcloud.wallet.api.vo.WalletTypeCountVo;
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplySelectCompareVo;
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -26,7 +28,7 @@ import java.util.Objects;
@Mapper
public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransactionEntity> {
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) {
default LambdaQueryWrapper<WalletTransactionEntity> commonWrapperQuery(WalletTransactionDto dto) {
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId())
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType())
@@ -58,47 +60,26 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
wrapper.lt(WalletTransactionEntity::getPrice, 0);
}
Page list = selectPageByScope(page, wrapper, dataScope);
return wrapper;
}
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) {
Page list = selectPageByScope(page, commonWrapperQuery(dto), dataScope);
list.setRecords(BeanUtils.toBean(list.getRecords(), WalletTransactionVo.class));
return list;
}
WalletTypeCountVo walletTypetotal(@Param("dto") WalletTransactionDto dto, @Param("dataScope") DataScope dataScope);
default List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope) {
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId())
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType())
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletTransactionEntity::getUserId, dto.getUserId())
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletTransactionEntity::getDeptId, dto.getDeptId())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletTransactionEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getBizTypes()), WalletTransactionEntity::getBizType, dto.getBizTypes())
.between(
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
WalletTransactionEntity::getCreateTime,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
)
.orderByDesc(WalletTransactionEntity::getCreateTime)
.orderByDesc(WalletTransactionEntity::getUserId);
if (ObjectUtil.isNotEmpty(dto.getIsInclude())) {
if (dto.getIsInclude()) {
wrapper.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId,
dto.getDeptIds());
} else {
wrapper.notIn(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId,
dto.getDeptIds());
}
} else {
wrapper.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId, dto.getDeptIds());
}
if (ObjectUtil.equals(dto.getType(), WalletTransactionDto.TYPE_INCOME)) {
wrapper.gt(WalletTransactionEntity::getPrice, 0);
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
wrapper.lt(WalletTransactionEntity::getPrice, 0);
}
List<WalletTransactionEntity> list = selectListByScope(wrapper, dataScope);
List<WalletTransactionEntity> list = selectListByScope(commonWrapperQuery(dto), dataScope);
return BeanUtils.toBean(list, WalletTransactionVo.class);
}
default Long count(WalletTransactionDto dto, DataScope dataScope) {
return selectCountByScope(commonWrapperQuery(dto), dataScope);
}
Page<WalletTransactionVo> scopeJzPageList(Page page, @Param("dto") WalletTransactionDto dto, DataScope dataScope);
Integer getTransactionPriceCount(@Param("month") String importTimeStr, @Param("walletId") Long walletId,
@@ -21,6 +21,8 @@ public interface WalletRechargeImportMapper extends PjcloudBaseMapper<WalletRech
List<WalletRechargeImportVo> scopeList(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope);
Long count(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope);
default Page<WalletRechargeImportVo> pageJoin(Page page, WalletRechargeImportDto dto) {
MPJLambdaWrapper<WalletRechargeImportEntity> wrapper = new MPJLambdaWrapper<WalletRechargeImportEntity>()
.eqIfExists(WalletRechargeImportEntity::getId, dto.getId())
@@ -6,10 +6,10 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
public interface WalletTransactionService extends IService<WalletTransactionEntity> {
@@ -23,6 +23,8 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope);
WalletTypeTotalVo walletTypetotal(WalletTransactionDto dto, DataScope dataScope);
/**
* 扣减钱包余额
*
@@ -399,7 +399,10 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
@Override
public void export(HttpServletResponse response, Page page, WalletManageDto dto) {
String fileName = "file/账户余额.xlsx";
List<WalletManageVo> list = scopeList(dto, DataScope.of());
DataScope dataScope = DataScope.of();
Long count = baseMapper.count(dto, dataScope);
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
List<WalletManageVo> list = scopeList(dto, dataScope);
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream(fileName)).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
@@ -17,6 +17,7 @@ import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
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.common.data.datascope.DataScope;
@@ -29,6 +30,8 @@ import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.WalletTypeCountVo;
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
@@ -196,6 +199,33 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
return list;
}
@Override
public WalletTypeTotalVo walletTypetotal(WalletTransactionDto dto, DataScope dataScope) {
WalletTypeTotalVo result = new WalletTypeTotalVo();
// 查询钱包类型
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(new WalletTypeDto());
if (ObjectUtil.isEmpty(walletTypeList)) return null;
for (WalletTypeEntity v : walletTypeList) {
WalletTransactionDto queryDto = BeanUtils.toBean(dto, WalletTransactionDto.class);
queryDto.setWalletTypeId(v.getId());
WalletTypeCountVo total = baseMapper.walletTypetotal(queryDto, dataScope);
if (ObjectUtil.isEmpty(total)) continue;
if (ObjectUtil.equals(v.getUniqueCode(), WalletTypeEnum.EAT.getCode())) {
result.setEatTotalPrice(total.getPriceTotal());
result.setEatTotalTime(total.getTimeTotal());
continue;
}
if (ObjectUtil.equals(v.getUniqueCode(), WalletTypeEnum.PAY.getCode())) {
result.setXfTotalPrice(total.getPriceTotal());
result.setXfTotalTime(total.getTimeTotal());
continue;
}
}
result.setTotalPrice(result.getEatTotalPrice() + result.getXfTotalPrice());
result.setTotalTime(result.getEatTotalTime() + result.getXfTotalTime());
return result;
}
@Override
public void exportByTemplate(HttpServletResponse response, WalletTransactionDto dto, String fileName, List<WalletTransactionVo> list) {
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream(fileName)).build()) {
@@ -270,7 +300,11 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
if (dto.getIsFindOrder()) {
list.forEach(v -> {
if (ObjectUtil.isNotEmpty(v.getBizId())) {
v.setOrderId(Long.valueOf(v.getBizId()));
try {
v.setOrderId(Long.valueOf(v.getBizId()));
} catch (Exception e) {
log.error("|{}|订单号转换错误,bizId:|{}|", TAG, v.getBizId());
}
}
});
}
@@ -44,12 +44,46 @@
<if test="dto.bizType != null">
and a.biz_type = #{dto.bizType}
</if>
<if test="dto.deptId != null">
and a.dept_id = #{dto.deptId}
</if>
<if test="dto.type != null and dto.type == 1 ">
and a.price &gt; 0
</if>
<if test="dto.type != null and dto.type == 2 ">
and a.price &lt; 0
</if>
<if test="dto.userIds != null and dto.userIds.size() != 0">
and a.user_id in
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.bizTypes != null and dto.bizTypes.size() != 0">
and a.biz_type in
<foreach collection="dto.bizTypes" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and a.dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and a.dept_id NOT IN
</when>
<otherwise>
and a.dept_id IN
</otherwise>
</choose>
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
</sql>
<select id="scopeJzPageList" resultType="com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo">
@@ -177,4 +211,16 @@
</if>
</where>
</select>
<select id="walletTypetotal" resultType="com.bsd.pjcloud.wallet.api.vo.WalletTypeCountVo">
select ifnull(sum(a.price), 0) as priceTotal, count(0) as timeTotal
FROM wallet_transaction a
left join wallet_manage m on m.id = a.wallet_id
<where>
<include refid="whereA"/>
<if test="dto.walletTypeId != null">
and m.wallet_type_id = #{dto.walletTypeId}
</if>
</where>
</select>
</mapper>
@@ -111,4 +111,26 @@
<select id="scopeList" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo">
<include refid="selectJoin"/>
</select>
<select id="count" resultType="java.lang.Long">
count(0)
from wallet_recharge_import a
inner join wallet_recharge_apply p on p.id = a.apply_id
<where>
<include refid="whereA"/>
and p.process_id is not null
<if test="dto.bizType != null and dto.bizType != ''">
and p.biz_type = #{dto.bizType}
</if>
<if test="dto.processStatus != null and dto.processStatus != ''">
and p.process_status = #{dto.processStatus}
</if>
<if test="dto.walletTypeId != null">
and p.wallet_type_id = #{dto.walletTypeId}
</if>
<if test="dto.processTimeList != null and dto.processTimeList.length == 2">
and p.process_time between #{dto.processTimeList[0]} and #{dto.processTimeList[1]}
</if>
</where>
</select>
</mapper>