Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b373cbbe46 | ||
|
|
bb5abcb48e | ||
|
|
acd97c7b9b | ||
|
|
4a549e77cb |
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||||
<artifactId>TimiServerAPI</artifactId>
|
<artifactId>TimiServerAPI</artifactId>
|
||||||
<version>1.0.31</version>
|
<version>1.0.33</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>TimiServerAPI</name>
|
<name>TimiServerAPI</name>
|
||||||
<description>imyeyu.com API</description>
|
<description>imyeyu.com API</description>
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||||
|
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoCustomerConsumptionRecordService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPage;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPageResult;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/// GAO 客户消费事实接口
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-09-07
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/gao/customer/consumption-record")
|
||||||
|
public class GaoCustomerConsumptionRecordController {
|
||||||
|
|
||||||
|
private final GaoCustomerConsumptionRecordService service;
|
||||||
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_READ)
|
||||||
|
@PostMapping("/list")
|
||||||
|
public GaoCustomerConsumptionRecordPageResult list(@RequestBody GaoCustomerConsumptionRecordPage page) {
|
||||||
|
TimiException.required(page, "not found consumption record page");
|
||||||
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
|
return service.pageByQuery(page);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.gao.entity;
|
package com.imyeyu.api.modules.gao.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -41,4 +42,8 @@ public class GaoCustomerConsumptionRecord extends UUIDEntity {
|
|||||||
private Long revokedAt;
|
private Long revokedAt;
|
||||||
private String revokeReason;
|
private String revokeReason;
|
||||||
private JsonNode sourcePayload;
|
private JsonNode sourcePayload;
|
||||||
|
|
||||||
|
/// 客户
|
||||||
|
@Transient
|
||||||
|
private GaoCustomer customer;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -1,6 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.gao.mapper;
|
package com.imyeyu.api.modules.gao.mapper;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPage;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@@ -16,5 +17,11 @@ public interface GaoCustomerConsumptionRecordMapper extends BaseMapper<GaoCustom
|
|||||||
|
|
||||||
List<GaoCustomerConsumptionRecord> selectActiveByWindow(@Param("storeId") String storeId, @Param("customerId") String customerId, @Param("beginAt") long beginAt, @Param("endAt") long endAt);
|
List<GaoCustomerConsumptionRecord> selectActiveByWindow(@Param("storeId") String storeId, @Param("customerId") String customerId, @Param("beginAt") long beginAt, @Param("endAt") long endAt);
|
||||||
|
|
||||||
|
long countByQuery(GaoCustomerConsumptionRecordPage page);
|
||||||
|
|
||||||
|
Long sumAmountByPage(GaoCustomerConsumptionRecordPage page);
|
||||||
|
|
||||||
|
List<GaoCustomerConsumptionRecord> selectByQuery(GaoCustomerConsumptionRecordPage page);
|
||||||
|
|
||||||
int revokeBySource(@Param("sourceType") GaoCustomerConsumptionRecord.SourceType sourceType, @Param("sourceId") String sourceId, @Param("revokedAt") long revokedAt, @Param("revokeReason") String revokeReason);
|
int revokeBySource(@Param("sourceType") GaoCustomerConsumptionRecord.SourceType sourceType, @Param("sourceId") String sourceId, @Param("revokedAt") long revokedAt, @Param("revokeReason") String revokeReason);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.gao.mapper;
|
|||||||
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem;
|
import com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -13,6 +14,12 @@ import java.util.List;
|
|||||||
/// @since 2026-08-31
|
/// @since 2026-08-31
|
||||||
public interface GaoPackageConfigItemMapper extends BaseMapper<GaoPackageConfigItem, String> {
|
public interface GaoPackageConfigItemMapper extends BaseMapper<GaoPackageConfigItem, String> {
|
||||||
|
|
||||||
|
/// 物理删除套餐配置的全部权益模板项
|
||||||
|
///
|
||||||
|
/// @param packageConfigId 套餐配置 ID
|
||||||
|
@Delete("DELETE FROM `gao_package_config_item` WHERE `package_config_id` = #{packageConfigId}")
|
||||||
|
void destroyByPackageConfigId(@Param("packageConfigId") String packageConfigId);
|
||||||
|
|
||||||
/// 按套餐配置 ID 查询产品
|
/// 按套餐配置 ID 查询产品
|
||||||
List<GaoPackageConfigItem> selectByPackageConfigId(@Param("packageConfigId") String packageConfigId);
|
List<GaoPackageConfigItem> selectByPackageConfigId(@Param("packageConfigId") String packageConfigId);
|
||||||
|
|
||||||
|
|||||||
+5
@@ -1,6 +1,8 @@
|
|||||||
package com.imyeyu.api.modules.gao.service;
|
package com.imyeyu.api.modules.gao.service;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPage;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPageResult;
|
||||||
import com.imyeyu.spring.service.BaseService;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -11,6 +13,9 @@ import java.util.List;
|
|||||||
/// @since 2026-09-04
|
/// @since 2026-09-04
|
||||||
public interface GaoCustomerConsumptionRecordService extends BaseService<GaoCustomerConsumptionRecord, String> {
|
public interface GaoCustomerConsumptionRecordService extends BaseService<GaoCustomerConsumptionRecord, String> {
|
||||||
|
|
||||||
|
/// 按条件分页查询消费事实
|
||||||
|
GaoCustomerConsumptionRecordPageResult pageByQuery(GaoCustomerConsumptionRecordPage page);
|
||||||
|
|
||||||
/// 写入销售订单消费事实
|
/// 写入销售订单消费事实
|
||||||
///
|
///
|
||||||
/// 幂等,重复执行返回已有事实
|
/// 幂等,重复执行返回已有事实
|
||||||
|
|||||||
+19
@@ -4,7 +4,10 @@ import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
|||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoCustomerConsumptionRecordMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoCustomerConsumptionRecordMapper;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoCustomerConsumptionRecordService;
|
import com.imyeyu.api.modules.gao.service.GaoCustomerConsumptionRecordService;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPage;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPageResult;
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
@@ -24,12 +27,28 @@ import java.util.List;
|
|||||||
public class GaoCustomerConsumptionRecordServiceImplement extends AbstractEntityService<GaoCustomerConsumptionRecord, String> implements GaoCustomerConsumptionRecordService {
|
public class GaoCustomerConsumptionRecordServiceImplement extends AbstractEntityService<GaoCustomerConsumptionRecord, String> implements GaoCustomerConsumptionRecordService {
|
||||||
|
|
||||||
private final GaoCustomerConsumptionRecordMapper mapper;
|
private final GaoCustomerConsumptionRecordMapper mapper;
|
||||||
|
private final GaoCustomerService customerService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseMapper<GaoCustomerConsumptionRecord, String> mapper() {
|
protected BaseMapper<GaoCustomerConsumptionRecord, String> mapper() {
|
||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GaoCustomerConsumptionRecordPageResult pageByQuery(GaoCustomerConsumptionRecordPage page) {
|
||||||
|
TimiException.required(page, "not found consumption record page");
|
||||||
|
GaoCustomerConsumptionRecordPageResult result = new GaoCustomerConsumptionRecordPageResult();
|
||||||
|
result.setTotal(mapper.countByQuery(page));
|
||||||
|
result.setAmountTotal(mapper.sumAmountByPage(page));
|
||||||
|
List<GaoCustomerConsumptionRecord> list = mapper.selectByQuery(page);
|
||||||
|
result.setList(list);
|
||||||
|
var customerMap = customerService.mapByIdList(list.stream().map(GaoCustomerConsumptionRecord::getCustomerId).toList());
|
||||||
|
for (GaoCustomerConsumptionRecord record : list) {
|
||||||
|
record.setCustomer(customerMap.get(record.getCustomerId()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public GaoCustomerConsumptionRecord createSalesOrder(String salesOrderId, String storeId, String customerId, Long amount, Long effectiveAt, GaoSalesOrder.OrderType orderType) {
|
public GaoCustomerConsumptionRecord createSalesOrder(String salesOrderId, String storeId, String customerId, Long amount, Long effectiveAt, GaoSalesOrder.OrderType orderType) {
|
||||||
|
|||||||
+4
-6
@@ -132,16 +132,14 @@ public class GaoPackageConfigServiceImplement extends AbstractEntityService<GaoP
|
|||||||
dbConfig.setEndAt(request.getEndAt());
|
dbConfig.setEndAt(request.getEndAt());
|
||||||
dbConfig.setSort(request.getSort());
|
dbConfig.setSort(request.getSort());
|
||||||
prepareConfig(dbConfig, dbConfig.getId());
|
prepareConfig(dbConfig, dbConfig.getId());
|
||||||
|
TimiException.required(request.getItemList(), "套餐至少配置一个产品");
|
||||||
|
verifyItems(dbConfig.getStoreId(), request.getItemList());
|
||||||
dbConfig.setUpdatedBy(userLoginService.getRequireLoginUserId());
|
dbConfig.setUpdatedBy(userLoginService.getRequireLoginUserId());
|
||||||
super.update(dbConfig);
|
super.update(dbConfig);
|
||||||
if (request.getItemList() != null) {
|
// 权益项仅是后续购买使用的套餐模板,历史订单已保存独立的订单明细快照
|
||||||
verifyItems(dbConfig.getStoreId(), request.getItemList());
|
itemMapper.destroyByPackageConfigId(dbConfig.getId());
|
||||||
GaoPackageConfigItem example = new GaoPackageConfigItem();
|
|
||||||
example.setPackageConfigId(dbConfig.getId());
|
|
||||||
itemMapper.deleteAllByExample(example);
|
|
||||||
saveItems(dbConfig.getId(), request.getItemList());
|
saveItems(dbConfig.getId(), request.getItemList());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.vo;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
||||||
|
import com.imyeyu.java.bean.BasePage;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/// GAO 客户消费事实分页请求
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-09-07
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class GaoCustomerConsumptionRecordPage extends BasePage {
|
||||||
|
|
||||||
|
/// 门店 ID
|
||||||
|
private String storeId;
|
||||||
|
|
||||||
|
/// 客户 ID
|
||||||
|
private String customerId;
|
||||||
|
|
||||||
|
/// 消费来源
|
||||||
|
private GaoCustomerConsumptionRecord.SourceType sourceType;
|
||||||
|
|
||||||
|
/// 消费状态
|
||||||
|
private GaoCustomerConsumptionRecord.Status status;
|
||||||
|
|
||||||
|
/// 起始生效时间
|
||||||
|
private Long beginAt;
|
||||||
|
|
||||||
|
/// 结束生效时间
|
||||||
|
private Long endAt;
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.vo;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
|
||||||
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/// GAO 客户消费事实分页查询结果
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-09-07
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class GaoCustomerConsumptionRecordPageResult extends PageResult<GaoCustomerConsumptionRecord> {
|
||||||
|
|
||||||
|
/// 当前筛选条件下的消费金额合计,单位分
|
||||||
|
private Long amountTotal;
|
||||||
|
}
|
||||||
@@ -12,6 +12,26 @@
|
|||||||
AND `effective_at` >= #{beginAt} AND `effective_at` <= #{endAt} AND `deleted_at` IS NULL
|
AND `effective_at` >= #{beginAt} AND `effective_at` <= #{endAt} AND `deleted_at` IS NULL
|
||||||
ORDER BY `effective_at` ASC, `id` ASC
|
ORDER BY `effective_at` ASC, `id` ASC
|
||||||
</select>
|
</select>
|
||||||
|
<sql id="pageWhere">
|
||||||
|
r.`deleted_at` IS NULL
|
||||||
|
<if test="storeId != null and storeId != ''">AND r.`store_id` = #{storeId}</if>
|
||||||
|
<if test="customerId != null and customerId != ''">AND r.`customer_id` = #{customerId}</if>
|
||||||
|
<if test="sourceType != null">AND r.`source_type` = #{sourceType}</if>
|
||||||
|
<if test="status != null">AND r.`status` = #{status}</if>
|
||||||
|
<if test="beginAt != null">AND r.`effective_at` >= #{beginAt}</if>
|
||||||
|
<if test="endAt != null">AND r.`effective_at` <= #{endAt}</if>
|
||||||
|
</sql>
|
||||||
|
<select id="countByQuery" resultType="long">
|
||||||
|
SELECT COUNT(1) FROM `gao_customer_consumption_record` r WHERE <include refid="pageWhere"/>
|
||||||
|
</select>
|
||||||
|
<select id="sumAmountByPage" resultType="long">
|
||||||
|
SELECT COALESCE(SUM(r.`amount`), 0) FROM `gao_customer_consumption_record` r WHERE <include refid="pageWhere"/>
|
||||||
|
</select>
|
||||||
|
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord">
|
||||||
|
SELECT r.* FROM `gao_customer_consumption_record` r WHERE <include refid="pageWhere"/>
|
||||||
|
ORDER BY r.`effective_at` DESC, r.`created_at` DESC
|
||||||
|
LIMIT #{offset}, #{limit}
|
||||||
|
</select>
|
||||||
<update id="revokeBySource">
|
<update id="revokeBySource">
|
||||||
UPDATE `gao_customer_consumption_record`
|
UPDATE `gao_customer_consumption_record`
|
||||||
SET `status` = 'REVOKED', `revoked_at` = #{revokedAt}, `revoke_reason` = #{revokeReason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
SET `status` = 'REVOKED', `revoked_at` = #{revokedAt}, `revoke_reason` = #{revokeReason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||||
|
|||||||
Reference in New Issue
Block a user