Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a6e1aa9a36
42 files changed
+771
-91
No files matched your search
+6
@@ -30,6 +30,12 @@ public enum HardOrderStatusEnum {
|
||||
);
|
||||
}
|
||||
|
||||
public static List<String> getPayErrorCodes() {
|
||||
return List.of(
|
||||
HardOrderStatusEnum.REFUND.type
|
||||
);
|
||||
}
|
||||
|
||||
public static HardOrderStatusEnum valueOfByType(Integer type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardAdminRefundDto {
|
||||
|
||||
@Schema(description = "订单id不能为空")
|
||||
@NotNull(message = "订单id不能为空")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "售后方式")
|
||||
@NotNull(message = "售后方式不能为空")
|
||||
private String way;
|
||||
|
||||
@Schema(description = "退款原因")
|
||||
@NotNull(message = "退款原因不能为空")
|
||||
private String applyReason;
|
||||
|
||||
@Schema(description = "相关描述")
|
||||
private String applyDescription;
|
||||
|
||||
@Schema(description="补充凭证图片")
|
||||
private String applyPicUrls;
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class HardDeptTotalDto {
|
||||
|
||||
@Schema(description = "饭卡类型id")
|
||||
private Long walletTypeId;
|
||||
|
||||
@Schema(description = "饭卡类型id")
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardOrderSumAndCountDto {
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private List<String> orderStatusCodes;
|
||||
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
private Long walletTypeId;
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardDeptTotalVo {
|
||||
|
||||
@Schema(description = "部门id")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "充值金额")
|
||||
private Long walletPrice = 0L;
|
||||
|
||||
@Schema(description = "充值次数")
|
||||
private Long walletCount = 0L;
|
||||
|
||||
@Schema(description = "消费金额")
|
||||
private Long orderPayPrice = 0L;
|
||||
|
||||
@Schema(description = "消费次数")
|
||||
private Long orderPayCount = 0L;
|
||||
|
||||
@Schema(description = "退款金额")
|
||||
private Long orderRefundPrice = 0L;
|
||||
|
||||
@Schema(description = "退款次数")
|
||||
private Long orderRefundCont = 0L;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardOrderSumAndCountVo {
|
||||
|
||||
@Schema(description = "部门id")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门操作金额")
|
||||
private Long sum;
|
||||
|
||||
@Schema(description = "部门操作金额数量")
|
||||
private Long count;
|
||||
|
||||
}
|
||||
+10
@@ -10,6 +10,7 @@ import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAdminRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDisagreeDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
|
||||
@@ -76,6 +77,15 @@ public class HardAfterSaleController {
|
||||
}
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
@PostMapping(value = "/admin-refund")
|
||||
@Operation(summary = "后台退款")
|
||||
@Idempotent(expireTime = 10, info = "正在退款中,请勿重复操作")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardAfterSale_adminRefund')")
|
||||
public R<Boolean> adminRefund(@RequestBody HardAdminRefundDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
return R.ok(hardAfterSaleService.adminRefund(dto, user));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/history")
|
||||
@Operation(summary = "查询售后进度")
|
||||
public R<List<HardAfterSaleLogEntity>> history(@RequestParam Long id) {
|
||||
|
||||
+73
-2
@@ -10,9 +10,12 @@ import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
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.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
|
||||
@@ -56,8 +59,15 @@ public class HardOrderTotalController {
|
||||
return R.ok(HardOrderTotalService.pageListCs(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "设备交易记录导出", description = "退款导出")
|
||||
@GetMapping("/page-list-dept")
|
||||
@Operation(summary = "部门交易记录")
|
||||
public R<List<HardDeptTotalVo>> pageListDept(@ParameterObject HardDeptTotalDto dto) {
|
||||
return R.ok(HardOrderTotalService.pageListDept(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "设备交易记录导出", description = "设备交易记录导出")
|
||||
@GetMapping("/export-sb")
|
||||
@SysLog("设备交易记录导出")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_sb')")
|
||||
public void exportSb(HttpServletResponse response, HardOrderDto dto) throws IOException {
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
@@ -95,8 +105,9 @@ public class HardOrderTotalController {
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "商户交易记录导出", description = "退款导出")
|
||||
@Operation(summary = "商户交易记录导出", description = "商户交易记录导出")
|
||||
@GetMapping("/export-cs")
|
||||
@SysLog("商户交易记录导出")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_cs')")
|
||||
public void exportTk(HttpServletResponse response, HardOrderDto dto) throws IOException {
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
@@ -132,4 +143,64 @@ public class HardOrderTotalController {
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "部门交易记录导出", description = "部门交易记录导出")
|
||||
@GetMapping("/export-dept")
|
||||
@SysLog("部门交易记录导出")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_dept')")
|
||||
public void exportDept(HttpServletResponse response, HardDeptTotalDto dto) throws IOException {
|
||||
List<HardDeptTotalVo> list = HardOrderTotalService.pageListDept(dto);
|
||||
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();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal walletPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal walletCountSum = BigDecimal.ZERO;
|
||||
BigDecimal orderPayPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal orderPayCountSum = BigDecimal.ZERO;
|
||||
BigDecimal orderRefundPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal orderRefundContSum = BigDecimal.ZERO;
|
||||
for (HardDeptTotalVo v : list) {
|
||||
if (ObjectUtil.isNotEmpty(v.getWalletPrice())) {
|
||||
walletPriceSum = walletPriceSum.add(BigDecimal.valueOf(v.getWalletPrice()));
|
||||
v.setWalletPrice(BigDecimal.valueOf(v.getWalletPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getWalletCount())) {
|
||||
walletCountSum = walletCountSum.add(BigDecimal.valueOf(v.getWalletCount()));
|
||||
v.setWalletCount(BigDecimal.valueOf(v.getWalletCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getOrderPayPrice())) {
|
||||
orderPayPriceSum = orderPayPriceSum.add(BigDecimal.valueOf(v.getOrderPayPrice()));
|
||||
v.setOrderPayPrice(BigDecimal.valueOf(v.getOrderPayPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getOrderPayCount())) {
|
||||
orderPayCountSum = orderPayCountSum.add(BigDecimal.valueOf(v.getOrderPayCount()));
|
||||
v.setOrderPayCount(BigDecimal.valueOf(v.getOrderPayCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getOrderRefundPrice())) {
|
||||
orderRefundPriceSum = orderRefundPriceSum.add(BigDecimal.valueOf(v.getOrderRefundPrice()));
|
||||
v.setOrderRefundPrice(BigDecimal.valueOf(v.getOrderRefundPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getOrderRefundCont())) {
|
||||
orderRefundContSum = orderRefundContSum.add(BigDecimal.valueOf(v.getOrderRefundCont()));
|
||||
v.setOrderRefundCont(BigDecimal.valueOf(v.getOrderRefundCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
|
||||
}
|
||||
map.put("walletPriceSum", walletPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("walletCountSum", walletCountSum.toString());
|
||||
map.put("orderPayPriceSum", orderPayPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("orderPayCountSum", orderPayCountSum.toString());
|
||||
map.put("orderRefundPriceSum", orderRefundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("orderRefundContSum", orderRefundContSum.toString());
|
||||
}
|
||||
}
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -7,11 +7,13 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSumAndCountVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -85,4 +87,6 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
Page<HardOrderCsVo> pageListCs(Page page, @Param("dto") HardOrderDto dto);
|
||||
|
||||
List<HardOrderCsVo> listCs(@Param("dto") HardOrderDto dto);
|
||||
|
||||
List<HardOrderSumAndCountVo> sumAndCount(@Param("dto") HardOrderSumAndCountDto dto);
|
||||
}
|
||||
+14
-2
@@ -2,6 +2,8 @@ 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.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAdminRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDisagreeDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
|
||||
@@ -20,6 +22,7 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
|
||||
/**
|
||||
* 申请售后
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -27,7 +30,8 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
|
||||
/**
|
||||
* 取消售后
|
||||
* @param userId 用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param afterSaleId 售后id
|
||||
* @return
|
||||
*/
|
||||
@@ -51,7 +55,7 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
* 同意售后
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param id 售后id
|
||||
* @param id 售后id
|
||||
*/
|
||||
Boolean agreeAfterSale(Long userId, Long id);
|
||||
|
||||
@@ -63,4 +67,12 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
* @return
|
||||
*/
|
||||
Boolean disagreeRefund(Long userId, HardDisagreeDto dto);
|
||||
|
||||
/**
|
||||
* 后台退款
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Boolean adminRefund(HardAdminRefundDto dto, PjcloudUser user);
|
||||
}
|
||||
+4
@@ -1,7 +1,9 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
|
||||
|
||||
@@ -16,4 +18,6 @@ public interface HardOrderTotalService {
|
||||
Page<HardOrderCsVo> pageListCs(Page page, HardOrderDto dto);
|
||||
|
||||
List<HardOrderCsVo> listCs(HardOrderDto dto);
|
||||
|
||||
List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto);
|
||||
}
|
||||
+43
-2
@@ -17,12 +17,14 @@ 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.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardAfterSaleOperateTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardRefundStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardSaleStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardSaleTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAdminRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDisagreeDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
@@ -216,7 +218,10 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
// 创建退款单
|
||||
WalletRechargeRefundDto hardRefundDto = WalletRechargeRefundDto.builder().walletId(order.getWalletId()).orderId(order.getId()).afterSaleId(afterSale.getId()).refundCode(refundCode).reason("订单退款").price(order.getPayPrice()).build();
|
||||
R<WalletRechargeVo> walletRefundResult = walletRechargeService.refund(hardRefundDto);
|
||||
WalletRechargeVo walletRefund = Optional.of(walletRefundResult).map(R::getData).orElseThrow(() -> new RuntimeException("钱包退款错误"));
|
||||
if (walletRefundResult.getCode() != 0 || ObjectUtil.isEmpty(walletRefundResult.getData())) {
|
||||
throw new RuntimeException("钱包退款错误");
|
||||
}
|
||||
WalletRechargeVo walletRefund = walletRefundResult.getData();
|
||||
HardOrderEntity updateObj = HardOrderEntity.builder()
|
||||
.id(order.getId())
|
||||
.orderStatus(HardOrderStatusEnum.REFUND.getType())
|
||||
@@ -303,7 +308,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
}
|
||||
// 校验订单是否已退款
|
||||
if (ObjectUtil.isNotEmpty(order.getPayRefundId())) {
|
||||
throw new RuntimeException("发起退款失败,示例订单已退款");
|
||||
throw new RuntimeException("发起退款失败,订单已退款");
|
||||
}
|
||||
return orderVo;
|
||||
}
|
||||
@@ -353,6 +358,42 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
return saveObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
// @GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean adminRefund(HardAdminRefundDto dto, PjcloudUser user) {
|
||||
// 校验订单是否可以退款
|
||||
HardOrderVo order = validateOrderCanRefund(dto.getOrderId());
|
||||
// 添加售后订单
|
||||
HardAfterSaleEntity saveObj = BeanUtils.toBean(dto, HardAfterSaleEntity.class);
|
||||
String refundCode = "hard_" + order.getId();
|
||||
saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType());
|
||||
saveObj.setStatus(HardSaleStatusEnum.COMPLETE.getStatus());
|
||||
saveObj.setNo(refundCode);
|
||||
saveObj.setOrderId(order.getId());
|
||||
saveObj.setRefundPrice(order.getPayPrice());
|
||||
saveObj.setUserId(order.getUserId());
|
||||
saveObj.setAuditUserId(user.getId());
|
||||
saveObj.setAuditTime(LocalDateTime.now());
|
||||
saveObj.setAuditReason("后台退款");
|
||||
baseMapper.insert(saveObj);
|
||||
// 添加售后进度
|
||||
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
|
||||
.afterSaleId(saveObj.getId())
|
||||
.userId(order.getUserId())
|
||||
.operateType(HardAfterSaleOperateTypeEnum.ADMIN_REFUND.getType())
|
||||
.beforeStatus(order.getOrderStatus())
|
||||
.afterStatus(HardSaleStatusEnum.COMPLETE.getStatus())
|
||||
.content(HardSaleStatusEnum.COMPLETE.getContent())
|
||||
.build();
|
||||
hardAfterSaleLogMapper.insert(saveLogObj);
|
||||
// 执行退款
|
||||
getSelf().refund(saveObj.getId());
|
||||
// 退库存
|
||||
hardOrderService.fastenerInventory(order, YesNoEnum.NO);
|
||||
return true;
|
||||
}
|
||||
|
||||
private HardAfterSaleServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
+99
@@ -3,25 +3,38 @@ package com.bsd.pjcloud.hard.service.impl.order;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSumAndCountVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionSumAndCountDto;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletTransactionService;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@@ -33,6 +46,8 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
private final HardManagerMapper hardManagerMapper;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteWalletTransactionService remoteWalletTransactionService;
|
||||
private final RemoteDeptService remoteDeptService;
|
||||
|
||||
@Override
|
||||
public Page<HardOrderSbVo> pageListSb(Page page, HardOrderDto dto) {
|
||||
@@ -117,4 +132,88 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto) {
|
||||
// 查询部门
|
||||
CompletableFuture<List<SysDept>> deptFuture = CompletableFuture.supplyAsync(() ->
|
||||
remoteDeptService.getInnerAllDept().getData()
|
||||
);
|
||||
CompletableFuture<List<HardDeptTotalVo>> resultListFuture = deptFuture.thenApply(deptList -> {
|
||||
if (ObjectUtil.isEmpty(deptList)) return null;
|
||||
List<Long> deptIds = deptList.stream().map(SysDept::getDeptId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
List<HardDeptTotalVo> resultList = deptList.stream().map(v -> {
|
||||
HardDeptTotalVo item = new HardDeptTotalVo();
|
||||
item.setDeptId(v.getDeptId());
|
||||
item.setDeptName(v.getName());
|
||||
return item;
|
||||
}).toList();
|
||||
// 查询钱包流水
|
||||
CompletableFuture<List<WalletTransactionSumAndCountVo>> walletFuture = CompletableFuture.supplyAsync(() -> {
|
||||
WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto();
|
||||
walletDto.setDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
walletDto.setCreateTimeList(dto.getCreateTimeList());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
|
||||
walletDto.setWalletTypeId(dto.getWalletTypeId());
|
||||
}
|
||||
return remoteWalletTransactionService.sumAndCount(walletDto).getData();
|
||||
});
|
||||
// 查询订单支付流水
|
||||
CompletableFuture<List<HardOrderSumAndCountVo>> payFuture = CompletableFuture.supplyAsync(() -> {
|
||||
HardOrderSumAndCountDto payDto = new HardOrderSumAndCountDto();
|
||||
payDto.setDeptIds(deptIds);
|
||||
payDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
payDto.setCreateTimeList(dto.getCreateTimeList());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
|
||||
payDto.setWalletTypeId(dto.getWalletTypeId());
|
||||
}
|
||||
return hardOrderMapper.sumAndCount(payDto);
|
||||
});
|
||||
// 查询订单退款流水
|
||||
CompletableFuture<List<HardOrderSumAndCountVo>> refundFuture = CompletableFuture.supplyAsync(() -> {
|
||||
HardOrderSumAndCountDto refundDto = new HardOrderSumAndCountDto();
|
||||
refundDto.setDeptIds(deptIds);
|
||||
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
refundDto.setCreateTimeList(dto.getCreateTimeList());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
|
||||
refundDto.setWalletTypeId(dto.getWalletTypeId());
|
||||
}
|
||||
return hardOrderMapper.sumAndCount(refundDto);
|
||||
});
|
||||
CompletableFuture<Void> allFutures = CompletableFuture.allOf(walletFuture, payFuture, refundFuture);
|
||||
allFutures.join();
|
||||
List<WalletTransactionSumAndCountVo> walletList = walletFuture.join();
|
||||
List<HardOrderSumAndCountVo> payList = payFuture.join();
|
||||
List<HardOrderSumAndCountVo> refundList = refundFuture.join();
|
||||
// 聚合一下数据
|
||||
for (HardDeptTotalVo v : resultList) {
|
||||
if (ObjectUtil.isNotEmpty(walletList)) {
|
||||
walletList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> {
|
||||
v.setWalletPrice(i.getSum());
|
||||
v.setWalletCount(i.getCount());
|
||||
});
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(payList)) {
|
||||
payList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> {
|
||||
v.setOrderPayPrice(i.getSum());
|
||||
v.setOrderPayCount(i.getCount());
|
||||
});
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(refundList)) {
|
||||
refundList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> {
|
||||
v.setOrderRefundPrice(i.getSum());
|
||||
v.setOrderRefundCont(i.getCount());
|
||||
});
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
});
|
||||
return resultListFuture.join();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
+30
@@ -137,4 +137,34 @@
|
||||
</where>
|
||||
group by a.merchant_id
|
||||
</select>
|
||||
|
||||
<select id="sumAndCount" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderSumAndCountVo">
|
||||
select
|
||||
a.dept_id,
|
||||
sum(a.pay_price) as sum,
|
||||
count(0) as count
|
||||
from hard_order a
|
||||
<where>
|
||||
a.del_flag = 0 and a.dept_id is not null
|
||||
<if test="dto.walletTypeId != null">
|
||||
</if>
|
||||
<if test="dto.orderStatusCodes != null and dto.orderStatusCodes.size() != 0">
|
||||
and a.order_status in
|
||||
<foreach collection="dto.orderStatusCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
|
||||
and a.dept_id in
|
||||
<foreach collection="dto.deptIds" 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>
|
||||
</where>
|
||||
group by a.dept_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+6
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.bsd.pjcloud.admin.api.feign;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -47,6 +48,10 @@ public interface RemoteDeptService {
|
||||
@GetMapping("/dept/list")
|
||||
R<List<SysDept>> getAllDept(@RequestParam("parentDeptId") Long parentDeptId);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/dept/inner-all-dept")
|
||||
R<List<SysDept>> getInnerAllDept();
|
||||
|
||||
/**
|
||||
* 通过部门ID获取负责人列表
|
||||
*
|
||||
@@ -97,6 +102,7 @@ public interface RemoteDeptService {
|
||||
|
||||
/**
|
||||
* 查询部门所属的分组部门
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
|
||||
+10
@@ -19,6 +19,9 @@
|
||||
|
||||
package com.bsd.pjcloud.admin.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.vo.DeptExcelVO;
|
||||
import com.bsd.pjcloud.admin.service.SysDeptService;
|
||||
@@ -32,6 +35,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -216,4 +220,10 @@ public class SysDeptController {
|
||||
public R<SysDept> getParentDeptHardGroup(@RequestParam("deptId") Long deptId) {
|
||||
return R.ok(sysDeptService.getParentDeptHardGroup(deptId));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/inner-all-dept")
|
||||
public R<List<SysDept>> getInnerAllDept() {
|
||||
return R.ok(sysDeptService.list());
|
||||
}
|
||||
}
|
||||
+1
@@ -20,6 +20,7 @@
|
||||
package com.bsd.pjcloud.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserDTO;
|
||||
|
||||
+5
@@ -21,6 +21,11 @@ public enum WalletTypeEnum {
|
||||
|
||||
private final String desc;
|
||||
|
||||
public static WalletTypeEnum valueOfByCode(String code) {
|
||||
if (ObjectUtil.isEmpty(code)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(code, v.getCode())).findFirst().get();
|
||||
}
|
||||
|
||||
public static WalletTypeEnum descOf(String description) {
|
||||
return Arrays.stream(WalletTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
|
||||
+4
@@ -3,6 +3,8 @@ package com.bsd.pjcloud.wallet.api.dto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -12,4 +14,6 @@ public class WalletManageDto extends WalletManageEntity {
|
||||
|
||||
private List<Long> walletIds;
|
||||
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.bsd.pjcloud.wallet.api.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WalletTransactionSumAndCountDto {
|
||||
/**
|
||||
* 类型 - 收入
|
||||
*/
|
||||
public static final Integer TYPE_INCOME = 1;
|
||||
/**
|
||||
* 类型 - 支出
|
||||
*/
|
||||
public static final Integer TYPE_EXPENSE = 2;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private List<String> bizTypes;
|
||||
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
private Long walletTypeId;
|
||||
|
||||
}
|
||||
+2
@@ -15,6 +15,8 @@ public class WalletRechargeImportDto extends WalletRechargeImportEntity {
|
||||
|
||||
private List<Long> userIds;
|
||||
|
||||
private List<Long> userUniqueIds;
|
||||
|
||||
private Long userDeptId;
|
||||
|
||||
private List<Long> userDeptIds;
|
||||
|
||||
+8
@@ -4,11 +4,15 @@ 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.dto.WalletBalanceTransactionDto;
|
||||
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 org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "remoteWalletTransactionService", value = ServiceNameConstants.WALLET_SERVICE)
|
||||
public interface RemoteWalletTransactionService {
|
||||
|
||||
@@ -20,4 +24,8 @@ public interface RemoteWalletTransactionService {
|
||||
@PostMapping("/wallet-transaction/reduce-balance")
|
||||
R<WalletTransactionEntity> reduceWalletBalance(@RequestBody WalletBalanceTransactionDto dto);
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/wallet-transaction/sum-and-count")
|
||||
R<List<WalletTransactionSumAndCountVo>> sumAndCount(@RequestBody WalletTransactionSumAndCountDto dto);
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletTransactionSumAndCountVo {
|
||||
|
||||
@Schema(description = "部门id")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门操作金额")
|
||||
private Long sum;
|
||||
|
||||
@Schema(description = "部门操作金额数量")
|
||||
private Long count;
|
||||
|
||||
}
|
||||
+5
@@ -12,6 +12,11 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class WalletTransactionVo extends WalletTransactionEntity implements BaseUserInterface, BaseDeptInterface, BaseWalletTypeInterface, BaseWalletInterface {
|
||||
|
||||
/**
|
||||
* 字符串金额用于导出
|
||||
*/
|
||||
private String priceStr;
|
||||
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
|
||||
@@ -149,4 +149,24 @@
|
||||
<id>boot</id>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/*.xlsx</exclude>
|
||||
<exclude>**/*.xls</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>**/*.xlsx</include>
|
||||
<include>**/*.xls</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
+10
-6
@@ -7,6 +7,8 @@ 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.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;
|
||||
@@ -18,6 +20,7 @@ import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -112,7 +115,9 @@ public class WalletManageController {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
WalletManageDto dto = new WalletManageDto();
|
||||
dto.setUserId(user.getId());
|
||||
return R.ok(walletManageService.pageJoin(page, dto));
|
||||
DataScope dataScope = new DataScope();
|
||||
dataScope.func(DataScopeFuncEnum.ALL);
|
||||
return R.ok(walletManageService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@@ -142,7 +147,7 @@ public class WalletManageController {
|
||||
@GetMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletManage_view')")
|
||||
public R getWalletManagePageJoin(@ParameterObject Page page, @ParameterObject WalletManageDto dto) {
|
||||
return R.ok(walletManageService.scopePageList(page, dto));
|
||||
return R.ok(walletManageService.scopePageList(page, dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@@ -175,11 +180,10 @@ public class WalletManageController {
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(walletManageService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletManage_export')")
|
||||
public List<WalletManageEntity> export(WalletManageEntity walletManage, Long[] ids) {
|
||||
return walletManageService.list(Wrappers.lambdaQuery(walletManage).in(ArrayUtil.isNotEmpty(ids), WalletManageEntity::getId, ids));
|
||||
public void export(HttpServletResponse response, @ParameterObject Page page, @ParameterObject WalletManageDto dto) {
|
||||
walletManageService.export(response, page, dto);
|
||||
}
|
||||
}
|
||||
+21
-20
@@ -1,11 +1,8 @@
|
||||
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.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.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
|
||||
@@ -16,15 +13,15 @@ import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
|
||||
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.recharge.excel.WalletTransactionCzExcelVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionTkExcelVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionXfExcelVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
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;
|
||||
@@ -33,7 +30,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -51,6 +47,8 @@ public class WalletTransactionController {
|
||||
|
||||
private final WalletTransactionService walletTransactionService;
|
||||
|
||||
private final WalletTransactionMapper walletTransactionMapper;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
@Inner
|
||||
@PostMapping("/add-balance")
|
||||
@@ -67,6 +65,12 @@ public class WalletTransactionController {
|
||||
if (ObjectUtil.isEmpty(walletTransaction)) return R.failed("扣减钱包余额");
|
||||
return R.ok(walletTransaction);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@PostMapping("/sum-and-count")
|
||||
public R<List<WalletTransactionSumAndCountVo>> sumAndCount(@RequestBody WalletTransactionSumAndCountDto dto) {
|
||||
return R.ok(walletTransactionMapper.sumAndCount(dto));
|
||||
}
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
@@ -153,34 +157,31 @@ public class WalletTransactionController {
|
||||
return R.ok(walletTransactionService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@Operation(summary = "充值导出", description = "充值导出")
|
||||
@GetMapping("/export-cz")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
public List<WalletTransactionCzExcelVo> exportCz(WalletTransactionDto dto) {
|
||||
public void exportCz(HttpServletResponse response, @ParameterObject Page page, WalletTransactionDto dto) {
|
||||
dto.setBizTypes(List.of(WalletBizEnum.RECHARGE.getCode()));
|
||||
List<WalletTransactionVo> list = walletTransactionService.pageList(dto);
|
||||
return BeanUtils.toBean(list, WalletTransactionCzExcelVo.class);
|
||||
List<WalletTransactionVo> list = walletTransactionService.scopePageList(page, dto, DataScope.of()).getRecords();
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list);
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@Operation(summary = "消费导出", description = "消费导出")
|
||||
@GetMapping("/export-xf")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
public List<WalletTransactionXfExcelVo> exportXf(WalletTransactionDto dto) {
|
||||
public void exportXf(HttpServletResponse response, @ParameterObject Page page, WalletTransactionDto dto) {
|
||||
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
|
||||
List<WalletTransactionVo> list = walletTransactionService.pageList(dto);
|
||||
return BeanUtils.toBean(list, WalletTransactionXfExcelVo.class);
|
||||
List<WalletTransactionVo> list = walletTransactionService.scopePageList(page, dto, DataScope.of()).getRecords();
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人消费明细.xlsx", list);
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@Operation(summary = "退款导出", description = "退款导出")
|
||||
@GetMapping("/export-tk")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
public List<WalletTransactionTkExcelVo> exportTk(WalletTransactionDto dto) {
|
||||
public void exportTk(HttpServletResponse response, @ParameterObject Page page, WalletTransactionDto dto) {
|
||||
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
|
||||
dto.setIsFindOrder(true);
|
||||
List<WalletTransactionVo> list = walletTransactionService.pageList(dto);
|
||||
return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
|
||||
List<WalletTransactionVo> list = walletTransactionService.scopePageList(page, dto, DataScope.of()).getRecords();
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人退款明细.xlsx", list);
|
||||
}
|
||||
}
|
||||
+18
-7
@@ -13,7 +13,6 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -59,7 +58,7 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
return update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
default Page<WalletManageVo> pageJoin(Page<WalletManageVo> page, @Param("pa") WalletManageDto dto) {
|
||||
default List<WalletManageVo> joinList(WalletManageDto dto) {
|
||||
MPJLambdaWrapper<WalletManageEntity> wrapper = new MPJLambdaWrapper<WalletManageEntity>()
|
||||
.selectAll(WalletManageEntity.class)
|
||||
.selectAs(WalletTypeEntity::getName, WalletManageVo::getWalletTypeName)
|
||||
@@ -70,8 +69,14 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
.eqIfExists(WalletManageEntity::getWalletTypeId, dto.getWalletTypeId())
|
||||
.eqIfExists(WalletManageEntity::getIsFreeze, dto.getIsFreeze())
|
||||
.likeIfExists(WalletManageEntity::getCardNumber, dto.getCardNumber())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds());
|
||||
return selectJoinPage(page, WalletManageVo.class, wrapper);
|
||||
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds())
|
||||
.between(
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
|
||||
WalletManageEntity::getCreateTime,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
|
||||
);
|
||||
return selectJoinList(WalletManageVo.class, wrapper);
|
||||
}
|
||||
|
||||
default List<WalletManageEntity> list(WalletManageDto dto) {
|
||||
@@ -95,14 +100,20 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
return selectJoinOne(WalletManageVo.class, wrapper);
|
||||
}
|
||||
|
||||
default Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto) {
|
||||
default Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto, DataScope dataScope) {
|
||||
LambdaQueryWrapper<WalletManageEntity> wrapper = new LambdaQueryWrapper<WalletManageEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletManageEntity::getUserId, dto.getUserId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getWalletTypeId()), WalletManageEntity::getWalletTypeId, dto.getWalletTypeId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getIsFreeze()), WalletManageEntity::getIsFreeze, dto.getIsFreeze())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getWalletIds()), WalletManageEntity::getId, dto.getWalletIds())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds());
|
||||
Page list = selectPageByScope(page, wrapper, DataScope.of());
|
||||
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds())
|
||||
.between(
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
|
||||
WalletManageEntity::getCreateTime,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
|
||||
);
|
||||
Page list = selectPageByScope(page, wrapper, dataScope);
|
||||
list.setRecords(BeanUtils.toBean(list.getRecords(), WalletManageVo.class));
|
||||
return list;
|
||||
}
|
||||
|
||||
+4
@@ -7,9 +7,11 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionSumAndCountDto;
|
||||
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.recharge.WalletRechargeApplySelectCompareVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -69,4 +71,6 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
|
||||
Integer getTransactionPriceCount(@Param("month") String importTimeStr, @Param("walletId") Long walletId, @Param("bizType") String bizType);
|
||||
|
||||
List<WalletRechargeApplySelectCompareVo> selectCompare(@Param("bizType") String bizType, @Param("dateTime") String monthTimeStr, @Param("userIdList") List<Long> userIdList);
|
||||
|
||||
List<WalletTransactionSumAndCountVo> sumAndCount(@Param("dto") WalletTransactionSumAndCountDto dto);
|
||||
}
|
||||
+13
-10
@@ -3,10 +3,12 @@ package com.bsd.pjcloud.wallet.service;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -47,6 +49,7 @@ public interface WalletManageService extends IService<WalletManageEntity> {
|
||||
|
||||
/**
|
||||
* 获取钱包(没有缓存)
|
||||
*
|
||||
* @param cardNumber
|
||||
* @return
|
||||
*/
|
||||
@@ -70,7 +73,6 @@ public interface WalletManageService extends IService<WalletManageEntity> {
|
||||
*/
|
||||
WalletManageEntity getWallet(@NotNull Long walletId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id删除用户钱包
|
||||
*
|
||||
@@ -79,16 +81,9 @@ public interface WalletManageService extends IService<WalletManageEntity> {
|
||||
*/
|
||||
Boolean delWalletByUserIds(List<@NotNull Long> userIds);
|
||||
|
||||
/**
|
||||
* 分页连表查询
|
||||
*
|
||||
* @param page
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Page<WalletManageVo> pageJoin(Page page, WalletManageDto dto);
|
||||
Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto, DataScope dataScope);
|
||||
|
||||
Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto);
|
||||
List<WalletManageVo> joinList(WalletManageDto dto);
|
||||
|
||||
WalletManageVo join(Long user, Long walletId);
|
||||
|
||||
@@ -98,4 +93,12 @@ public interface WalletManageService extends IService<WalletManageEntity> {
|
||||
* @param walletId 钱包id
|
||||
*/
|
||||
String getQrCode(Long walletId);
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param response
|
||||
* @param dto
|
||||
*/
|
||||
void export(HttpServletResponse response, Page page, WalletManageDto dto);
|
||||
}
|
||||
+4
@@ -7,7 +7,9 @@ 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.transaction.WalletTransactionVo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface WalletTransactionService extends IService<WalletTransactionEntity> {
|
||||
@@ -46,4 +48,6 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
|
||||
* @return
|
||||
*/
|
||||
Boolean updateWalletBalance(WalletTransactionDto dto);
|
||||
|
||||
void exportByTemplate(HttpServletResponse response, WalletTransactionDto dto, String fileName, List<WalletTransactionVo> list);
|
||||
}
|
||||
+65
-9
@@ -1,8 +1,15 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -18,6 +25,7 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
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.resolver.ParamResolver;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
@@ -31,11 +39,13 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletSettingService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTypeService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -45,6 +55,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
@@ -206,28 +219,28 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<WalletManageVo> pageJoin(Page page, WalletManageDto dto) {
|
||||
Page<WalletManageVo> list = baseMapper.pageJoin(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
public List<WalletManageVo> joinList(WalletManageDto dto) {
|
||||
List<WalletManageVo> list = baseMapper.joinList(dto);
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(WalletManageVo::getUserId).distinct().toList();
|
||||
List<Long> userIds = list.stream().map(WalletManageVo::getUserId).distinct().toList();
|
||||
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
}
|
||||
// 部门
|
||||
List<Long> deptIds = list.getRecords().stream().map(WalletManageVo::getDeptId).distinct().toList();
|
||||
List<Long> deptIds = list.stream().map(WalletManageVo::getDeptId).distinct().toList();
|
||||
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
DataUtil.convertDeptList(list, deptList.getData());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto) {
|
||||
Page<WalletManageVo> list = baseMapper.scopePageList(page, dto);
|
||||
public Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto, DataScope dataScope) {
|
||||
Page<WalletManageVo> list = baseMapper.scopePageList(page, dto, dataScope);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(WalletManageVo::getUserId).distinct().toList();
|
||||
@@ -267,6 +280,49 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(HttpServletResponse response, Page page, WalletManageDto dto) {
|
||||
String fileName = "file/账户余额.xlsx";
|
||||
List<WalletManageVo> list = scopePageList(page, dto, DataScope.of()).getRecords();
|
||||
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();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal balanceSum = BigDecimal.ZERO;
|
||||
BigDecimal totalExpenseSum = BigDecimal.ZERO;
|
||||
BigDecimal totalRechargeSum = BigDecimal.ZERO;
|
||||
for (WalletManageVo v : list) {
|
||||
if (ObjectUtil.isNotEmpty(v.getBalance())) {
|
||||
balanceSum = balanceSum.add(BigDecimal.valueOf(v.getBalance()));
|
||||
v.setBalance(BigDecimal.valueOf(v.getBalance()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalExpense())) {
|
||||
totalExpenseSum = totalExpenseSum.add(BigDecimal.valueOf(v.getTotalExpense()));
|
||||
v.setTotalExpense(BigDecimal.valueOf(v.getTotalExpense()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalRecharge())) {
|
||||
totalRechargeSum = totalRechargeSum.add(BigDecimal.valueOf(v.getTotalRecharge()));
|
||||
v.setTotalRecharge(BigDecimal.valueOf(v.getTotalRecharge()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
}
|
||||
map.put("balanceSum", balanceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("totalExpenseSum", totalExpenseSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("totalRechargeSum", totalRechargeSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("|{}|导入错误,dto:|{}|,fileName:|{}|,error:|{}|", TAG, JSON.toJSONString(dto), fileName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private WalletManageServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
+41
@@ -1,7 +1,14 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -28,6 +35,7 @@ import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -35,7 +43,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -239,4 +251,33 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@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()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal priceTotal = BigDecimal.ZERO;
|
||||
for (WalletTransactionVo v : list) {
|
||||
if (ObjectUtil.isNotEmpty(v.getPrice())) {
|
||||
priceTotal = priceTotal.add(BigDecimal.valueOf(v.getPrice()));
|
||||
v.setPriceStr(BigDecimal.valueOf(v.getPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
}
|
||||
map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("|{}|导入错误,dto:|{}|,fileName:|{}|,error:|{}|", TAG, JSON.toJSONString(dto), fileName, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -28,6 +28,7 @@ import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
@@ -347,6 +348,11 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
if (ObjectUtil.isNotEmpty(detail.getProcessStatus()) || ObjectUtil.equals(detail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
|
||||
return;
|
||||
}
|
||||
WalletTypeEntity walletType = walletTypeService.getById(detail.getWalletTypeId());
|
||||
WalletTypeEnum walletTypeEnum = WalletTypeEnum.valueOfByCode(walletType.getUniqueCode());
|
||||
if (ObjectUtil.isEmpty(walletType) || ObjectUtil.isEmpty(walletTypeEnum)) {
|
||||
return;
|
||||
}
|
||||
String importTimeStr = LocalDateTimeUtil.format(detail.getImportTime(), DatePattern.NORM_MONTH_PATTERN);
|
||||
List<WalletRechargeImportEntity> importList = rechargeImportService.list(new LambdaQueryWrapper<WalletRechargeImportEntity>()
|
||||
.eq(WalletRechargeImportEntity::getApplyId, detail.getId())
|
||||
@@ -356,7 +362,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
for (WalletRechargeImportEntity v : importList) {
|
||||
WalletRechargeImportEntity item = new WalletRechargeImportEntity();
|
||||
item.setId(v.getId());
|
||||
WalletManageEntity wallet = walletManageService.getWallet(v.getUserId(), detail.getWalletTypeId());
|
||||
WalletManageEntity wallet = walletManageService.getOrCreateWallet(v.getUserId(), walletTypeEnum);
|
||||
if (ObjectUtil.isEmpty(wallet)) continue;
|
||||
Integer price = walletTransactionMapper.getTransactionPriceCount(importTimeStr, wallet.getId(), WalletBizEnum.BATCH.getCode());
|
||||
if (ObjectUtil.isNotEmpty(price)) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+75
-32
@@ -2,8 +2,7 @@
|
||||
<!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.WalletTransactionMapper">
|
||||
|
||||
<resultMap id="walletTransactionMap" type="com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity">
|
||||
<resultMap id="walletTransactionMap" type="com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="walletId" column="wallet_id"/>
|
||||
<result property="bizType" column="biz_type"/>
|
||||
@@ -11,36 +10,80 @@
|
||||
<result property="title" column="title"/>
|
||||
<result property="price" column="price"/>
|
||||
<result property="balance" column="balance"/>
|
||||
</resultMap>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTransactionPriceCount" resultType="java.lang.Integer">
|
||||
select sum(a.price)
|
||||
from wallet_transaction a
|
||||
<where>
|
||||
<if test="month != null and month != '' ">
|
||||
and DATE_FORMAT(a.create_time, '%Y-%m') = #{month}
|
||||
</if>
|
||||
<if test="walletId != null">
|
||||
and a.wallet_id = #{walletId}
|
||||
</if>
|
||||
<if test="bizType != null and bizType != '' ">
|
||||
and a.biz_type = #{bizType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<sql id="selectA">
|
||||
</sql>
|
||||
|
||||
<select id="selectCompare" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplySelectCompareVo">
|
||||
SELECT w.user_id,
|
||||
SUM(a.price) as price
|
||||
FROM wallet_transaction a
|
||||
INNER JOIN
|
||||
wallet_manage w ON w.id = a.wallet_id
|
||||
WHERE biz_type = #{bizType}
|
||||
and DATE_FORMAT(a.create_time, '%Y-%m') = #{dateTime}
|
||||
and w.user_id in
|
||||
<foreach collection="userIdList" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
GROUP BY w.user_id
|
||||
</select>
|
||||
<sql id="whereA">
|
||||
|
||||
</sql>
|
||||
|
||||
<select id="getTransactionPriceCount" resultType="java.lang.Integer">
|
||||
select sum(a.price)
|
||||
from wallet_transaction a
|
||||
<where>
|
||||
<if test="month != null and month != '' ">
|
||||
and DATE_FORMAT(a.create_time, '%Y-%m') = #{month}
|
||||
</if>
|
||||
<if test="walletId != null">
|
||||
and a.wallet_id = #{walletId}
|
||||
</if>
|
||||
<if test="bizType != null and bizType != '' ">
|
||||
and a.biz_type = #{bizType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectCompare" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplySelectCompareVo">
|
||||
SELECT w.user_id,
|
||||
SUM(a.price) as price
|
||||
FROM wallet_transaction a
|
||||
INNER JOIN
|
||||
wallet_manage w ON w.id = a.wallet_id
|
||||
WHERE biz_type = #{bizType}
|
||||
and DATE_FORMAT(a.create_time, '%Y-%m') = #{dateTime}
|
||||
and w.user_id in
|
||||
<foreach collection="userIdList" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
GROUP BY w.user_id
|
||||
</select>
|
||||
|
||||
<select id="sumAndCount" resultType="com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo">
|
||||
select
|
||||
a.dept_id,
|
||||
sum(a.price) as sum,
|
||||
count(0) as count
|
||||
from wallet_transaction a
|
||||
<where>
|
||||
a.del_flag = 0 and a.dept_id is not null
|
||||
<if test="dto.walletTypeId != null">
|
||||
</if>
|
||||
<if test="dto.type != null">
|
||||
<if test="dto.type == 1">
|
||||
and a.price > 0
|
||||
</if>
|
||||
<if test="dto.type == 2">
|
||||
and a.price < 0
|
||||
</if>
|
||||
</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.deptIds != null and dto.deptIds.size() != 0">
|
||||
and a.dept_id in
|
||||
<foreach collection="dto.deptIds" 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>
|
||||
</where>
|
||||
group by a.dept_id
|
||||
</select>
|
||||
</mapper>
|
||||
+6
@@ -40,6 +40,12 @@
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.userUniqueIds != null and dto.userUniqueIds.size() != 0">
|
||||
and a.user_id in
|
||||
<foreach collection="dto.userUniqueIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.userDeptIds != null and dto.userDeptIds.size() != 0">
|
||||
and a.user_dept_id in
|
||||
<foreach collection="dto.userDeptIds" item="v" open="(" close=")" separator=",">
|
||||
|
||||
Reference in new issue
Block a user