Commit 66cdf4ca4ce0100bb32da9c689f5d5dae00b58aa
Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
Showing
45 changed files
with
110 additions
and
214 deletions
yudao-framework/yudao-spring-boot-starter-biz-ip/src/main/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtils.java
| ... | ... | @@ -132,7 +132,9 @@ public class AreaUtils { |
| 132 | 132 | return convertList(areas.values(), func, area -> type.getType().equals(area.getType())); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | + // TODO @疯狂:注释写下; | |
| 135 | 136 | public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) { |
| 137 | + // TODO @疯狂:这种不要用 while true;因为万一脏数据,可能会死循环;可以转换成 for (int i = 0; i < Byte.MAX; i++) 一般是优先层级; | |
| 136 | 138 | do { |
| 137 | 139 | Area area = AreaUtils.getArea(id); |
| 138 | 140 | if (area == null) { | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| ... | ... | @@ -6,8 +6,6 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidate |
| 6 | 6 | |
| 7 | 7 | import javax.validation.Valid; |
| 8 | 8 | |
| 9 | -// TODO @芋艿:后面也再撸撸这几个接口 | |
| 10 | - | |
| 11 | 9 | /** |
| 12 | 10 | * 拼团记录 API 接口 |
| 13 | 11 | * |
| ... | ... | @@ -30,7 +28,7 @@ public interface CombinationRecordApi { |
| 30 | 28 | * 创建开团记录 |
| 31 | 29 | * |
| 32 | 30 | * @param reqDTO 请求 DTO |
| 33 | - * @return key 开团记录编号 value 团长编号 | |
| 31 | + * @return key 开团记录编号、value 团长编号 | |
| 34 | 32 | */ |
| 35 | 33 | KeyValue<Long, Long> createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); |
| 36 | 34 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
| ... | ... | @@ -29,6 +29,7 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { |
| 29 | 29 | recordService.validateCombinationRecord(userId, activityId, headId, skuId, count); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | + // TODO @puhui999:搞个创建的 RespDTO 哈; | |
| 32 | 33 | @Override |
| 33 | 34 | public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 34 | 35 | return recordService.createCombinationRecord(reqDTO); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java
| ... | ... | @@ -40,6 +40,9 @@ public class CombinationRecordController { |
| 40 | 40 | @Lazy |
| 41 | 41 | private CombinationRecordService combinationRecordService; |
| 42 | 42 | |
| 43 | + // TODO @puhui999:getBargainRecordPage 和 getBargainRecordPage 是不是可以合并;然后 CombinationRecordReqPageVO 加一个 headId; | |
| 44 | + // 然后如果 headId 非空,并且第一页,单独多查询一条 head ;放到第 0 个位置;相当于说,第一页特殊一点; | |
| 45 | + | |
| 43 | 46 | @GetMapping("/page") |
| 44 | 47 | @Operation(summary = "获得拼团记录分页") |
| 45 | 48 | @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") |
| ... | ... | @@ -47,6 +50,7 @@ public class CombinationRecordController { |
| 47 | 50 | PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO); |
| 48 | 51 | List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( |
| 49 | 52 | convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); |
| 53 | + // TODO @puhui999:商品没读取 | |
| 50 | 54 | return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities)); |
| 51 | 55 | } |
| 52 | 56 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java
| ... | ... | @@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.Operation; |
| 27 | 27 | import io.swagger.v3.oas.annotations.Parameter; |
| 28 | 28 | import io.swagger.v3.oas.annotations.Parameters; |
| 29 | 29 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 30 | -import org.springframework.context.annotation.Lazy; | |
| 31 | 30 | import org.springframework.validation.annotation.Validated; |
| 32 | 31 | import org.springframework.web.bind.annotation.*; |
| 33 | 32 | |
| ... | ... | @@ -49,20 +48,15 @@ public class AppBargainRecordController { |
| 49 | 48 | @Resource |
| 50 | 49 | private BargainHelpService bargainHelpService; |
| 51 | 50 | @Resource |
| 52 | - @Lazy | |
| 53 | 51 | private BargainRecordService bargainRecordService; |
| 54 | 52 | @Resource |
| 55 | - @Lazy | |
| 56 | 53 | private BargainActivityService bargainActivityService; |
| 57 | 54 | |
| 58 | - | |
| 59 | 55 | @Resource |
| 60 | 56 | private TradeOrderApi tradeOrderApi; |
| 61 | 57 | @Resource |
| 62 | - @Lazy | |
| 63 | 58 | private MemberUserApi memberUserApi; |
| 64 | 59 | @Resource |
| 65 | - @Lazy | |
| 66 | 60 | private ProductSpuApi productSpuApi; |
| 67 | 61 | |
| 68 | 62 | @GetMapping("/get-summary") | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| ... | ... | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityD |
| 9 | 9 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 10 | 10 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 11 | 11 | import org.apache.ibatis.annotations.Mapper; |
| 12 | -import org.apache.ibatis.annotations.Param; | |
| 13 | 12 | |
| 14 | 13 | import java.time.LocalDateTime; |
| 15 | 14 | import java.util.Collection; |
| ... | ... | @@ -87,6 +86,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { |
| 87 | 86 | .last("LIMIT " + count)); |
| 88 | 87 | } |
| 89 | 88 | |
| 89 | + // TODO @puhui999:是不是返回 BargainActivityDO 更干净哈? | |
| 90 | 90 | /** |
| 91 | 91 | * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 |
| 92 | 92 | * |
| ... | ... | @@ -94,7 +94,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { |
| 94 | 94 | * @param status 状态 |
| 95 | 95 | * @return 包含 spuId 和 activityId 的 map 对象列表 |
| 96 | 96 | */ |
| 97 | - default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection<Long> spuIds, @Param("status") Integer status) { | |
| 97 | + default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) { | |
| 98 | 98 | return selectMaps(new QueryWrapper<BargainActivityDO>() |
| 99 | 99 | .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id |
| 100 | 100 | .in("spu_id", spuIds) | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| ... | ... | @@ -120,6 +120,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 120 | 120 | */ |
| 121 | 121 | default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { |
| 122 | 122 | return selectCount(new QueryWrapper<CombinationRecordDO>() |
| 123 | + // TODO @puhui999:这种偏逻辑性的,不要给 mapper 哈;可以考虑拆成 2 个 mapper,上层也是 2 个 service; | |
| 123 | 124 | .select(status == null && virtualGroup == null && headId == null, "DISTINCT (user_id)") |
| 124 | 125 | .eq(status != null, "status", status) |
| 125 | 126 | .eq(virtualGroup != null, "virtual_group", virtualGroup) | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java
| ... | ... | @@ -22,7 +22,7 @@ public class CombinationRecordExpireJob implements JobHandler { |
| 22 | 22 | |
| 23 | 23 | @Override |
| 24 | 24 | @TenantJob |
| 25 | - public String execute(String param) throws Exception { | |
| 25 | + public String execute(String param) { | |
| 26 | 26 | KeyValue<Integer, Integer> keyValue = combinationRecordService.expireCombinationRecord(); |
| 27 | 27 | return StrUtil.format("过期拼团 {} 个, 虚拟成团 {} 个", keyValue.getKey(), keyValue.getValue()); |
| 28 | 28 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
| ... | ... | @@ -94,7 +94,6 @@ public class BargainActivityServiceImpl implements BargainActivityService { |
| 94 | 94 | } else if (count > 0) { |
| 95 | 95 | bargainActivityMapper.updateStock(id, count); |
| 96 | 96 | } |
| 97 | - | |
| 98 | 97 | } |
| 99 | 98 | |
| 100 | 99 | private void validateBargainConflict(Long spuId, Long activityId) { |
| ... | ... | @@ -184,12 +183,13 @@ public class BargainActivityServiceImpl implements BargainActivityService { |
| 184 | 183 | |
| 185 | 184 | @Override |
| 186 | 185 | public List<BargainActivityDO> getBargainActivityBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) { |
| 187 | - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 | |
| 186 | + // 1. 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 | |
| 187 | + // TODO @puhui999:我想了下,这种是不是只展示当前正在进行中的。已经结束、或者未开始的,可能没啥意义? | |
| 188 | 188 | List<Map<String, Object>> spuIdAndActivityIdMaps = bargainActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); |
| 189 | 189 | if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { |
| 190 | 190 | return Collections.emptyList(); |
| 191 | 191 | } |
| 192 | - // 2.查询活动详情 | |
| 192 | + // 2. 查询活动详情 | |
| 193 | 193 | return bargainActivityMapper.selectListByIds(convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId"))); |
| 194 | 194 | } |
| 195 | 195 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| ... | ... | @@ -146,7 +146,6 @@ public interface CombinationRecordService { |
| 146 | 146 | */ |
| 147 | 147 | PageResult<CombinationRecordDO> getCombinationRecordPage2(CombinationRecordReqPage2VO pageVO); |
| 148 | 148 | |
| 149 | - | |
| 150 | 149 | /** |
| 151 | 150 | * 【拼团活动】获得拼团记录数量 Map |
| 152 | 151 | * |
| ... | ... | @@ -159,7 +158,6 @@ public interface CombinationRecordService { |
| 159 | 158 | @Nullable Integer status, |
| 160 | 159 | @Nullable Long headId); |
| 161 | 160 | |
| 162 | - | |
| 163 | 161 | /** |
| 164 | 162 | * 获取拼团记录 |
| 165 | 163 | * | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -23,7 +23,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR |
| 23 | 23 | import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; |
| 24 | 24 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 25 | 25 | import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; |
| 26 | -import org.springframework.context.annotation.Lazy; | |
| 27 | 26 | import org.springframework.scheduling.annotation.Async; |
| 28 | 27 | import org.springframework.stereotype.Service; |
| 29 | 28 | import org.springframework.transaction.annotation.Transactional; |
| ... | ... | @@ -52,7 +51,6 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 52 | 51 | public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 53 | 52 | |
| 54 | 53 | @Resource |
| 55 | - @Lazy | |
| 56 | 54 | private CombinationActivityService combinationActivityService; |
| 57 | 55 | @Resource |
| 58 | 56 | private CombinationRecordMapper combinationRecordMapper; |
| ... | ... | @@ -60,16 +58,13 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 60 | 58 | @Resource |
| 61 | 59 | private MemberUserApi memberUserApi; |
| 62 | 60 | @Resource |
| 63 | - @Lazy | |
| 64 | 61 | private ProductSpuApi productSpuApi; |
| 65 | 62 | @Resource |
| 66 | - @Lazy | |
| 67 | 63 | private ProductSkuApi productSkuApi; |
| 68 | 64 | |
| 69 | 65 | @Resource |
| 70 | 66 | private TradeOrderApi tradeOrderApi; |
| 71 | 67 | |
| 72 | - // TODO @芋艿:在详细预览下; | |
| 73 | 68 | @Override |
| 74 | 69 | @Transactional(rollbackFor = Exception.class) |
| 75 | 70 | public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) { |
| ... | ... | @@ -77,6 +72,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 77 | 72 | CombinationRecordDO record = validateCombinationRecord(userId, orderId); |
| 78 | 73 | |
| 79 | 74 | // 更新状态 |
| 75 | + // TODO @puhui999:不要整个更新,new 一个出来;why?例如说,两个线程都去更新,这样存在相互覆盖的问题 | |
| 80 | 76 | record.setStatus(status); |
| 81 | 77 | combinationRecordMapper.updateById(record); |
| 82 | 78 | } |
| ... | ... | @@ -169,16 +165,16 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 169 | 165 | @Override |
| 170 | 166 | @Transactional(rollbackFor = Exception.class) |
| 171 | 167 | public KeyValue<Long, Long> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 172 | - // 1.校验拼团活动 | |
| 168 | + // 1. 校验拼团活动 | |
| 173 | 169 | KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(), |
| 174 | 170 | reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); |
| 175 | 171 | |
| 176 | - // 2.组合数据创建拼团记录 | |
| 172 | + // 2. 组合数据创建拼团记录 | |
| 177 | 173 | MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()); |
| 178 | 174 | ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()); |
| 179 | 175 | ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); |
| 180 | 176 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku); |
| 181 | - // 2.1.如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP | |
| 177 | + // 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP | |
| 182 | 178 | if (record.getHeadId() == null) { |
| 183 | 179 | record.setStartTime(LocalDateTime.now()) |
| 184 | 180 | .setExpireTime(keyValue.getKey().getStartTime().plusHours(keyValue.getKey().getLimitDuration())) |
| ... | ... | @@ -191,12 +187,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 191 | 187 | } |
| 192 | 188 | combinationRecordMapper.insert(record); |
| 193 | 189 | |
| 194 | - if (ObjUtil.equal(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { | |
| 195 | - return new KeyValue<>(record.getId(), record.getHeadId()); | |
| 190 | + // 3. 更新拼团记录 | |
| 191 | + if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { | |
| 192 | + updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); | |
| 196 | 193 | } |
| 197 | - | |
| 198 | - // 3、更新拼团记录 | |
| 199 | - updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); | |
| 200 | 194 | return new KeyValue<>(record.getId(), record.getHeadId()); |
| 201 | 195 | } |
| 202 | 196 | |
| ... | ... | @@ -349,6 +343,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 349 | 343 | |
| 350 | 344 | @Override |
| 351 | 345 | public KeyValue<Integer, Integer> expireCombinationRecord() { |
| 346 | + // TODO @puhui999:数字一般是 1. 2. 这种格式哈 | |
| 352 | 347 | // 1。获取所有正在进行中的过期的父拼团 |
| 353 | 348 | List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( |
| 354 | 349 | CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); |
| ... | ... | @@ -356,18 +351,21 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 356 | 351 | return new KeyValue<>(0, 0); |
| 357 | 352 | } |
| 358 | 353 | |
| 359 | - // 2.获取拼团活动 | |
| 354 | + // 2. 获取拼团活动 | |
| 355 | + // TODO @puhui999:在自己模块里,变量可以简略点;例如说 activityList | |
| 360 | 356 | List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityListByIds( |
| 361 | 357 | convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); |
| 362 | 358 | Map<Long, CombinationActivityDO> activityMap = convertMap(combinationActivities, CombinationActivityDO::getId); |
| 363 | 359 | |
| 364 | - // 3.校验是否虚拟成团 | |
| 360 | + // TODO @puhui999:job 一般不建议异步跑;因为可能下次跑,结果上次还没跑完; | |
| 361 | + // TODO 这里,我们可以每个 record 处理下;然后按照是否需要虚拟拼团,各搞一个方法逻辑 + 事务;这样,保证 job 里面尽量不要大事务,而是 n 个独立小事务的处理。 | |
| 362 | + // 3. 校验是否虚拟成团 | |
| 365 | 363 | List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 |
| 366 | 364 | for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { |
| 367 | 365 | CombinationRecordDO record = iterator.next(); |
| 368 | 366 | // 3.1 不匹配,则直接跳过 |
| 369 | - CombinationActivityDO activityDO = activityMap.get(record.getActivityId()); | |
| 370 | - if (activityDO == null || !activityDO.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 | |
| 367 | + CombinationActivityDO activity = activityMap.get(record.getActivityId()); | |
| 368 | + if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 | |
| 371 | 369 | continue; |
| 372 | 370 | } |
| 373 | 371 | // 3.2 匹配,则移除,添加到虚拟成团中,并结束寻找 |
| ... | ... | @@ -380,7 +378,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 380 | 378 | getSelf().handleExpireRecord(headExpireRecords); |
| 381 | 379 | // 5.虚拟成团 |
| 382 | 380 | getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords); |
| 383 | - | |
| 384 | 381 | return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size()); |
| 385 | 382 | } |
| 386 | 383 | |
| ... | ... | @@ -401,7 +398,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 401 | 398 | headsAndRecords.forEach(item -> { |
| 402 | 399 | tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()); |
| 403 | 400 | }); |
| 404 | - | |
| 405 | 401 | } |
| 406 | 402 | |
| 407 | 403 | @Async |
| ... | ... | @@ -410,9 +406,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 410 | 406 | return; |
| 411 | 407 | } |
| 412 | 408 | |
| 413 | - // 1.团员补齐 | |
| 409 | + // 1. 团员补齐 | |
| 414 | 410 | combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords)); |
| 415 | - // 2.更新拼团记录 | |
| 411 | + // 2. 更新拼团记录 | |
| 416 | 412 | updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS); |
| 417 | 413 | } |
| 418 | 414 | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java
| ... | ... | @@ -7,15 +7,17 @@ import org.apache.ibatis.annotations.Param; |
| 7 | 7 | import java.time.LocalDateTime; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * API 访问日志统计 Mapper | |
| 10 | + * API 访问日志的统计 Mapper | |
| 11 | 11 | * |
| 12 | 12 | * @author owen |
| 13 | 13 | */ |
| 14 | 14 | @Mapper |
| 15 | 15 | public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> { |
| 16 | 16 | |
| 17 | - Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); | |
| 17 | + Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, | |
| 18 | + @Param("endTime") LocalDateTime endTime); | |
| 18 | 19 | |
| 19 | - Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); | |
| 20 | + Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, | |
| 21 | + @Param("endTime") LocalDateTime endTime); | |
| 20 | 22 | |
| 21 | 23 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java
| ... | ... | @@ -10,7 +10,7 @@ import java.time.LocalDateTime; |
| 10 | 10 | import java.util.List; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * 会员统计 Mapper | |
| 13 | + * 会员信息的统计 Mapper | |
| 14 | 14 | * |
| 15 | 15 | * @author owen |
| 16 | 16 | */ |
| ... | ... | @@ -21,6 +21,7 @@ public interface MemberStatisticsMapper extends BaseMapperX<Object> { |
| 21 | 21 | |
| 22 | 22 | List<MemberSexStatisticsRespVO> selectSummaryListBySex(); |
| 23 | 23 | |
| 24 | - Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); | |
| 24 | + Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, | |
| 25 | + @Param("endTime") LocalDateTime endTime); | |
| 25 | 26 | |
| 26 | 27 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java
| ... | ... | @@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Param; |
| 10 | 10 | import java.time.LocalDateTime; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * 交易统计 Mapper | |
| 13 | + * 支付钱包的统计 Mapper | |
| 14 | 14 | * |
| 15 | 15 | * @author owen |
| 16 | 16 | */ |
| ... | ... | @@ -29,6 +29,7 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO |
| 29 | 29 | @Param("endTime") LocalDateTime endTime, |
| 30 | 30 | @Param("bizType") Integer bizType); |
| 31 | 31 | |
| 32 | + // TODO @疯狂:是不是搞个单独的 BO 呀; | |
| 32 | 33 | MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, |
| 33 | 34 | @Param("endTime") LocalDateTime endTime, |
| 34 | 35 | @Param("payStatus") Boolean payStatus); | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java
| ... | ... | @@ -19,6 +19,7 @@ import java.util.List; |
| 19 | 19 | @Mapper |
| 20 | 20 | public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { |
| 21 | 21 | |
| 22 | + // TODO @疯狂:这个要不要也挪到 xml 里,保持统一? | |
| 22 | 23 | @Select("SELECT IFNULL(SUM(order_create_count), 0) AS count, IFNULL(SUM(order_pay_price), 0) AS summary " + |
| 23 | 24 | "FROM trade_statistics " + |
| 24 | 25 | "WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE") |
| ... | ... | @@ -33,4 +34,5 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { |
| 33 | 34 | |
| 34 | 35 | Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 35 | 36 | @Param("endTime") LocalDateTime endTime); |
| 37 | + | |
| 36 | 38 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java
| ... | ... | @@ -12,7 +12,7 @@ import javax.annotation.Resource; |
| 12 | 12 | import java.time.LocalDateTime; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * 钱包统计 Service 实现类 | |
| 15 | + * 钱包的统计 Service 实现类 | |
| 16 | 16 | * |
| 17 | 17 | * @author owen |
| 18 | 18 | */ |
| ... | ... | @@ -31,11 +31,10 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic |
| 31 | 31 | beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus()); |
| 32 | 32 | Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( |
| 33 | 33 | beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); |
| 34 | - | |
| 35 | - paySummary.setOrderWalletPayPrice(walletPayPrice); | |
| 36 | - paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount()); | |
| 37 | - paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); | |
| 38 | - | |
| 34 | + // 拼接 | |
| 35 | + paySummary.setOrderWalletPayPrice(walletPayPrice) | |
| 36 | + .setRechargeRefundCount(refundSummary.getRechargeRefundCount()) | |
| 37 | + .setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); | |
| 39 | 38 | return paySummary; |
| 40 | 39 | } |
| 41 | 40 | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java
| ... | ... | @@ -45,16 +45,15 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 45 | 45 | |
| 46 | 46 | @Override |
| 47 | 47 | public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() { |
| 48 | - // 昨天的数据 | |
| 48 | + // 1.1 昨天的数据 | |
| 49 | 49 | TradeSummaryRespBO yesterdayData = getTradeSummaryByDays(-1); |
| 50 | - // 前天的数据(用于对照昨天的数据) | |
| 50 | + // 1.2 前天的数据(用于对照昨天的数据) | |
| 51 | 51 | TradeSummaryRespBO beforeYesterdayData = getTradeSummaryByDays(-2); |
| 52 | - | |
| 53 | - // 本月数据; | |
| 52 | + // 2.1 本月数据 | |
| 54 | 53 | TradeSummaryRespBO monthData = getTradeSummaryByMonths(0); |
| 55 | - // 上月数据(用于对照本月的数据) | |
| 54 | + // 2.2 上月数据(用于对照本月的数据) | |
| 56 | 55 | TradeSummaryRespBO lastMonthData = getTradeSummaryByMonths(-1); |
| 57 | - | |
| 56 | + // 转换返回 | |
| 58 | 57 | return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData); |
| 59 | 58 | } |
| 60 | 59 | |
| ... | ... | @@ -81,31 +80,31 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 81 | 80 | |
| 82 | 81 | @Override |
| 83 | 82 | public String statisticsYesterdayTrade() { |
| 84 | - // 处理统计参数 | |
| 85 | 83 | LocalDateTime yesterday = LocalDateTime.now().minusDays(1); |
| 86 | 84 | LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); |
| 87 | 85 | LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); |
| 88 | - // 统计 | |
| 86 | + // 1.1 统计订单 | |
| 89 | 87 | StopWatch stopWatch = new StopWatch("交易统计"); |
| 90 | 88 | stopWatch.start("统计订单"); |
| 91 | 89 | TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); |
| 92 | 90 | stopWatch.stop(); |
| 93 | - | |
| 91 | + // 1.2 统计售后 | |
| 94 | 92 | stopWatch.start("统计售后"); |
| 95 | 93 | AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); |
| 96 | 94 | stopWatch.stop(); |
| 97 | - | |
| 95 | + // 1.3 统计佣金 | |
| 98 | 96 | stopWatch.start("统计佣金"); |
| 99 | 97 | Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); |
| 100 | 98 | stopWatch.stop(); |
| 101 | - | |
| 99 | + // 1.4 统计充值 | |
| 102 | 100 | stopWatch.start("统计充值"); |
| 103 | 101 | WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); |
| 104 | 102 | stopWatch.stop(); |
| 105 | - // 插入数据 | |
| 106 | - TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary); | |
| 103 | + | |
| 104 | + // 2. 插入数据 | |
| 105 | + TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, | |
| 106 | + brokerageSettlementPrice, walletSummary); | |
| 107 | 107 | tradeStatisticsMapper.insert(entity); |
| 108 | - // 返回计时结果 | |
| 109 | 108 | return stopWatch.prettyPrint(); |
| 110 | 109 | } |
| 111 | 110 | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper"> |
| 4 | + | |
| 4 | 5 | <select id="selectCountByIp" resultType="java.lang.Integer"> |
| 5 | 6 | SELECT COUNT(1) |
| 6 | 7 | FROM infra_api_access_log |
| 7 | - WHERE deleted = FALSE | |
| 8 | - AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 8 | + WHERE create_time BETWEEN #{beginTime} AND #{endTime} | |
| 9 | + AND deleted = FALSE | |
| 9 | 10 | GROUP BY user_ip |
| 10 | 11 | </select> |
| 11 | 12 | |
| 12 | 13 | <select id="selectCountByUserId" resultType="java.lang.Integer"> |
| 13 | 14 | SELECT COUNT(1) |
| 14 | 15 | FROM infra_api_access_log |
| 15 | - WHERE user_id != 0 | |
| 16 | - AND deleted = FALSE | |
| 16 | + WHERE user_id > 0 | |
| 17 | 17 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 18 | + AND deleted = FALSE | |
| 18 | 19 | GROUP BY user_id |
| 19 | 20 | </select> |
| 21 | + | |
| 20 | 22 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | FROM member_user |
| 9 | 9 | WHERE deleted = FALSE |
| 10 | 10 | GROUP BY area_id |
| 11 | + <!-- TODO @疯狂:order by 是不是交给内存哈 --> | |
| 11 | 12 | ORDER BY userCount DESC |
| 12 | 13 | </select> |
| 13 | 14 | |
| ... | ... | @@ -17,6 +18,7 @@ |
| 17 | 18 | FROM member_user |
| 18 | 19 | WHERE deleted = FALSE |
| 19 | 20 | GROUP BY sex |
| 21 | + <!-- TODO @疯狂:order by 是不是交给内存哈 --> | |
| 20 | 22 | ORDER BY userCount DESC |
| 21 | 23 | </select> |
| 22 | 24 | |
| ... | ... | @@ -31,4 +33,5 @@ |
| 31 | 33 | AND create_time <= #{endTime} |
| 32 | 34 | </if> |
| 33 | 35 | </select> |
| 34 | -</mapper> | |
| 35 | 36 | \ No newline at end of file |
| 37 | + | |
| 38 | +</mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | SUM(pay_price) AS rechargePayPrice |
| 8 | 8 | FROM pay_wallet_recharge |
| 9 | 9 | WHERE pay_status = #{payStatus} |
| 10 | - AND deleted = FALSE | |
| 11 | 10 | AND pay_time BETWEEN #{beginTime} AND #{endTime} |
| 11 | + AND deleted = FALSE | |
| 12 | 12 | </select> |
| 13 | 13 | |
| 14 | 14 | <select id="selectRechargeSummaryByRefundTimeBetween" |
| ... | ... | @@ -17,16 +17,16 @@ |
| 17 | 17 | SUM(pay_price) AS rechargeRefundPrice |
| 18 | 18 | FROM pay_wallet_recharge |
| 19 | 19 | WHERE refund_status = #{refundStatus} |
| 20 | - AND deleted = FALSE | |
| 21 | 20 | AND refund_time BETWEEN #{beginTime} AND #{endTime} |
| 21 | + AND deleted = FALSE | |
| 22 | 22 | </select> |
| 23 | 23 | |
| 24 | 24 | <select id="selectPriceSummaryByBizTypeAndCreateTimeBetween" resultType="java.lang.Integer"> |
| 25 | 25 | SELECT SUM(price) |
| 26 | 26 | FROM pay_wallet_transaction |
| 27 | 27 | WHERE biz_type = #{bizType} |
| 28 | - AND deleted = FALSE | |
| 29 | 28 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 29 | + AND deleted = FALSE | |
| 30 | 30 | </select> |
| 31 | 31 | |
| 32 | 32 | <select id="selectRechargeSummaryGroupByWalletId" |
| ... | ... | @@ -35,13 +35,14 @@ |
| 35 | 35 | SUM(pay_price) AS rechargePrice |
| 36 | 36 | FROM pay_wallet_recharge |
| 37 | 37 | WHERE pay_status = #{payStatus} |
| 38 | - AND deleted = FALSE | |
| 39 | 38 | <if test="beginTime != null"> |
| 40 | 39 | AND pay_time >= #{beginTime} |
| 41 | 40 | </if> |
| 42 | 41 | <if test="endTime != null"> |
| 43 | 42 | AND pay_time <= #{endTime} |
| 44 | 43 | </if> |
| 44 | + AND deleted = FALSE | |
| 45 | 45 | GROUP BY wallet_id |
| 46 | 46 | </select> |
| 47 | + | |
| 47 | 48 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper"> |
| 4 | + | |
| 4 | 5 | <select id="selectSummaryByRefundTimeBetween" |
| 5 | 6 | resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO"> |
| 6 | 7 | SELECT COUNT(1) AS afterSaleCount, |
| 7 | 8 | SUM(refund_price) AS afterSaleRefundPrice |
| 8 | 9 | FROM trade_after_sale |
| 9 | - WHERE deleted = FALSE | |
| 10 | - AND refund_time BETWEEN #{beginTime} AND #{endTime} | |
| 10 | + WHERE refund_time BETWEEN #{beginTime} AND #{endTime} | |
| 11 | + AND deleted = FALSE | |
| 11 | 12 | </select> |
| 13 | + | |
| 12 | 14 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper"> |
| 4 | + | |
| 4 | 5 | <select id="selectSummaryPriceByStatusAndUnfreezeTimeBetween" resultType="java.lang.Integer"> |
| 5 | 6 | SELECT SUM(price) |
| 6 | 7 | FROM trade_brokerage_record |
| 7 | 8 | WHERE biz_type = #{bizType} |
| 8 | 9 | AND status = #{status} |
| 9 | - AND deleted = FALSE | |
| 10 | 10 | AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} |
| 11 | + AND deleted = FALSE | |
| 11 | 12 | </select> |
| 13 | + | |
| 12 | 14 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper"> |
| 4 | + | |
| 4 | 5 | <select id="selectSummaryListByAreaId" |
| 5 | 6 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> |
| 6 | 7 | SELECT receiver_area_id AS areaId, |
| ... | ... | @@ -33,25 +34,25 @@ |
| 33 | 34 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> |
| 34 | 35 | SELECT COUNT(1) |
| 35 | 36 | FROM trade_order |
| 36 | - WHERE deleted = FALSE | |
| 37 | + WHERE pay_time BETWEEN #{beginTime} AND #{endTime} | |
| 37 | 38 | AND pay_status = TRUE |
| 38 | - AND pay_time BETWEEN #{beginTime} AND #{endTime} | |
| 39 | + AND deleted = FALSE | |
| 39 | 40 | GROUP BY user_id |
| 40 | 41 | </select> |
| 41 | 42 | |
| 42 | 43 | <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> |
| 43 | 44 | SELECT COUNT(1) |
| 44 | 45 | FROM trade_order |
| 45 | - WHERE deleted = FALSE | |
| 46 | - AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 46 | + WHERE create_time BETWEEN #{beginTime} AND #{endTime} | |
| 47 | + AND deleted = FALSE | |
| 47 | 48 | </select> |
| 48 | 49 | |
| 49 | 50 | <select id="selectCountByPayTimeBetween" resultType="java.lang.Integer"> |
| 50 | 51 | SELECT COUNT(1) |
| 51 | 52 | FROM trade_order |
| 52 | 53 | WHERE pay_status = TRUE |
| 53 | - AND deleted = FALSE | |
| 54 | 54 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 55 | + AND deleted = FALSE | |
| 55 | 56 | </select> |
| 56 | 57 | |
| 57 | 58 | <select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer"> |
| ... | ... | @@ -61,4 +62,5 @@ |
| 61 | 62 | AND deleted = FALSE |
| 62 | 63 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 63 | 64 | </select> |
| 65 | + | |
| 64 | 66 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper"> |
| 4 | + | |
| 4 | 5 | <select id="selectByTimeBetween" |
| 5 | 6 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> |
| 6 | 7 | SELECT |
| ... | ... | @@ -48,4 +49,5 @@ |
| 48 | 49 | AND time <= #{endTime} |
| 49 | 50 | </if> |
| 50 | 51 | </select> |
| 52 | + | |
| 51 | 53 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java deleted
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java deleted
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java
| ... | ... | @@ -28,16 +28,7 @@ public interface TradeOrderApi { |
| 28 | 28 | */ |
| 29 | 29 | TradeOrderRespDTO getOrder(Long id); |
| 30 | 30 | |
| 31 | - /** | |
| 32 | - * 更新拼团相关信息到订单 | |
| 33 | - * | |
| 34 | - * @param orderId 订单编号 | |
| 35 | - * @param activityId 拼团活动编号 | |
| 36 | - * @param combinationRecordId 拼团记录编号 | |
| 37 | - * @param headId 团长编号 | |
| 38 | - */ | |
| 39 | - void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId); | |
| 40 | - | |
| 31 | + // TODO 芋艿:需要优化下; | |
| 41 | 32 | /** |
| 42 | 33 | * 取消支付订单 |
| 43 | 34 | * | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.api.aftersale; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; | |
| 4 | -import org.springframework.stereotype.Service; | |
| 5 | -import org.springframework.validation.annotation.Validated; | |
| 6 | - | |
| 7 | -import javax.annotation.Resource; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 售后 API 接口实现类 | |
| 11 | - * | |
| 12 | - * @author owen | |
| 13 | - */ | |
| 14 | -@Service | |
| 15 | -@Validated | |
| 16 | -public class TradeAfterSaleApiImpl implements TradeAfterSaleApi { | |
| 17 | - | |
| 18 | - @Resource | |
| 19 | - private AfterSaleService afterSaleService; | |
| 20 | - | |
| 21 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.api.brokerage; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; | |
| 4 | -import org.springframework.stereotype.Service; | |
| 5 | -import org.springframework.validation.annotation.Validated; | |
| 6 | - | |
| 7 | -import javax.annotation.Resource; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 订单 API 接口实现类 | |
| 11 | - * | |
| 12 | - * @author HUIHUI | |
| 13 | - */ | |
| 14 | -@Service | |
| 15 | -@Validated | |
| 16 | -public class TradeBrokerageApiImpl implements TradeBrokerageApi { | |
| 17 | - | |
| 18 | - @Resource | |
| 19 | - private BrokerageRecordService brokerageRecordService; | |
| 20 | - | |
| 21 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java
| ... | ... | @@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.trade.api.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; |
| 4 | 4 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 5 | -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | |
| 6 | 5 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| 7 | 6 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; |
| 8 | -import org.springframework.context.annotation.Lazy; | |
| 9 | 7 | import org.springframework.stereotype.Service; |
| 10 | 8 | import org.springframework.validation.annotation.Validated; |
| 11 | 9 | |
| ... | ... | @@ -13,9 +11,6 @@ import javax.annotation.Resource; |
| 13 | 11 | import java.util.Collection; |
| 14 | 12 | import java.util.List; |
| 15 | 13 | |
| 16 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 17 | -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; | |
| 18 | - | |
| 19 | 14 | /** |
| 20 | 15 | * 订单 API 接口实现类 |
| 21 | 16 | * |
| ... | ... | @@ -28,7 +23,6 @@ public class TradeOrderApiImpl implements TradeOrderApi { |
| 28 | 23 | @Resource |
| 29 | 24 | private TradeOrderUpdateService tradeOrderUpdateService; |
| 30 | 25 | @Resource |
| 31 | - @Lazy | |
| 32 | 26 | private TradeOrderQueryService tradeOrderQueryService; |
| 33 | 27 | |
| 34 | 28 | @Override |
| ... | ... | @@ -42,11 +36,6 @@ public class TradeOrderApiImpl implements TradeOrderApi { |
| 42 | 36 | } |
| 43 | 37 | |
| 44 | 38 | @Override |
| 45 | - public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) { | |
| 46 | - tradeOrderUpdateService.updateOrderCombinationInfo(orderId, activityId, combinationRecordId, headId); | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | 39 | public void cancelPaidOrder(Long userId, Long orderId) { |
| 51 | 40 | tradeOrderUpdateService.cancelPaidOrder(userId, orderId); |
| 52 | 41 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| ... | ... | @@ -93,6 +93,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 93 | 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | + // TODO @hui999:是不是只针对 combinationActivityId 的查询呀? | |
| 96 | 97 | default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { |
| 97 | 98 | return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() |
| 98 | 99 | .and(q -> q.eq(TradeOrderDO::getUserId, userId) | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -657,7 +657,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 657 | 657 | public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { |
| 658 | 658 | // 校验交易订单 |
| 659 | 659 | TradeOrderDO order = validateOrderExists(reqVO.getId()); |
| 660 | - // 只有待发货状态才可以修改订单收货地址; | |
| 660 | + // 只有待发货状态,才可以修改订单收货地址; | |
| 661 | 661 | if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { |
| 662 | 662 | throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED); |
| 663 | 663 | } |
| ... | ... | @@ -823,11 +823,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 823 | 823 | @Override |
| 824 | 824 | @Transactional(rollbackFor = Exception.class) |
| 825 | 825 | public void cancelPaidOrder(Long userId, Long orderId) { |
| 826 | + // TODO 芋艿:这里实现要优化下; | |
| 826 | 827 | TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); |
| 827 | 828 | if (order == null) { |
| 828 | 829 | throw exception(ORDER_NOT_FOUND); |
| 829 | 830 | } |
| 830 | - | |
| 831 | 831 | cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); |
| 832 | 832 | } |
| 833 | 833 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java
| ... | ... | @@ -10,7 +10,6 @@ import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; |
| 10 | 10 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; |
| 11 | 11 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| 12 | 12 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; |
| 13 | -import org.springframework.context.annotation.Lazy; | |
| 14 | 13 | import org.springframework.stereotype.Component; |
| 15 | 14 | |
| 16 | 15 | import javax.annotation.Resource; |
| ... | ... | @@ -29,14 +28,11 @@ import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_DELIV |
| 29 | 28 | public class TradeCombinationOrderHandler implements TradeOrderHandler { |
| 30 | 29 | |
| 31 | 30 | @Resource |
| 32 | - @Lazy | |
| 33 | 31 | private TradeOrderUpdateService orderUpdateService; |
| 34 | 32 | @Resource |
| 35 | - @Lazy | |
| 36 | 33 | private TradeOrderQueryService orderQueryService; |
| 37 | 34 | |
| 38 | 35 | @Resource |
| 39 | - @Lazy | |
| 40 | 36 | private CombinationRecordApi combinationRecordApi; |
| 41 | 37 | |
| 42 | 38 | @Override |
| ... | ... | @@ -51,7 +47,9 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { |
| 51 | 47 | TradeOrderItemDO item = orderItems.get(0); |
| 52 | 48 | combinationRecordApi.validateCombinationRecord(order.getUserId(), order.getCombinationActivityId(), |
| 53 | 49 | order.getCombinationHeadId(), item.getSkuId(), item.getCount()); |
| 54 | - // 2. 校验该用户是否存在未支付的拼团活动订单;就是还没支付的时候,重复下单了;需要校验下;不然的话,一个拼团可以下多个单子了; | |
| 50 | + | |
| 51 | + // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 | |
| 52 | + // TODO @puhui999:只校验未支付的拼团订单噢 | |
| 55 | 53 | TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus( |
| 56 | 54 | order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); |
| 57 | 55 | if (activityOrder != null) { | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java deleted
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.pay.api.wallet; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; | |
| 4 | -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; | |
| 5 | -import org.springframework.stereotype.Service; | |
| 6 | -import org.springframework.validation.annotation.Validated; | |
| 7 | - | |
| 8 | -import javax.annotation.Resource; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * 钱包 API 接口实现类 | |
| 12 | - * | |
| 13 | - * @author owen | |
| 14 | - */ | |
| 15 | -@Service | |
| 16 | -@Validated | |
| 17 | -public class PayWalletApiImpl implements PayWalletApi { | |
| 18 | - | |
| 19 | - @Resource | |
| 20 | - private PayWalletRechargeService payWalletRechargeService; | |
| 21 | - @Resource | |
| 22 | - private PayWalletTransactionService payWalletTransactionService; | |
| 23 | - | |
| 24 | -} |