!672 Review代码修改

Merge pull request !672 from 疯狂的世界/feature/mall_product
This commit is contained in:
芋道源码 2023-10-17 12:28:47 +00:00 committed by Gitee
commit 3c6c8aab01
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
35 changed files with 221 additions and 148 deletions

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.common.util.servlet;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
@ -89,18 +88,6 @@ public class ServletUtils {
return ServletUtil.getClientIP(request);
}
public static Integer getTerminal() {
return getHeaderInt("terminal");
}
public static String getHeader(String header) {
return getHeader(getRequest(), header);
}
public static Integer getHeaderInt(String header) {
return Convert.toInt(getHeader(header));
}
public static boolean isJsonRequest(ServletRequest request) {
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
}
@ -121,11 +108,4 @@ public class ServletUtils {
return ServletUtil.getParamMap(request);
}
public static String getHeader(HttpServletRequest request, String header) {
if (request == null) {
return null;
}
return request.getHeader(header);
}
}

View File

@ -77,8 +77,7 @@ public class MemberStatisticsController {
}
// TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致
@GetMapping("/get-area-statistics-list")
@GetMapping("/area-statistics-list")
@Operation(summary = "按照省份,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() {
@ -86,8 +85,7 @@ public class MemberStatisticsController {
}
// TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致
@GetMapping("/get-sex-statistics-list")
@GetMapping("/sex-statistics-list")
@Operation(summary = "按照性别,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() {
@ -95,12 +93,11 @@ public class MemberStatisticsController {
}
// TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致
@GetMapping("/get-terminal-statistics-list")
@GetMapping("/terminal-statistics-list")
@Operation(summary = "按照终端,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
return success(memberStatisticsService.getRegisterTerminalStatisticsList());
return success(memberStatisticsService.getMemberTerminalStatisticsList());
}
// TODO 芋艿已经 review

View File

@ -10,8 +10,7 @@ public class MemberCountRespVO {
@Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer visitUserCount;
// TODO @疯狂要不改成 registerUserCount注册
@Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer createUserCount;
@Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer registerUserCount;
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.statistics.controller.admin.pay;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO;
import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert;
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -24,11 +26,11 @@ public class PayStatisticsController {
@Resource
private PayWalletStatisticsService payWalletStatisticsService;
// TODO @疯狂要不搞成 PaySummary只是目前只有 rechargePrice 充值金额
@GetMapping("/wallet-recharge-price")
@GetMapping("/summary")
@Operation(summary = "获取充值金额")
public CommonResult<Integer> getWalletRechargePrice() {
return success(payWalletStatisticsService.getRechargePriceSummary());
public CommonResult<PaySummaryRespVO> getWalletRechargePrice() {
Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary();
return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice));
}
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 支付统计 Response VO")
@Data
public class PaySummaryRespVO {
@Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer rechargePrice;
}

View File

@ -14,6 +14,8 @@ import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@ -104,11 +106,15 @@ public class TradeStatisticsController {
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<TradeOrderCountRespVO> getOrderCount() {
// 订单统计
TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount();
Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType(
TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType());
Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType(
TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType());
// 售后统计
vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY))
.setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING));
return success(vo);
Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY);
Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING);
// 拼接返回
return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount));
}
// TODO 芋艿已经 review

View File

@ -34,11 +34,11 @@ public class TradeTrendSummaryExcelVO {
private Integer expensePrice;
@ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class)
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
@ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class)
private Integer brokerageSettlementPrice;
@ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class)
private Integer orderRefundPrice;
private Integer afterSaleRefundPrice;
}

View File

@ -23,10 +23,10 @@ public class TradeTrendSummaryRespVO {
private Integer orderPayPrice;
@Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
@Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderRefundPrice;
private Integer afterSaleRefundPrice;
@Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer brokerageSettlementPrice;

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnaly
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -29,10 +30,10 @@ public interface MemberStatisticsConvert {
default List<MemberAreaStatisticsRespVO> convertList(List<Area> areaList,
Map<Integer, Integer> userCountMap,
Map<Integer, MemberAreaStatisticsRespVO> orderMap) {
Map<Integer, MemberAreaStatisticsRespBO> orderMap) {
return CollectionUtils.convertList(areaList, area -> {
MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId()))
.orElseGet(MemberAreaStatisticsRespVO::new);
MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId()))
.orElseGet(MemberAreaStatisticsRespBO::new);
return new MemberAreaStatisticsRespVO()
.setAreaId(area.getId()).setAreaName(area.getName())
.setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0))

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.statistics.convert.pay;
import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 支付统计 Convert
*
* @author owen
*/
@Mapper
public interface PayStatisticsConvert {
PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class);
PaySummaryRespVO convert(Integer rechargePrice);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.statistics.convert.trade;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
@ -9,7 +10,9 @@ import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespB
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import java.time.LocalDateTime;
@ -50,21 +53,22 @@ public interface TradeStatisticsConvert {
AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice,
WalletSummaryRespBO walletSummary);
@IterableMapping(qualifiedByName = "convert")
List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list);
// TODO @疯狂要不要搞个默认的 convertA 方法然后这个 convert 去调用 convertA特殊字段再去 set
TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics);
@Named("convert")
default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) {
return new TradeTrendSummaryRespVO()
TradeTrendSummaryRespVO vo = convertA(tradeStatistics);
return vo
.setDate(tradeStatistics.getTime().toLocalDate())
// 营业额 = 商品支付金额 + 充值金额
.setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice())
.setOrderPayPrice(tradeStatistics.getOrderPayPrice())
.setRechargePrice(tradeStatistics.getRechargePayPrice())
// 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
.setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice())
.setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice())
.setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice())
.setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice());
.setExpensePrice(tradeStatistics.getWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice());
}
TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw);
}

View File

@ -63,11 +63,10 @@ public class TradeStatisticsDO extends TenantBaseDO {
*/
private Integer brokerageSettlementPrice;
// TODO @疯狂walletPayPrice钱包支付金额
/**
* 总支付金额余额单位
*/
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
/**
* 充值订单数
* <p>

View File

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO;
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -20,7 +20,7 @@ import java.util.List;
public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
// TODO 芋艿已经 review
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId();
// TODO 芋艿已经 review
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@ -65,10 +65,7 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
@Param("endTime") LocalDateTime endTime);
// TODO @芋艿已经 review
Long selectCountByStatus(@Param("status") Integer status);
// TODO 芋艿已经 review
Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status);
Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType);
// TODO 芋艿已经 review
TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status,

View File

@ -30,8 +30,10 @@ public class TradeStatisticsJob implements JobHandler {
@Override
@TenantJob
public String execute(String param) {
// TODO @疯狂要搞个默认的 1
if (NumberUtil.isInteger(param)) {
// 默认 昨日
if (StrUtil.isBlank(param)) {
param = "1";
} else if (!NumberUtil.isInteger(param)) {
throw new RuntimeException("交易统计任务的参数只能为是正整数");
}
Integer days = Convert.toInt(param, 0);

View File

@ -48,13 +48,12 @@ public interface MemberStatisticsService {
*/
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
// TODO @疯狂这个要不要使用 getMemberTerminalStatisticsList保持统一
/**
* 按照终端获得会员统计列表
*
* @return 会员统计列表
*/
List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList();
List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList();
// TODO 芋艿已经 review
/**

View File

@ -65,10 +65,10 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
MemberAreaStatisticsRespBO::getUserCount, Integer::sum);
// 统计订单
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
vo -> vo,
(a, b) -> new MemberAreaStatisticsRespVO()
Map<Integer, MemberAreaStatisticsRespBO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE),
bo -> bo,
(a, b) -> new MemberAreaStatisticsRespBO()
.setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount())
.setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount())
.setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice()));
@ -105,7 +105,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
}
@Override
public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() {
public List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList() {
return memberStatisticsMapper.selectSummaryListByRegisterTerminal();
}
@ -129,7 +129,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
return new MemberCountRespVO()
.setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime));
}

View File

@ -33,7 +33,7 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic
Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween(
beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType());
// 拼接
paySummary.setOrderWalletPayPrice(walletPayPrice)
paySummary.setWalletPayPrice(walletPayPrice)
.setRechargeRefundCount(refundSummary.getRechargeRefundCount())
.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice());
return paySummary;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.statistics.service.trade;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import java.time.LocalDateTime;
@ -30,7 +30,7 @@ public interface TradeOrderStatisticsService {
*
* @return 订单统计结果
*/
List<MemberAreaStatisticsRespVO> getSummaryListByAreaId();
List<MemberAreaStatisticsRespBO> getSummaryListByAreaId();
// TODO 芋艿已经 review
/**
@ -62,13 +62,12 @@ public interface TradeOrderStatisticsService {
*/
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
// TODO 芋艿已经 review
/**
* 获得交易订单数量
* 根据订单状态物流类型获得交易订单数量
*
* @return 订单数量
*/
TradeOrderCountRespVO getOrderCount();
Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType);
// TODO 芋艿已经 review
/**

View File

@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.statistics.service.trade;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper;
import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -42,7 +42,7 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
}
@Override
public List<MemberAreaStatisticsRespVO> getSummaryListByAreaId() {
public List<MemberAreaStatisticsRespBO> getSummaryListByAreaId() {
return tradeOrderStatisticsMapper.selectSummaryListByAreaId();
}
@ -62,13 +62,8 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
}
@Override
public TradeOrderCountRespVO getOrderCount() {
// TODO 疯狂这个可以根据 status + delivertyType 来过滤呀ps是不是搞个 service 方法交给上层去聚合这样 TradeOrderCountRespVO 可以更明确返回不用搞 bo
Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus());
Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus());
return new TradeOrderCountRespVO()
.setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L))
.setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L));
public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) {
return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType);
}
@Override

View File

@ -83,9 +83,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Override
public String statisticsTrade(Integer days) {
LocalDateTime today = LocalDateTime.now();
// TODO @疯狂不用并发哈因为租户可能会丢然后一般串行就好对性能没绝对的要求哈天数也不会多
return IntStream.rangeClosed(1, days)
.parallel()
.mapToObj(day -> statisticsTrade(today.minusDays(day)))
.sorted()
.collect(Collectors.joining("\n"));
@ -131,7 +129,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice,
walletSummary);
tradeStatisticsMapper.insert(entity);
// TODO @疯狂这里是不是也要把日期带上类似 108 那边
// TODO @疯狂这里是不是也要把日期带上类似 108 那边; 110 已经带上了
return stopWatch.prettyPrint();
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.statistics.service.trade.bo;
import lombok.Data;
/**
* 会员地区统计 Response BO
*
* @author owen
*/
@Data
public class MemberAreaStatisticsRespBO {
/**
* 省份编号
*/
private Integer areaId;
/**
* 省份名称
*/
private String areaName;
/**
* 会员数量
*/
private Integer userCount;
/**
* 下单的会员数量
*/
private Integer orderCreateUserCount;
/**
* 支付订单的会员数量
*/
private Integer orderPayUserCount;
/**
* 订单支付金额单位
*/
private Integer orderPayPrice;
}

View File

@ -13,7 +13,7 @@ public class WalletSummaryRespBO {
/**
* 总支付金额余额单位
*/
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
/**
* 充值订单数

View File

@ -2,9 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper">
<!-- TODO @疯狂:是返回不是的 MemberAreaStatisticsRespBO 哈 -->
<select id="selectSummaryListByAreaId"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
resultType="cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO">
SELECT receiver_area_id AS areaId,
(SELECT COUNT(DISTINCT s.user_id)
FROM trade_order AS s
@ -86,18 +85,11 @@
GROUP BY date
</select>
<select id="selectCountByStatus" resultType="java.lang.Long">
<select id="selectCountByStatusAndDeliveryType" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status}
AND deleted = FALSE
</select>
<select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status}
AND pick_up_store_id IS NOT NULL
ANd delivery_type = #{deliveryType}
AND deleted = FALSE
</select>

View File

@ -15,14 +15,14 @@
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
SELECT
-- 营业额 = 商品支付金额 + 充值金额
SUM(order_pay_price + recharge_pay_price) AS turnoverPrice,
SUM(order_pay_price) AS orderPayPrice,
SUM(recharge_pay_price) AS rechargePrice,
SUM(order_pay_price + recharge_pay_price) AS turnoverPrice,
SUM(order_pay_price) AS orderPayPrice,
SUM(recharge_pay_price) AS rechargePrice,
-- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
SUM(order_wallet_pay_price) AS orderWalletPayPrice,
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
SUM(after_sale_refund_price) AS orderRefundPrice
SUM(wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
SUM(wallet_pay_price) AS walletPayPrice,
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
SUM(after_sale_refund_price) AS afterSaleRefundPrice
FROM trade_statistics
WHERE time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
@ -30,7 +30,7 @@
<select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer">
SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
SUM(wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
FROM trade_statistics
WHERE deleted = FALSE
<if test="beginTime != null">

View File

@ -56,7 +56,7 @@ public class TradeOrderController {
}
// 查询用户信息
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), TradeOrderDO::getUserId));;
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), TradeOrderDO::getUserId));
// 查询订单项
List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(
convertSet(pageResult.getList(), TradeOrderDO::getId));
@ -126,18 +126,31 @@ public class TradeOrderController {
return success(true);
}
// TODO @疯狂1订单列表界面增加一个核销按钮点击后弹窗出一个核销码输入的窗口
//
//2输入核销码后点击确认基于 code 查询对应的订单之后弹窗展示
//
//3新的弹窗下面有个确认核销按钮确认后进行订单核销逻辑注意只有门店自提的订单才可以核销
// TODO 这里的 id 应该是 pickUpVerifyCode 参数哈
@PutMapping("/pick-up")
@PutMapping("/pick-up-by-id")
@Operation(summary = "订单核销")
@Parameter(name = "id", description = "交易订单编号")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrder(@RequestParam("id") Long id) {
public CommonResult<Boolean> pickUpOrderById(@RequestParam("id") Long id) {
tradeOrderUpdateService.pickUpOrderByMember(id);
return success(true);
}
@PutMapping("/pick-up-by-verify-code")
@Operation(summary = "订单核销")
@Parameter(name = "pickUpVerifyCode", description = "自提核销码")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) {
tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode);
return success(true);
}
@GetMapping("/get-by-pick-up-verify-code")
@Operation(summary = "查询核销码对应的订单")
@Parameter(name = "pickUpVerifyCode", description = "自提核销码")
@PreAuthorize("@ss.hasPermission('trade:order:query')")
public CommonResult<TradeOrderDetailRespVO> getByPickUpVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) {
TradeOrderDO tradeOrder = tradeOrderUpdateService.getByPickUpVerifyCode(pickUpVerifyCode);
return success(TradeOrderConvert.INSTANCE.convert2(tradeOrder, null));
}
}

View File

@ -93,6 +93,9 @@ public class TradeOrderBaseVO {
@Schema(description = "自提门店", example = "10")
private Long pickUpStoreId;
@Schema(description = "自提核销码", example = "10")
private Long pickUpVerifyCode;
@Schema(description = "配送模板编号", example = "1024")
private Long deliveryTemplateId;
@ -102,9 +105,6 @@ public class TradeOrderBaseVO {
@Schema(description = "发货物流单号", example = "1024")
private String logisticsNo;
@Schema(description = "发货状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer deliveryStatus;
@Schema(description = "发货时间")
private LocalDateTime deliveryTime;

View File

@ -61,8 +61,9 @@ public class AppTradeOrderController {
@PostMapping("/create")
@Operation(summary = "创建订单")
@PreAuthenticated
public CommonResult<AppTradeOrderCreateRespVO> createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) {
TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO);
public CommonResult<AppTradeOrderCreateRespVO> createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO,
@RequestHeader Integer terminal) {
TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO, terminal);
return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId()));
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.service.order;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
@ -37,9 +38,10 @@ public interface TradeOrderUpdateService {
* @param userId 登录用户
* @param userIp 用户 IP 地址
* @param createReqVO 创建交易订单请求模型
* @param terminal 终端 {@link TerminalEnum}
* @return 交易订单的
*/
TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO);
TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal);
/**
* 更新交易订单已支付
@ -129,6 +131,13 @@ public interface TradeOrderUpdateService {
*/
void pickUpOrderByAdmin(String pickUpVerifyCode);
/**
* 管理员根据自提核销码查询订单
*
* @param pickUpVerifyCode 自提核销码
*/
TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode);
// =================== Order Item ===================
/**

View File

@ -11,7 +11,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.module.member.api.address.AddressApi;
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
@ -159,11 +158,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override
@Transactional(rollbackFor = Exception.class)
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE)
public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) {
public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal) {
// 1.1 价格计算
TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO);
// 1.2 构建订单
TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO);
TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO, terminal);
List<TradeOrderItemDO> orderItems = buildTradeOrderItems(order, calculateRespBO);
// 2. 订单创建前的逻辑
@ -180,15 +179,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
}
private TradeOrderDO buildTradeOrder(Long userId, String clientIp, AppTradeOrderCreateReqVO createReqVO,
TradePriceCalculateRespBO calculateRespBO) {
TradePriceCalculateRespBO calculateRespBO, Integer terminal) {
TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO);
order.setType(calculateRespBO.getType());
order.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX));
order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus());
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());
order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum));
// TODO @疯狂无状态terminal 不从 servletuTILS 而是通过 controller 传递给 service
order.setTerminal(ServletUtils.getTerminal());
order.setTerminal(terminal);
// 支付 + 退款信息
order.setAdjustPrice(0).setPayStatus(false);
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
@ -682,6 +680,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
}
@Override
public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) {
return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode);
}
@Transactional(rollbackFor = Exception.class)
public void pickUpOrder(TradeOrderDO order) {
if (order == null) {

View File

@ -152,7 +152,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest {
}))).thenReturn(1000L);
// 调用方法
TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO);
TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO, null);
// 断言 TradeOrderDO 订单
List<TradeOrderDO> tradeOrderDOs = tradeOrderMapper.selectList();
assertEquals(tradeOrderDOs.size(), 1);

View File

@ -65,8 +65,9 @@ public class AppAuthController {
@PostMapping("/sms-login")
@Operation(summary = "使用手机 + 验证码登录")
public CommonResult<AppAuthLoginRespVO> smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO) {
return success(authService.smsLogin(reqVO));
public CommonResult<AppAuthLoginRespVO> smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO,
@RequestHeader Integer terminal) {
return success(authService.smsLogin(reqVO, terminal));
}
@PostMapping("/send-sms-code")

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.service.auth;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.module.member.controller.app.auth.vo.*;
import javax.validation.Valid;
@ -31,10 +32,11 @@ public interface MemberAuthService {
/**
* 手机 + 验证码登陆
*
* @param reqVO 登陆信息
* @param reqVO 登陆信息
* @param terminal 终端 {@link TerminalEnum}
* @return 登录结果
*/
AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO);
AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO, Integer terminal);
/**
* 社交登录使用 code 授权码

View File

@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
@ -78,13 +79,13 @@ public class MemberAuthServiceImpl implements MemberAuthService {
@Override
@Transactional
public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO) {
public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO, Integer terminal) {
// 校验验证码
String userIp = getClientIP();
smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp));
// 获得获得注册用户
MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp);
MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp, terminal);
Assert.notNull(user, "获取用户失败,结果为空");
// 如果 socialType 非空说明需要绑定社交用户
@ -128,7 +129,7 @@ public class MemberAuthServiceImpl implements MemberAuthService {
throw exception(AUTH_WEIXIN_MINI_APP_PHONE_CODE_ERROR);
}
// 获得获得注册用户
MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), getClientIP());
MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), getClientIP(), TerminalEnum.WECHAT_MINI_PROGRAM.getTerminal());
Assert.notNull(user, "获取用户失败,结果为空");
// 绑定社交用户

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.service.user;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
@ -43,9 +44,10 @@ public interface MemberUserService {
*
* @param mobile 手机号
* @param registerIp 注册 IP
* @param terminal 终端 {@link TerminalEnum}
* @return 用户对象
*/
MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp);
MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp, Integer terminal);
/**
* 更新用户的最后登陆信息

View File

@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
@ -81,17 +80,17 @@ public class MemberUserServiceImpl implements MemberUserService {
@Override
@Transactional(rollbackFor = Exception.class)
public MemberUserDO createUserIfAbsent(String mobile, String registerIp) {
public MemberUserDO createUserIfAbsent(String mobile, String registerIp, Integer terminal) {
// 用户已经存在
MemberUserDO user = memberUserMapper.selectByMobile(mobile);
if (user != null) {
return user;
}
// 用户不存在则进行创建
return createUser(mobile, registerIp);
return createUser(mobile, registerIp, terminal);
}
private MemberUserDO createUser(String mobile, String registerIp) {
private MemberUserDO createUser(String mobile, String registerIp, Integer terminal) {
// 生成密码
String password = IdUtil.fastSimpleUUID();
// 插入用户
@ -100,8 +99,7 @@ public class MemberUserServiceImpl implements MemberUserService {
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
user.setPassword(encodePassword(password)); // 加密密码
user.setRegisterIp(registerIp);
// TODO @疯狂无状态terminal 不从 servletuTILS 而是通过 controller 传递给 service
user.setRegisterTerminal(ServletUtils.getTerminal());
user.setRegisterTerminal(terminal);
memberUserMapper.insert(user);
// 发送 MQ 消息用户创建