feat(gao): update customer recycle api
This commit is contained in:
+14
-1
@@ -30,11 +30,24 @@ public class GaoRecycleLedgerController {
|
||||
private final GaoStoreScopeService scope;
|
||||
private final GaoCustomerService customerService;
|
||||
|
||||
@RequireGaoPermission(GaoPermissionCode.RECYCLE_ACCOUNT_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoRecycleLedger detail(@RequestParam String id) {
|
||||
GaoRecycleLedger ledger = service.detail(id);
|
||||
TimiException.required(ledger, "回收物流水不存在");
|
||||
scope.checkStoreId(ledger.getStoreId());
|
||||
return ledger;
|
||||
}
|
||||
|
||||
@RequireGaoPermission(GaoPermissionCode.RECYCLE_ACCOUNT_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoRecycleLedger> list(@RequestBody GaoRecycleLedgerPage page) {
|
||||
TimiException.required(page, "请求不能为空");
|
||||
checkCustomer(page.getStoreId(), page.getCustomerId());
|
||||
scope.checkStoreId(page.getStoreId());
|
||||
if (page.getCustomerId() != null && !page.getCustomerId().isBlank()) {
|
||||
checkCustomer(page.getStoreId(), page.getCustomerId());
|
||||
}
|
||||
TimiException.requiredTrue(page.getIndex() >= 0 && page.getSize() > 0 && page.getSize() <= 100, "分页参数无效");
|
||||
return service.pageByQuery(page);
|
||||
}
|
||||
@RequireGaoPermission(GaoPermissionCode.RECYCLE_ACCOUNT_ADJUST)
|
||||
|
||||
@@ -33,6 +33,10 @@ public class GaoRecyclePaymentController {
|
||||
@PostMapping("/create-and-verify")
|
||||
public GaoRecyclePayment createAndVerify(@RequestBody GaoRecyclePaymentRequest request) { return service.createAndVerify(request); }
|
||||
|
||||
@RequireGaoPermission(GaoPermissionCode.FUND_RECORD_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoRecyclePayment detail(@RequestParam String id) { return service.detail(id); }
|
||||
|
||||
@RequireGaoPermission(GaoPermissionCode.FUND_RECORD_READ)
|
||||
@PostMapping("/list")
|
||||
public List<GaoRecyclePayment> list(@RequestParam String orderId) { return service.list(orderId); }
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.imyeyu.api.modules.gao.entity;
|
||||
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.spring.annotation.table.AutoUUID;
|
||||
import com.imyeyu.spring.annotation.table.Id;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.Creatable;
|
||||
import com.imyeyu.spring.entity.IDEntity;
|
||||
import lombok.Data;
|
||||
@@ -47,6 +49,18 @@ public class GaoRecycleLedger implements IDEntity<String>, Creatable {
|
||||
private BigDecimal balanceAfter;
|
||||
private BigDecimal reservedAfter;
|
||||
private String operatorUserId;
|
||||
@Transient
|
||||
private User operator;
|
||||
private String reason;
|
||||
private Long createdAt;
|
||||
@Transient
|
||||
private GaoCustomer customer;
|
||||
@Transient
|
||||
private String customerName;
|
||||
@Transient
|
||||
private String customerCode;
|
||||
@Transient
|
||||
private String recycleName;
|
||||
@Transient
|
||||
private String recycleUnit;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,12 @@ public class GaoRecyclePayment extends UUIDEntity {
|
||||
private String recycleName;
|
||||
@Transient
|
||||
private String recycleUnit;
|
||||
/// 关联订单当前成交金额,单位分
|
||||
@Transient
|
||||
private Long salesOrderAmount;
|
||||
/// 关联订单当前剩余待收金额,单位分
|
||||
@Transient
|
||||
private Long salesOrderUnpaidAmount;
|
||||
@Transient
|
||||
private GaoCustomer customer;
|
||||
@Transient
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.util.List;
|
||||
/// 回收物额度流水 Mapper
|
||||
public interface GaoRecycleLedgerMapper extends BaseMapper<GaoRecycleLedger, String> {
|
||||
|
||||
GaoRecycleLedger detail(@Param("id") String id);
|
||||
|
||||
long countByQuery(GaoRecycleLedgerPage page);
|
||||
|
||||
List<GaoRecycleLedger> selectByQuery(GaoRecycleLedgerPage page);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.imyeyu.api.modules.gao.service;
|
||||
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoRecycleLedgerMapper;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRecycleLedger;
|
||||
import com.imyeyu.api.modules.gao.vo.recycle.GaoRecycleLedgerPage;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
@@ -10,17 +15,51 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/// 回收物额度流水服务
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoRecycleLedgerService {
|
||||
private final GaoRecycleLedgerMapper mapper;
|
||||
private final GaoCustomerService customerService;
|
||||
private final AttachmentService attachmentService;
|
||||
private final UserService userService;
|
||||
|
||||
public GaoRecycleLedger detail(String id) {
|
||||
GaoRecycleLedger ledger = mapper.detail(id);
|
||||
if (ledger != null && ledger.getOperatorUserId() != null && !ledger.getOperatorUserId().isBlank()) {
|
||||
User source = userService.get(ledger.getOperatorUserId());
|
||||
if (source != null) {
|
||||
User operator = new User();
|
||||
operator.setId(source.getId());
|
||||
operator.setName(source.getName());
|
||||
operator.setNick(source.getNick());
|
||||
ledger.setOperator(operator);
|
||||
}
|
||||
}
|
||||
return ledger;
|
||||
}
|
||||
|
||||
public PageResult<GaoRecycleLedger> pageByQuery(GaoRecycleLedgerPage page) {
|
||||
PageResult<GaoRecycleLedger> result = new PageResult<>();
|
||||
result.setTotal(mapper.countByQuery(page));
|
||||
result.setList(mapper.selectByQuery(page));
|
||||
List<GaoRecycleLedger> records = mapper.selectByQuery(page);
|
||||
List<String> customerIds = records.stream().map(GaoRecycleLedger::getCustomerId)
|
||||
.filter(id -> id != null && !id.isBlank()).distinct().toList();
|
||||
if (!customerIds.isEmpty()) {
|
||||
Map<String, GaoCustomer> customers = customerService.mapByIdList(customerIds);
|
||||
Map<String, List<Attachment>> photos = attachmentService.mapByBizIdList(
|
||||
Attachment.BizType.GAO_CUSTOMER, customerIds, GaoCustomer.AttachType.PHOTO.name());
|
||||
records.forEach(record -> {
|
||||
GaoCustomer customer = customers.get(record.getCustomerId());
|
||||
if (customer != null) {
|
||||
customer.setAttachmentList(photos.getOrDefault(customer.getId(), List.of()));
|
||||
record.setCustomer(customer);
|
||||
}
|
||||
});
|
||||
}
|
||||
result.setList(records);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,14 @@ public class GaoRecyclePaymentService {
|
||||
return order.getRecycleRequiredQuantity() != null && 0 <= mapper.paid(order.getId()).compareTo(order.getRecycleRequiredQuantity());
|
||||
}
|
||||
|
||||
/// 查询单笔回收物支付记录
|
||||
public GaoRecyclePayment detail(String id) {
|
||||
GaoRecyclePayment payment = mapper.byId(id);
|
||||
TimiException.required(payment, "支付记录不存在");
|
||||
scope.checkStoreId(payment.getStoreId());
|
||||
return payment;
|
||||
}
|
||||
|
||||
/// 查询订单的回收物支付记录
|
||||
public List<GaoRecyclePayment> list(String orderId) {
|
||||
GaoSalesOrder order = orders.get(orderId);
|
||||
|
||||
@@ -10,4 +10,9 @@ import lombok.EqualsAndHashCode;
|
||||
public class GaoRecycleLedgerPage extends BasePage {
|
||||
private String storeId;
|
||||
private String customerId;
|
||||
private String recycleItemId;
|
||||
private String keyword;
|
||||
private String bizType;
|
||||
private Long beginAt;
|
||||
private Long endAt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user