diff --git a/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java b/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java index 68d1c56..ae8565b 100644 --- a/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java +++ b/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java @@ -19,6 +19,7 @@ public class LoginUser { public static final String INFO_KEY_NICKNAME = "nickname"; public static final String INFO_KEY_DEPT_ID = "deptId"; + public static final String INFO_KEY_MOBILE = "mobile"; /** * 用户编号 diff --git a/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java b/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java index f85d77c..88bf6ba 100644 --- a/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java +++ b/ruoyi-vue-pro-master/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java @@ -112,6 +112,17 @@ public class SecurityFrameworkUtils { return loginUser != null ? MapUtil.getLong(loginUser.getInfo(), LoginUser.INFO_KEY_DEPT_ID) : null; } + /** + * 获得当前用户的电话,从上下文中 + * + * @return 昵称 + */ + @Nullable + public static String getLoginUserMobile() { + LoginUser loginUser = getLoginUser(); + return loginUser != null ? MapUtil.getStr(loginUser.getInfo(), LoginUser.INFO_KEY_MOBILE) : null; + } + /** * 设置当前用户 * diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java index 3b19d61..a0cb259 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java @@ -124,5 +124,11 @@ public interface ErrorCodeConstants { // ========== 装修页面 1-013-018-000 ========== ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); ErrorCode DIY_PAGE_NAME_USED = new ErrorCode(1_013_018_001, "装修页面名称({})已经被使用"); + ErrorCode PRIZE_DRAW_NOT_EXISTS = new ErrorCode(1_013_018_002, "抽奖活动不存在"); + ErrorCode PRIZE_DRAW_NOT_START = new ErrorCode(1_013_018_003, "抽奖活动暂未开启"); + ErrorCode PRIZE_DRAW_NOT_TIME = new ErrorCode(1_013_018_004, "抽奖活动未开始或已过期"); + ErrorCode PRIZE_LOG_NOT_EXISTS = new ErrorCode(1_013_018_005, "抽奖记录不存在"); + ErrorCode PRIZE_LOG_NOT_DRAWNUM = new ErrorCode(1_013_018_006, "抽奖次数已达上限"); + ErrorCode PRIZE_LOG_NOT_LEVEL = new ErrorCode(1_013_018_007, "分销等级不在权限范围"); } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/PrizeDrawController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/PrizeDrawController.java new file mode 100644 index 0000000..79230eb --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/PrizeDrawController.java @@ -0,0 +1,121 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizedraw; + +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.convert.prizedraw.PrizeDrawConvert; +import cn.iocoder.yudao.module.promotion.convert.prizelog.PrizeLogConvert; +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawService; + +@Tag(name = "管理后台 - 抽奖活动") +@RestController +@RequestMapping("/promotion/prize-draw") +@Validated +public class PrizeDrawController { + + @Resource + private PrizeDrawService prizeDrawService; + + @Resource + private MemberLevelApi memberLevelApi; + + @PostMapping("/create") + @Operation(summary = "创建抽奖活动") + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:create')") + public CommonResult createPrizeDraw(@Valid @RequestBody PrizeDrawSaveReqVO createReqVO) { + return success(prizeDrawService.createPrizeDraw(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新抽奖活动") + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:update')") + public CommonResult updatePrizeDraw(@Valid @RequestBody PrizeDrawSaveReqVO updateReqVO) { + prizeDrawService.updatePrizeDraw(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除抽奖活动") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:delete')") + public CommonResult deletePrizeDraw(@RequestParam("id") Long id) { + prizeDrawService.deletePrizeDraw(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得抽奖活动") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:query')") + public CommonResult getPrizeDraw(@RequestParam("id") Long id) { + PrizeDrawDO prizeDraw = prizeDrawService.getPrizeDraw(id); + return success(BeanUtils.toBean(prizeDraw, PrizeDrawRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得抽奖活动分页") + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:query')") + public CommonResult> getPrizeDrawPage(@Valid PrizeDrawPageReqVO pageReqVO) { + PageResult pageResult = prizeDrawService.getPrizeDrawPage(pageReqVO); + // 处理用户级别返显 + List levels = memberLevelApi.getLevelList( + convertSet(pageResult.getList(), PrizeDrawDO::getMebLevel)); + return success(PrizeDrawConvert.INSTANCE.convertPage(pageResult, levels)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出抽奖活动 Excel") + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportPrizeDrawExcel(@Valid PrizeDrawPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = prizeDrawService.getPrizeDrawPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "抽奖活动.xls", "数据", PrizeDrawRespVO.class, + BeanUtils.toBean(list, PrizeDrawRespVO.class)); + } + + // ==================== 子表(抽奖活动奖品) ==================== + + @GetMapping("/activity-prize/list-by-activity-id") + @Operation(summary = "获得抽奖活动奖品列表") + @Parameter(name = "activityId", description = "关联抽奖活动id") + @PreAuthorize("@ss.hasPermission('promotion:prize-draw:query')") + public CommonResult> getActivityPrizeListByActivityId(@RequestParam("activityId") Long activityId) { + return success(prizeDrawService.getActivityPrizeListByActivityId(activityId)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawPageReqVO.java new file mode 100644 index 0000000..3b2a278 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawPageReqVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 抽奖活动分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class PrizeDrawPageReqVO extends PageParam { + + @Schema(description = "活动名称", example = "李四") + private String name; + + @Schema(description = "活动规则") + private String activityRule; + + @Schema(description = "活动状态(0:开启;1关闭)", example = "1") + private String status; + + @Schema(description = "开始时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] startTime; + + @Schema(description = "截至时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] endTime; + + @Schema(description = "会员等级") + private Integer mebLevel; + + /** + * 单人次抽奖次数 + */ + @Schema(description = "单人次抽奖次数") + private Integer drawNum; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawRespVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawRespVO.java new file mode 100644 index 0000000..465d5e0 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawRespVO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 抽奖活动 Response VO") +@Data +@ExcelIgnoreUnannotated +public class PrizeDrawRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1166") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "活动名称", example = "李四") + @ExcelProperty("活动名称") + private String name; + + @Schema(description = "活动规则") + @ExcelProperty("活动规则") + private String activityRule; + + @Schema(description = "活动状态(0:开启;1关闭)", example = "1") + @ExcelProperty("活动状态(0:开启;1关闭)") + private String status; + + @Schema(description = "开始时间") + @ExcelProperty("开始时间") + private LocalDateTime startTime; + + @Schema(description = "截至时间") + @ExcelProperty("截至时间") + private LocalDateTime endTime; + + @Schema(description = "会员等级") + @ExcelProperty("会员等级") + private Long mebLevel; + + /** + * 单人次抽奖次数 + */ + @Schema(description = "单人次抽奖次数") + @ExcelProperty("单人次抽奖次数") + private Integer drawNum; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + /** + * 会员等级名称 + */ + @Schema(description = "会员等级名称") + @ExcelProperty("会员等级名称") + private String levelName; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawSaveReqVO.java new file mode 100644 index 0000000..5165284 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizedraw/vo/PrizeDrawSaveReqVO.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo; + +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 抽奖活动新增/修改 Request VO") +@Data +public class PrizeDrawSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1166") + private Long id; + + @Schema(description = "活动名称", example = "李四") + private String name; + + @Schema(description = "活动规则") + private String activityRule; + + @Schema(description = "活动状态(0:开启;1关闭)", example = "1") + private String status; + + @Schema(description = "开始时间") + private LocalDateTime startTime; + + @Schema(description = "截至时间") + private LocalDateTime endTime; + + @Schema(description = "会员等级") + private Integer mebLevel; + + /** + * 单人次抽奖次数 + */ + @Schema(description = "单人次抽奖次数") + private Integer drawNum; + + @Schema(description = "抽奖活动奖品列表") + private List activityPrizes; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/PrizeLogController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/PrizeLogController.java new file mode 100644 index 0000000..acf265f --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/PrizeLogController.java @@ -0,0 +1,115 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizelog; + +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; +import cn.iocoder.yudao.module.promotion.convert.prizelog.PrizeLogConvert; +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import cn.iocoder.yudao.module.promotion.service.prizelog.PrizeLogService; + +@Tag(name = "管理后台 - 抽奖记录") +@RestController +@RequestMapping("/promotion/prize-log") +@Validated +public class PrizeLogController { + + @Resource + private PrizeLogService prizeLogService; + + @Resource + private MemberUserApi memberUserApi; + + @Resource + private PrizeDrawService prizeDrawService; + + @PostMapping("/create") + @Operation(summary = "创建抽奖记录") + @PreAuthorize("@ss.hasPermission('promotion:prize-log:create')") + public CommonResult createPrizeLog(@Valid @RequestBody PrizeLogSaveReqVO createReqVO) { + return success(prizeLogService.createPrizeLog(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新抽奖记录") + @PreAuthorize("@ss.hasPermission('promotion:prize-log:update')") + public CommonResult updatePrizeLog(@Valid @RequestBody PrizeLogSaveReqVO updateReqVO) { + prizeLogService.updatePrizeLog(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除抽奖记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('promotion:prize-log:delete')") + public CommonResult deletePrizeLog(@RequestParam("id") Long id) { + prizeLogService.deletePrizeLog(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得抽奖记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('promotion:prize-log:query')") + public CommonResult getPrizeLog(@RequestParam("id") Long id) { + PrizeLogDO prizeLog = prizeLogService.getPrizeLog(id); + return success(BeanUtils.toBean(prizeLog, PrizeLogRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得抽奖记录分页") + @PreAuthorize("@ss.hasPermission('promotion:prize-log:query')") + public CommonResult> getPrizeLogPage(@Valid PrizeLogPageReqVO pageReqVO) { + PageResult pageResult = prizeLogService.getPrizeLogPage(pageReqVO); + // 拼接用户数据 + Map userMap = memberUserApi.getUserMap( + convertSet(pageResult.getList(), PrizeLogDO::getMebId)); + // 拼接活动数据 + Map prizeMap = prizeDrawService.getPrizeDrawMap( + convertSet(pageResult.getList(), PrizeLogDO::getActivityId)); + return success(PrizeLogConvert.INSTANCE.convertPage(pageResult, userMap,prizeMap)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出抽奖记录 Excel") + @PreAuthorize("@ss.hasPermission('promotion:prize-log:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportPrizeLogExcel(@Valid PrizeLogPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = prizeLogService.getPrizeLogPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "抽奖记录.xls", "数据", PrizeLogRespVO.class, + BeanUtils.toBean(list, PrizeLogRespVO.class)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogPageReqVO.java new file mode 100644 index 0000000..7db8eca --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogPageReqVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 抽奖记录分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class PrizeLogPageReqVO extends PageParam { + + @Schema(description = "会员id", example = "26219") + private Long mebId; + + @Schema(description = "关联抽奖活动id", example = "17850") + private Long activityId; + + @Schema(description = "奖品id", example = "17850") + private Long prizeId; + + @Schema(description = "奖品名称", example = "李四") + private String name; + + @Schema(description = "奖品图片路径", example = "https://www.iocoder.cn") + private String imgUrl; + + @Schema(description = "获奖人数上限") + private Integer winNum; + + @Schema(description = "获奖概率") + private String prizeChance; + + @Schema(description = "获奖金额") + private String prizePoolAmount; + + @Schema(description = "兑奖状态(0:已兑奖;1:未兑奖)", example = "2") + private String status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogRespVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogRespVO.java new file mode 100644 index 0000000..63aee16 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogRespVO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 抽奖记录 Response VO") +@Data +@ExcelIgnoreUnannotated +public class PrizeLogRespVO { + + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5655") + @ExcelProperty("主键id") + private Long id; + + @Schema(description = "会员id", example = "26219") + @ExcelProperty("会员id") + private Long mebId; + + @Schema(description = "关联抽奖活动id", example = "17850") + @ExcelProperty("关联抽奖活动id") + private Long activityId; + + @Schema(description = "奖品id", example = "17850") + @ExcelProperty("奖品id") + private Long prizeId; + + @Schema(description = "奖品名称", example = "李四") + @ExcelProperty("奖品名称") + private String name; + + @Schema(description = "奖品图片路径", example = "https://www.iocoder.cn") + @ExcelProperty("奖品图片路径") + private String imgUrl; + + @Schema(description = "获奖人数上限") + @ExcelProperty("获奖人数上限") + private Integer winNum; + + @Schema(description = "获奖概率") + @ExcelProperty("获奖概率") + private String prizeChance; + + @Schema(description = "获奖金额") + @ExcelProperty("获奖金额") + private String prizePoolAmount; + + @Schema(description = "兑奖状态(0:已兑奖;1:未兑奖)", example = "2") + @ExcelProperty("兑奖状态(0:已兑奖;1:未兑奖)") + private String status; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + // ========== 用户相关 ========== + + @Schema(description = "用户昵称", example = "老芋艿") + private String nickname; + + @Schema(description = "活动名称", example = "老芋艿") + private String activityName; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogSaveReqVO.java new file mode 100644 index 0000000..1fc8442 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/prizelog/vo/PrizeLogSaveReqVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 抽奖记录新增/修改 Request VO") +@Data +public class PrizeLogSaveReqVO { + + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5655") + private Long id; + + @Schema(description = "会员id", example = "26219") + private Long mebId; + + @Schema(description = "关联抽奖活动id", example = "17850") + private Long activityId; + + @Schema(description = "奖品id", example = "17850") + private Long prizeId; + + @Schema(description = "奖品名称", example = "李四") + private String name; + + @Schema(description = "奖品图片路径", example = "https://www.iocoder.cn") + private String imgUrl; + + @Schema(description = "获奖人数上限") + private Integer winNum; + + @Schema(description = "获奖概率") + private String prizeChance; + + @Schema(description = "获奖金额") + private String prizePoolAmount; + + @Schema(description = "兑奖状态(0:已兑奖;1:未兑奖)", example = "2") + private String status; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/AppPrizeDrawController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/AppPrizeDrawController.java new file mode 100644 index 0000000..d5fa9c4 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/AppPrizeDrawController.java @@ -0,0 +1,180 @@ +package cn.iocoder.yudao.module.promotion.controller.app.prizedraw; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.WeightRandom; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogPageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogSaveReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo.AppPrizeDrawRespVO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawService; +import cn.iocoder.yudao.module.promotion.service.prizelog.PrizeLogService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.USER_NOT_EXISTS; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; + +@Tag(name = "用户APP - 抽奖活动") +@RestController +@RequestMapping("/promotion/prize-draw") +@Validated +public class AppPrizeDrawController { + + @Resource + private PrizeDrawService prizeDrawService; + + @Resource + private PrizeLogService prizeLogService; + + @Resource + private RedissonClient redissonClient; + + @Resource + private MemberUserApi memberUserApi; + + @Resource + private MemberLevelApi memberLevelApi; + + @GetMapping("/getOne") + @Operation(summary = "用户APP--获得抽奖活动规则") + public CommonResult getPrizeDraw() { + PrizeDrawDO prizeDraw = prizeDrawService.getOnePrizeDraw(); + if (prizeDraw == null) {//抽奖活动不存在 + throw exception(PRIZE_DRAW_NOT_EXISTS); + } + return success(BeanUtils.toBean(prizeDraw, AppPrizeDrawRespVO.class)); + } + @GetMapping("/activity-prize/list-by-activity-id") + @Operation(summary = "用户APP--获得抽奖活动奖品列表") + @Parameter(name = "activityId", description = "关联抽奖活动id") + public CommonResult> getActivityPrizeListByActivityId(@RequestParam("activityId") Long activityId) { + return success(prizeDrawService.getActivityPrizeListByActivityId(activityId)); + } + @GetMapping("/lottery") + @Operation(summary = "用户APP--抽奖") + @Parameter(name = "activityId", description = "关联抽奖活动id") + public CommonResult lottery(@RequestParam("activityId") Long activityId) { + //获取用户id + Long loginUserId = getLoginUserId(); + //查询用户信息 + MemberUserRespDTO user = memberUserApi.getUser(loginUserId); + //用户不存在 + if(user == null){ + throw exception(USER_NOT_EXISTS); + } + //获取活动信息 + PrizeDrawDO prizeDraw = prizeDrawService.getPrizeDraw(activityId); + if (prizeDraw == null) {//抽奖活动不存在 + throw exception(PRIZE_DRAW_NOT_EXISTS); + } + //判断活动状态 + if(!ObjectUtil.equal(prizeDraw.getStatus(),"0")){ + throw exception(PRIZE_DRAW_NOT_START); + } + //判断抽奖活动时间范围 + if(!DateUtil.isIn(new Date(),DateUtils.of(prizeDraw.getStartTime()),DateUtils.of(prizeDraw.getEndTime()))){ + throw exception(PRIZE_DRAW_NOT_TIME); + } + //判断抽奖活动会员等级 + MemberLevelRespDTO memberLevel = memberLevelApi.getMemberLevel(user.getLevelId()); + MemberLevelRespDTO activityLevel = memberLevelApi.getMemberLevel(Long.valueOf(prizeDraw.getMebLevel())); + if(memberLevel.getLevel()=prizeDraw.getDrawNum()){ + throw exception(PRIZE_LOG_NOT_DRAWNUM); + } + //抽奖 + ActivityPrizeDO activityPrizeDO = recursionLottery(prizeDraw); + return success(activityPrizeDO); + } + + private ActivityPrizeDO recursionLottery(PrizeDrawDO prizeDraw){ + //获取奖品信息 + List list = prizeDrawService.getActivityPrizeListByActivityId(prizeDraw.getId()); + //获取随机数 + int sortNum = (int) (Math.random() * ((8-list.size()) + 1)); + // TODO: 2023/8/16 0016 后台限制 + List> weightObjList = new ArrayList>(); + list.forEach(s -> { + weightObjList.add(new WeightRandom.WeightObj<>(s.getId().toString(), Double.valueOf(s.getPrizeChance()))); + }); + WeightRandom wr = RandomUtil.weightRandom(weightObjList); + String str = wr.next(); + RLock lock = redissonClient.getLock(str); + try { + if (lock.tryLock(1000, 10000, TimeUnit.MILLISECONDS)) { + ActivityPrizeDO activityPrize = prizeDrawService.getActivityPrize(Long.valueOf(str)); + //判断被抽中次数 + Long prizeLogNum = prizeLogService.getPrizeLogList(prizeDraw, activityPrize.getId()); + if (prizeLogNum >= activityPrize.getWinNum()) { + recursionLottery(prizeDraw); + } + //中奖 + //添加抽奖记录 + PrizeLogSaveReqVO createReqVO = new PrizeLogSaveReqVO(); + createReqVO.setMebId(getLoginUserId()); + createReqVO.setActivityId(prizeDraw.getId()); + createReqVO.setPrizeId(activityPrize.getId()); + createReqVO.setName(activityPrize.getName()); + createReqVO.setImgUrl(activityPrize.getImgUrl()); + createReqVO.setWinNum(activityPrize.getWinNum()); + createReqVO.setPrizeChance(activityPrize.getPrizeChance()); + createReqVO.setPrizePoolAmount(activityPrize.getPrizePoolAmount()); + createReqVO.setStatus("1"); + prizeLogService.createPrizeLog(createReqVO); + return activityPrize; + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + if (ObjectUtil.isNotEmpty(lock)){ + lock.unlock(); + } + } + return null; + } + + @GetMapping("/getMyPrizeLogDO") + @Operation(summary = "获得我的抽奖记录") + public CommonResult> getPrizeLogPage(@RequestParam("activityId") Long activityId) { + //获取活动信息 + PrizeDrawDO prizeDraw = prizeDrawService.getPrizeDraw(activityId); + List list = prizeLogService.getPrizeLogListByMebId(getLoginUserId(), prizeDraw); + return success(BeanUtils.toBean(list, PrizeLogRespVO.class)); + } +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawPageReqVO.java new file mode 100644 index 0000000..9116361 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawPageReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "应用 App - 抽奖活动分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class AppPrizeDrawPageReqVO extends PageParam { + + @Schema(description = "活动名称", example = "李四") + private String name; + + @Schema(description = "活动规则") + private String activityRule; + + @Schema(description = "活动状态(0:开启;1关闭)", example = "1") + private String status; + + @Schema(description = "开始时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] startTime; + + @Schema(description = "截至时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] endTime; + + @Schema(description = "会员等级") + private Integer mebLevel; + + /** + * 单人次抽奖次数 + */ + @Schema(description = "单人次抽奖次数") + @ExcelProperty("单人次抽奖次数") + private Integer drawNum; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawRespVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawRespVO.java new file mode 100644 index 0000000..b9cfbbf --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawRespVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "应用 App - 抽奖活动 Response VO") +@Data +@ExcelIgnoreUnannotated +public class AppPrizeDrawRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1166") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "活动名称", example = "李四") + @ExcelProperty("活动名称") + private String name; + + @Schema(description = "活动规则") + @ExcelProperty("活动规则") + private String activityRule; + + @Schema(description = "活动状态(0:开启;1关闭)", example = "1") + @ExcelProperty("活动状态(0:开启;1关闭)") + private String status; + + @Schema(description = "开始时间") + @ExcelProperty("开始时间") + private LocalDateTime startTime; + + @Schema(description = "截至时间") + @ExcelProperty("截至时间") + private LocalDateTime endTime; + + @Schema(description = "会员等级") + @ExcelProperty("会员等级") + private Integer mebLevel; + + /** + * 单人次抽奖次数 + */ + @Schema(description = "单人次抽奖次数") + @ExcelProperty("单人次抽奖次数") + private Integer drawNum; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawSaveReqVO.java new file mode 100644 index 0000000..fab22fa --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/prizedraw/vo/AppPrizeDrawSaveReqVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo; + +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +@Schema(description = "应用 App - 抽奖活动新增/修改 Request VO") +@Data +public class AppPrizeDrawSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1166") + private Long id; + + @Schema(description = "活动名称", example = "李四") + private String name; + + @Schema(description = "活动规则") + private String activityRule; + + @Schema(description = "活动状态(0:开启;1关闭)", example = "1") + private String status; + + @Schema(description = "开始时间") + private LocalDateTime startTime; + + @Schema(description = "截至时间") + private LocalDateTime endTime; + + @Schema(description = "会员等级") + private Integer mebLevel; + + /** + * 单人次抽奖次数 + */ + @Schema(description = "单人次抽奖次数") + private Integer drawNum; + + @Schema(description = "抽奖活动奖品列表") + private List activityPrizes; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/prizedraw/PrizeDrawConvert.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/prizedraw/PrizeDrawConvert.java new file mode 100644 index 0000000..952c582 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/prizedraw/PrizeDrawConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.promotion.convert.prizedraw; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.PrizeDrawRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogRespVO; +import cn.iocoder.yudao.module.promotion.convert.prizelog.PrizeLogConvert; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; + +@Mapper +public interface PrizeDrawConvert { + PrizeDrawConvert INSTANCE = Mappers.getMapper(PrizeDrawConvert.class); + + default PageResult convertPage(PageResult page, + List levels) { + PageResult pageResult = convertPage(page); + Map levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName); + // 拼接数据 + pageResult.getList().forEach(record ->{ + MapUtils.findAndThen(levelMap, record.getMebLevel(), + level -> record.setLevelName(levelMap.get(record.getMebLevel()))); + }); + return pageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/prizelog/PrizeLogConvert.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/prizelog/PrizeLogConvert.java new file mode 100644 index 0000000..58e3819 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/prizelog/PrizeLogConvert.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.promotion.convert.prizelog; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogRespVO; +import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +/** + * 抽奖记录 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface PrizeLogConvert { + + PrizeLogConvert INSTANCE = Mappers.getMapper(PrizeLogConvert.class); + + default PageResult convertPage(PageResult page, + Map userMap, + Map prizeMap) { + PageResult pageResult = convertPage(page); + // 拼接数据 + pageResult.getList().forEach(record ->{ + MapUtils.findAndThen(userMap, record.getMebId(), + user -> record.setNickname(user.getNickname())); + MapUtils.findAndThen(prizeMap, record.getActivityId(), + activity -> record.setActivityName(activity.getName())); + }); + return pageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizedraw/ActivityPrizeDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizedraw/ActivityPrizeDO.java new file mode 100644 index 0000000..9fc93f6 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizedraw/ActivityPrizeDO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 抽奖活动奖品 DO + * + * @author 芋道源码 + */ +@TableName("promotion_activity_prize") +@KeySequence("promotion_activity_prize_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ActivityPrizeDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 关联抽奖活动id + */ + private Long activityId; + /** + * 奖品名称 + */ + private String name; + /** + * 奖品图片路径 + */ + private String imgUrl; + /** + * 获奖人数上限 + */ + private Integer winNum; + /** + * 获奖概率 + */ + private String prizeChance; + /** + * 获奖金额 + */ + private String prizePoolAmount; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizedraw/PrizeDrawDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizedraw/PrizeDrawDO.java new file mode 100644 index 0000000..5d755e8 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizedraw/PrizeDrawDO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 抽奖活动 DO + * + * @author 芋道源码 + */ +@TableName("promotion_prize_draw") +@KeySequence("promotion_prize_draw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PrizeDrawDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 活动名称 + */ + private String name; + /** + * 活动规则 + */ + private String activityRule; + /** + * 活动状态(0:开启;1关闭) + */ + private String status; + /** + * 开始时间 + */ + private LocalDateTime startTime; + /** + * 截至时间 + */ + private LocalDateTime endTime; + /** + * 会员等级 + */ + private Long mebLevel; + + /** + * 单人次抽奖次数 + */ + private Integer drawNum; +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizelog/PrizeLogDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizelog/PrizeLogDO.java new file mode 100644 index 0000000..a543db0 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/prizelog/PrizeLogDO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 抽奖记录 DO + * + * @author 芋道源码 + */ +@TableName("promotion_prize_log") +@KeySequence("promotion_prize_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PrizeLogDO extends BaseDO { + + /** + * 主键id + */ + @TableId + private Long id; + /** + * 会员id + */ + private Long mebId; + /** + * 关联抽奖活动id + */ + private Long activityId; + /** + * 奖品id + */ + private Long prizeId; + /** + * 奖品名称 + */ + private String name; + /** + * 奖品图片路径 + */ + private String imgUrl; + /** + * 获奖人数上限 + */ + private Integer winNum; + /** + * 获奖概率 + */ + private String prizeChance; + /** + * 获奖金额 + */ + private String prizePoolAmount; + /** + * 兑奖状态(0:已兑奖;1:未兑奖) + */ + private String status; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizedraw/ActivityPrizeMapper.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizedraw/ActivityPrizeMapper.java new file mode 100644 index 0000000..67830a5 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizedraw/ActivityPrizeMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 抽奖活动奖品 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ActivityPrizeMapper extends BaseMapperX { + + default List selectListByActivityId(Long activityId) { + return selectList(ActivityPrizeDO::getActivityId, activityId); + } + + default int deleteByActivityId(Long activityId) { + return delete(ActivityPrizeDO::getActivityId, activityId); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizedraw/PrizeDrawMapper.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizedraw/PrizeDrawMapper.java new file mode 100644 index 0000000..7b0f8d9 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizedraw/PrizeDrawMapper.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*; + +/** + * 抽奖活动 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface PrizeDrawMapper extends BaseMapperX { + + default PageResult selectPage(PrizeDrawPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(PrizeDrawDO::getName, reqVO.getName()) + .eqIfPresent(PrizeDrawDO::getActivityRule, reqVO.getActivityRule()) + .eqIfPresent(PrizeDrawDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(PrizeDrawDO::getStartTime, reqVO.getStartTime()) + .betweenIfPresent(PrizeDrawDO::getEndTime, reqVO.getEndTime()) + .eqIfPresent(PrizeDrawDO::getMebLevel, reqVO.getMebLevel()) + .betweenIfPresent(PrizeDrawDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(PrizeDrawDO::getId)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizelog/PrizeLogMapper.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizelog/PrizeLogMapper.java new file mode 100644 index 0000000..650d62e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/prizelog/PrizeLogMapper.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.promotion.dal.mysql.prizelog; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*; + +/** + * 抽奖记录 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface PrizeLogMapper extends BaseMapperX { + + default PageResult selectPage(PrizeLogPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(PrizeLogDO::getMebId, reqVO.getMebId()) + .eqIfPresent(PrizeLogDO::getActivityId, reqVO.getActivityId()) + .likeIfPresent(PrizeLogDO::getName, reqVO.getName()) + .eqIfPresent(PrizeLogDO::getImgUrl, reqVO.getImgUrl()) + .eqIfPresent(PrizeLogDO::getWinNum, reqVO.getWinNum()) + .eqIfPresent(PrizeLogDO::getPrizeChance, reqVO.getPrizeChance()) + .eqIfPresent(PrizeLogDO::getPrizePoolAmount, reqVO.getPrizePoolAmount()) + .eqIfPresent(PrizeLogDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(PrizeLogDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(PrizeLogDO::getId)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawService.java new file mode 100644 index 0000000..e57e2b8 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawService.java @@ -0,0 +1,104 @@ +package cn.iocoder.yudao.module.promotion.service.prizedraw; + +import java.util.*; +import javax.validation.*; + +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*; +import cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo.AppPrizeDrawRespVO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; + +/** + * 抽奖活动 Service 接口 + * + * @author 芋道源码 + */ +public interface PrizeDrawService { + + /** + * 创建抽奖活动 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createPrizeDraw(@Valid PrizeDrawSaveReqVO createReqVO); + + /** + * 更新抽奖活动 + * + * @param updateReqVO 更新信息 + */ + void updatePrizeDraw(@Valid PrizeDrawSaveReqVO updateReqVO); + + /** + * 删除抽奖活动 + * + * @param id 编号 + */ + void deletePrizeDraw(Long id); + + /** + * 获得抽奖活动 + * + * @param id 编号 + * @return 抽奖活动 + */ + PrizeDrawDO getPrizeDraw(Long id); + + /** + * 获得抽奖活动分页 + * + * @param pageReqVO 分页查询 + * @return 抽奖活动分页 + */ + PageResult getPrizeDrawPage(PrizeDrawPageReqVO pageReqVO); + + // ==================== 子表(抽奖活动奖品) ==================== + + /** + * 获得抽奖活动奖品列表 + * + * @param activityId 关联抽奖活动id + * @return 抽奖活动奖品列表 + */ + List getActivityPrizeListByActivityId(Long activityId); + /** + * 获得抽奖活动奖品 + * + * @param id 奖品id + * @return 抽奖活动奖品列表 + */ + ActivityPrizeDO getActivityPrize(Long id); + + /** + * 获得已开启抽奖活动 + * + * @return 抽奖活动 + */ + PrizeDrawDO getOnePrizeDraw(); + + + /** + * 获得活动 Map + * + * @param ids 活动id的数组 + * @return 活动 Map + */ + default Map getPrizeDrawMap(Collection ids) { + List list = getPrizeDrawDOList(ids); + return convertMap(list, PrizeDrawDO::getId); + } + + /** + * 获得活动信息 + * + * @param ids 用户编号的数组 + * @return 用户信息们 + */ + List getPrizeDrawDOList(Collection ids); +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawServiceImpl.java new file mode 100644 index 0000000..7304758 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawServiceImpl.java @@ -0,0 +1,136 @@ +package cn.iocoder.yudao.module.promotion.service.prizedraw; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO; +import cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw.ActivityPrizeMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw.PrizeDrawMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; + +/** + * 抽奖活动 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class PrizeDrawServiceImpl implements PrizeDrawService { + + @Resource + private PrizeDrawMapper prizeDrawMapper; + @Resource + private ActivityPrizeMapper activityPrizeMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createPrizeDraw(PrizeDrawSaveReqVO createReqVO) { + // 插入 + PrizeDrawDO prizeDraw = BeanUtils.toBean(createReqVO, PrizeDrawDO.class); + prizeDrawMapper.insert(prizeDraw); + + // 插入子表 + createActivityPrizeList(prizeDraw.getId(), createReqVO.getActivityPrizes()); + // 返回 + return prizeDraw.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updatePrizeDraw(PrizeDrawSaveReqVO updateReqVO) { + // 校验存在 + validatePrizeDrawExists(updateReqVO.getId()); + // 更新 + PrizeDrawDO updateObj = BeanUtils.toBean(updateReqVO, PrizeDrawDO.class); + prizeDrawMapper.updateById(updateObj); + + // 更新子表 + updateActivityPrizeList(updateReqVO.getId(), updateReqVO.getActivityPrizes()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deletePrizeDraw(Long id) { + // 校验存在 + validatePrizeDrawExists(id); + // 删除 + prizeDrawMapper.deleteById(id); + + // 删除子表 + deleteActivityPrizeByActivityId(id); + } + + private void validatePrizeDrawExists(Long id) { + if (prizeDrawMapper.selectById(id) == null) { + throw exception(PRIZE_DRAW_NOT_EXISTS); + } + } + + @Override + public PrizeDrawDO getPrizeDraw(Long id) { + return prizeDrawMapper.selectById(id); + } + + @Override + public PageResult getPrizeDrawPage(PrizeDrawPageReqVO pageReqVO) { + return prizeDrawMapper.selectPage(pageReqVO); + } + + // ==================== 子表(抽奖活动奖品) ==================== + + @Override + public List getActivityPrizeListByActivityId(Long activityId) { + return activityPrizeMapper.selectListByActivityId(activityId); + } + + private void createActivityPrizeList(Long activityId, List list) { + list.forEach(o -> o.setActivityId(activityId)); + activityPrizeMapper.insertBatch(list); + } + + private void updateActivityPrizeList(Long activityId, List list) { + deleteActivityPrizeByActivityId(activityId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createActivityPrizeList(activityId, list); + } + + private void deleteActivityPrizeByActivityId(Long activityId) { + activityPrizeMapper.deleteByActivityId(activityId); + } + + + @Override + public PrizeDrawDO getOnePrizeDraw() { + return prizeDrawMapper.selectOne(new LambdaQueryWrapperX() + .eq(PrizeDrawDO::getStatus, 0) + ); + } + + @Override + public List getPrizeDrawDOList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return prizeDrawMapper.selectBatchIds(ids); + } + + @Override + public ActivityPrizeDO getActivityPrize(Long id) { + return activityPrizeMapper.selectById(id); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogService.java new file mode 100644 index 0000000..d29ac07 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogService.java @@ -0,0 +1,81 @@ +package cn.iocoder.yudao.module.promotion.service.prizelog; + +import java.util.*; +import javax.validation.*; + +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; + +/** + * 抽奖记录 Service 接口 + * + * @author 芋道源码 + */ +public interface PrizeLogService { + + /** + * 创建抽奖记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createPrizeLog(@Valid PrizeLogSaveReqVO createReqVO); + + /** + * 更新抽奖记录 + * + * @param updateReqVO 更新信息 + */ + void updatePrizeLog(@Valid PrizeLogSaveReqVO updateReqVO); + + /** + * 删除抽奖记录 + * + * @param id 编号 + */ + void deletePrizeLog(Long id); + + /** + * 获得抽奖记录 + * + * @param id 编号 + * @return 抽奖记录 + */ + PrizeLogDO getPrizeLog(Long id); + + /** + * 获得抽奖记录分页 + * + * @param pageReqVO 分页查询 + * @return 抽奖记录分页 + */ + PageResult getPrizeLogPage(PrizeLogPageReqVO pageReqVO); + /** + * 查询用户抽奖次数 + * + * @param mebId 用户id + * @return 抽奖记录分页 + */ + Long getPrizeLogByMebIdList(Long mebId,PrizeDrawDO prizeDraw); + /** + * 查询奖品被抽中次数 + * + * @param prizeDraw 活动 + * @return 抽奖记录分页 + */ + Long getPrizeLogList(PrizeDrawDO prizeDraw,Long prizeId); + /** + * 获取我的抽奖记录 + * + * @param prizeDraw 活动 + * @return 抽奖记录分页 + */ + List getPrizeLogListByMebId(Long mebId,PrizeDrawDO prizeDraw); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogServiceImpl.java new file mode 100644 index 0000000..410f7e7 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogServiceImpl.java @@ -0,0 +1,103 @@ +package cn.iocoder.yudao.module.promotion.service.prizelog; + +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.promotion.dal.mysql.prizelog.PrizeLogMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; + +/** + * 抽奖记录 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class PrizeLogServiceImpl implements PrizeLogService { + + @Resource + private PrizeLogMapper prizeLogMapper; + + @Override + public Long createPrizeLog(PrizeLogSaveReqVO createReqVO) { + // 插入 + PrizeLogDO prizeLog = BeanUtils.toBean(createReqVO, PrizeLogDO.class); + prizeLogMapper.insert(prizeLog); + // 返回 + return prizeLog.getId(); + } + + @Override + public void updatePrizeLog(PrizeLogSaveReqVO updateReqVO) { + // 校验存在 + validatePrizeLogExists(updateReqVO.getId()); + // 更新 + PrizeLogDO updateObj = BeanUtils.toBean(updateReqVO, PrizeLogDO.class); + prizeLogMapper.updateById(updateObj); + } + + @Override + public void deletePrizeLog(Long id) { + // 校验存在 + validatePrizeLogExists(id); + // 删除 + prizeLogMapper.deleteById(id); + } + + private void validatePrizeLogExists(Long id) { + if (prizeLogMapper.selectById(id) == null) { + throw exception(PRIZE_LOG_NOT_EXISTS); + } + } + + @Override + public PrizeLogDO getPrizeLog(Long id) { + return prizeLogMapper.selectById(id); + } + + @Override + public PageResult getPrizeLogPage(PrizeLogPageReqVO pageReqVO) { + return prizeLogMapper.selectPage(pageReqVO); + } + + @Override + public Long getPrizeLogByMebIdList(Long mebId,PrizeDrawDO prizeDraw) { + return prizeLogMapper.selectCount(new LambdaQueryWrapperX() + .eq(PrizeLogDO::getMebId, mebId) + .ge(PrizeLogDO::getCreateTime, prizeDraw.getStartTime()) + .le(PrizeLogDO::getCreateTime, prizeDraw.getEndTime()) + ); + } + + @Override + public Long getPrizeLogList(PrizeDrawDO prizeDraw,Long prizeId) { + return prizeLogMapper.selectCount(new LambdaQueryWrapperX() + .eq(PrizeLogDO::getPrizeId,prizeId) + .ge(PrizeLogDO::getCreateTime, prizeDraw.getStartTime()) + .le(PrizeLogDO::getCreateTime, prizeDraw.getEndTime()) + ); + } + + @Override + public List getPrizeLogListByMebId(Long mebId,PrizeDrawDO prizeDraw) { + return prizeLogMapper.selectList(new LambdaQueryWrapperX() + .eq(PrizeLogDO::getMebId, mebId) + .ge(PrizeLogDO::getCreateTime, prizeDraw.getStartTime()) + .le(PrizeLogDO::getCreateTime, prizeDraw.getEndTime()) + ); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/prizedraw/PrizeDrawMapper.xml b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/prizedraw/PrizeDrawMapper.xml new file mode 100644 index 0000000..3fa77d9 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/prizedraw/PrizeDrawMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/prizelog/PrizeLogMapper.xml b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/prizelog/PrizeLogMapper.xml new file mode 100644 index 0000000..a96a198 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/prizelog/PrizeLogMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawServiceImplTest.java new file mode 100644 index 0000000..e9395ce --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/prizedraw/PrizeDrawServiceImplTest.java @@ -0,0 +1,154 @@ +package cn.iocoder.yudao.module.promotion.service.prizedraw; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO; +import cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw.PrizeDrawMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link PrizeDrawServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(PrizeDrawServiceImpl.class) +public class PrizeDrawServiceImplTest extends BaseDbUnitTest { + + @Resource + private PrizeDrawServiceImpl prizeDrawService; + + @Resource + private PrizeDrawMapper prizeDrawMapper; + + @Test + public void testCreatePrizeDraw_success() { + // 准备参数 + PrizeDrawSaveReqVO createReqVO = randomPojo(PrizeDrawSaveReqVO.class).setId(null); + + // 调用 + Long prizeDrawId = prizeDrawService.createPrizeDraw(createReqVO); + // 断言 + assertNotNull(prizeDrawId); + // 校验记录的属性是否正确 + PrizeDrawDO prizeDraw = prizeDrawMapper.selectById(prizeDrawId); + assertPojoEquals(createReqVO, prizeDraw, "id"); + } + + @Test + public void testUpdatePrizeDraw_success() { + // mock 数据 + PrizeDrawDO dbPrizeDraw = randomPojo(PrizeDrawDO.class); + prizeDrawMapper.insert(dbPrizeDraw);// @Sql: 先插入出一条存在的数据 + // 准备参数 + PrizeDrawSaveReqVO updateReqVO = randomPojo(PrizeDrawSaveReqVO.class, o -> { + o.setId(dbPrizeDraw.getId()); // 设置更新的 ID + }); + + // 调用 + prizeDrawService.updatePrizeDraw(updateReqVO); + // 校验是否更新正确 + PrizeDrawDO prizeDraw = prizeDrawMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, prizeDraw); + } + + @Test + public void testUpdatePrizeDraw_notExists() { + // 准备参数 + PrizeDrawSaveReqVO updateReqVO = randomPojo(PrizeDrawSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> prizeDrawService.updatePrizeDraw(updateReqVO), PRIZE_DRAW_NOT_EXISTS); + } + + @Test + public void testDeletePrizeDraw_success() { + // mock 数据 + PrizeDrawDO dbPrizeDraw = randomPojo(PrizeDrawDO.class); + prizeDrawMapper.insert(dbPrizeDraw);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbPrizeDraw.getId(); + + // 调用 + prizeDrawService.deletePrizeDraw(id); + // 校验数据不存在了 + assertNull(prizeDrawMapper.selectById(id)); + } + + @Test + public void testDeletePrizeDraw_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> prizeDrawService.deletePrizeDraw(id), PRIZE_DRAW_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetPrizeDrawPage() { + // mock 数据 + PrizeDrawDO dbPrizeDraw = randomPojo(PrizeDrawDO.class, o -> { // 等会查询到 + o.setName(null); + o.setActivityRule(null); + o.setStatus(null); + o.setStartTime(null); + o.setEndTime(null); + o.setMebLevel(null); + o.setCreateTime(null); + }); + prizeDrawMapper.insert(dbPrizeDraw); + // 测试 name 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setName(null))); + // 测试 activityRule 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setActivityRule(null))); + // 测试 status 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setStatus(null))); + // 测试 startTime 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setStartTime(null))); + // 测试 endTime 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setEndTime(null))); + // 测试 mebLevel 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setMebLevel(null))); + // 测试 createTime 不匹配 + prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setCreateTime(null))); + // 准备参数 + PrizeDrawPageReqVO reqVO = new PrizeDrawPageReqVO(); + reqVO.setName(null); + reqVO.setActivityRule(null); + reqVO.setStatus(null); + reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setMebLevel(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = prizeDrawService.getPrizeDrawPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbPrizeDraw, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogServiceImplTest.java new file mode 100644 index 0000000..4f94756 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/prizelog/PrizeLogServiceImplTest.java @@ -0,0 +1,162 @@ +package cn.iocoder.yudao.module.promotion.service.prizelog; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO; +import cn.iocoder.yudao.module.promotion.dal.mysql.prizelog.PrizeLogMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link PrizeLogServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(PrizeLogServiceImpl.class) +public class PrizeLogServiceImplTest extends BaseDbUnitTest { + + @Resource + private PrizeLogServiceImpl prizeLogService; + + @Resource + private PrizeLogMapper prizeLogMapper; + + @Test + public void testCreatePrizeLog_success() { + // 准备参数 + PrizeLogSaveReqVO createReqVO = randomPojo(PrizeLogSaveReqVO.class).setId(null); + + // 调用 + Long prizeLogId = prizeLogService.createPrizeLog(createReqVO); + // 断言 + assertNotNull(prizeLogId); + // 校验记录的属性是否正确 + PrizeLogDO prizeLog = prizeLogMapper.selectById(prizeLogId); + assertPojoEquals(createReqVO, prizeLog, "id"); + } + + @Test + public void testUpdatePrizeLog_success() { + // mock 数据 + PrizeLogDO dbPrizeLog = randomPojo(PrizeLogDO.class); + prizeLogMapper.insert(dbPrizeLog);// @Sql: 先插入出一条存在的数据 + // 准备参数 + PrizeLogSaveReqVO updateReqVO = randomPojo(PrizeLogSaveReqVO.class, o -> { + o.setId(dbPrizeLog.getId()); // 设置更新的 ID + }); + + // 调用 + prizeLogService.updatePrizeLog(updateReqVO); + // 校验是否更新正确 + PrizeLogDO prizeLog = prizeLogMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, prizeLog); + } + + @Test + public void testUpdatePrizeLog_notExists() { + // 准备参数 + PrizeLogSaveReqVO updateReqVO = randomPojo(PrizeLogSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> prizeLogService.updatePrizeLog(updateReqVO), PRIZE_LOG_NOT_EXISTS); + } + + @Test + public void testDeletePrizeLog_success() { + // mock 数据 + PrizeLogDO dbPrizeLog = randomPojo(PrizeLogDO.class); + prizeLogMapper.insert(dbPrizeLog);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbPrizeLog.getId(); + + // 调用 + prizeLogService.deletePrizeLog(id); + // 校验数据不存在了 + assertNull(prizeLogMapper.selectById(id)); + } + + @Test + public void testDeletePrizeLog_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> prizeLogService.deletePrizeLog(id), PRIZE_LOG_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetPrizeLogPage() { + // mock 数据 + PrizeLogDO dbPrizeLog = randomPojo(PrizeLogDO.class, o -> { // 等会查询到 + o.setMebId(null); + o.setActivityId(null); + o.setName(null); + o.setImgUrl(null); + o.setWinNum(null); + o.setPrizeChance(null); + o.setPrizePoolAmount(null); + o.setStatus(null); + o.setCreateTime(null); + }); + prizeLogMapper.insert(dbPrizeLog); + // 测试 mebId 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setMebId(null))); + // 测试 activityId 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setActivityId(null))); + // 测试 name 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setName(null))); + // 测试 imgUrl 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setImgUrl(null))); + // 测试 winNum 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setWinNum(null))); + // 测试 prizeChance 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setPrizeChance(null))); + // 测试 prizePoolAmount 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setPrizePoolAmount(null))); + // 测试 status 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setCreateTime(null))); + // 准备参数 + PrizeLogPageReqVO reqVO = new PrizeLogPageReqVO(); + reqVO.setMebId(null); + reqVO.setActivityId(null); + reqVO.setName(null); + reqVO.setImgUrl(null); + reqVO.setWinNum(null); + reqVO.setPrizeChance(null); + reqVO.setPrizePoolAmount(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = prizeLogService.getPrizeLogPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbPrizeLog, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql index 6a1a242..993e5d7 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql @@ -9,4 +9,6 @@ DELETE FROM "promotion_combination_activity"; DELETE FROM "promotion_article_category"; DELETE FROM "promotion_article"; DELETE FROM "promotion_diy_template"; -DELETE FROM "promotion_diy_page"; \ No newline at end of file +DELETE FROM "promotion_diy_page"; +DELETE FROM "promotion_prize_draw"; +DELETE FROM "promotion_prize_log"; diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql index 00ac3f9..6227cb4 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql @@ -253,4 +253,39 @@ CREATE TABLE IF NOT EXISTS "promotion_diy_page" "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint NOT NULL, PRIMARY KEY ("id") -) COMMENT '装修页面'; \ No newline at end of file +) COMMENT '装修页面'; +CREATE TABLE IF NOT EXISTS "promotion_prize_draw" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar, + "activity_rule" varchar, + "status" varchar, + "start_time" varchar, + "end_time" varchar, + "meb_level" int, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint NOT NULL, + PRIMARY KEY ("id") + ) COMMENT '抽奖活动'; + +CREATE TABLE IF NOT EXISTS "promotion_prize_log" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "meb_id" bigint, + "activity_id" bigint, + "name" varchar, + "img_url" varchar, + "win_num" int, + "prize_chance" varchar, + "prize_pool_amount" varchar, + "status" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint NOT NULL, + PRIMARY KEY ("id") + ) COMMENT '抽奖记录表'; diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java new file mode 100644 index 0000000..25e27ee --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java @@ -0,0 +1,4 @@ +package cn.iocoder.yudao.module.trade.api.order; + +public interface TradeOrderItemApi { +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java index 58acde4..9c9b973 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.admin.order; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; @@ -31,6 +32,7 @@ import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.*; @Tag(name = "管理后台 - 交易订单") @RestController @@ -153,7 +155,10 @@ public class TradeOrderController { @Parameter(name = "pickUpVerifyCode", description = "自提核销码") @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") public CommonResult pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode); + // 根据管理系统登录用户信息获取APP系统用户信息 + String mobile = getLoginUserMobile(); + MemberUserRespDTO userByMobile = memberUserApi.getUserByMobile(mobile); + tradeOrderUpdateService.pickUpOrderByAdmin(userByMobile.getId(),pickUpVerifyCode); return success(true); } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index 762b238..6c8b745 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.trade.controller.app.order; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; @@ -17,6 +19,7 @@ import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.collect.Maps; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -32,6 +35,7 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "用户 App - 交易订单") @@ -54,6 +58,9 @@ public class AppTradeOrderController { @Resource private TradeOrderProperties tradeOrderProperties; + @Resource + private MemberUserApi memberUserApi; + @GetMapping("/settlement") @Operation(summary = "获得订单结算信息") @PreAuthenticated @@ -65,6 +72,9 @@ public class AppTradeOrderController { @Operation(summary = "创建订单") @PreAuthenticated public CommonResult createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) { + LoginUser loginUser = getLoginUser(); + createReqVO.setReceiverName(loginUser.getInfo().getOrDefault("nickname","")); + createReqVO.setReceiverMobile(loginUser.getInfo().getOrDefault("mobile","")); TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), createReqVO); return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId())); } @@ -74,6 +84,8 @@ public class AppTradeOrderController { public CommonResult updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayOrderId()); +// memberUserApi.updateUserUpgradesLevel(); + return success(true); } @@ -116,6 +128,13 @@ public class AppTradeOrderController { return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems)); } + @GetMapping("/getPickUpVerifyCode") + @Operation(summary = "根据订单id获取自提核销码") + public CommonResult getPickUpVerifyCode(String id) { + String pickUpVerifyCode = tradeOrderQueryService.getPickUpVerifyCode(id); + return success(pickUpVerifyCode); + } + @GetMapping("/get-count") @Operation(summary = "获得交易订单数量") public CommonResult> getOrderCount() { diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java index ba7b813..4e7cfc3 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.trade.controller.app.order.vo; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -45,6 +46,19 @@ public class AppTradeOrderPageItemRespVO { @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Integer deliveryType; + /** + * 自提门店编号 + * + * 关联 {@link DeliveryPickUpStoreDO#getId()} + */ + @Schema(description = "核销单位id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long pickUpStoreId; + /** + * 核销码 + */ + @Schema(description = "核销码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private String pickUpVerifyCode; + /** * 订单项数组 */ diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java index 8d73858..1be8990 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java @@ -59,4 +59,8 @@ public class BrokerageUserDO extends BaseDO { * 冻结佣金 */ private Integer frozenPrice; + /** + * 会员等级 + */ + private Integer level; } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java index 10b07ce..b95cf7e 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java @@ -130,6 +130,7 @@ public class TradeOrderItemDO extends BaseDO { */ private Integer payPrice; + // ========== 营销基本信息 ========== /** diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java index 6c24cac..f7989f5 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java @@ -53,6 +53,20 @@ public interface BrokerageUserMapper extends BaseMapperX { update(null, lambdaUpdateWrapper); } + /** + * 更新用户可用佣金(增加) + * + * @param id 用户编号 + * @param incrCount 增加佣金(正数) + */ + default void updateUserPriceByBindUserIdIncr(Long id, Integer incrCount) { + Assert.isTrue(incrCount > 0); + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() + .setSql(" brokerage_price = brokerage_price + " + incrCount) + .eq(BrokerageUserDO::getBindUserId, id); + update(null, lambdaUpdateWrapper); + } + /** * 更新用户可用佣金(减少) * 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失 @@ -69,6 +83,22 @@ public interface BrokerageUserMapper extends BaseMapperX { return update(null, lambdaUpdateWrapper); } + /** + * 更新用户可用佣金(减少) + * 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失 + * + * @param id 用户编号 + * @param incrCount 增加佣金(负数) + * @return 更新行数 + */ + default int updateUserPriceByBindUserIdDecr(Long id, Integer incrCount) { + Assert.isTrue(incrCount < 0); + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() + .setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号 + .eq(BrokerageUserDO::getBindUserId, id); + return update(null, lambdaUpdateWrapper); + } + /** * 更新用户冻结佣金(增加) * diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index 21fc038..f5848ec 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -124,4 +124,7 @@ public interface TradeOrderMapper extends BaseMapperX { ); } + default String getPickUpVerifyCode(String id){ + return selectOne(TradeOrderDO::getId, id).getPickUpVerifyCode(); + }; } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java index e5b7e7a..5c1a682 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java @@ -76,6 +76,16 @@ public interface BrokerageUserService { */ boolean updateUserPrice(Long id, Integer price); + + /** + * 更新用户佣金 + * + * @param id 用户编号 + * @param price 用户可用佣金 + * @return 更新结果 + */ + boolean updateUserPriceByBindUserId(Long id, Integer price); + /** * 更新用户冻结佣金 * diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java index 74439f9..6416e12 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java @@ -138,6 +138,16 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { return true; } + @Override + public boolean updateUserPriceByBindUserId(Long id, Integer price) { + if (price > 0) { + brokerageUserMapper.updateUserPriceByBindUserIdIncr(id, price); + } else if (price < 0) { + return brokerageUserMapper.updateUserPriceByBindUserIdDecr(id, price) > 0; + } + return true; + } + @Override public void updateUserFrozenPrice(Long id, Integer frozenPrice) { if (frozenPrice > 0) { diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java index 4457922..dd446f1 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java @@ -155,4 +155,5 @@ public interface TradeOrderQueryService { */ List getOrderItemListByOrderId(Collection orderIds); + String getPickUpVerifyCode(String id); } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index 0c1f696..1750772 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -248,6 +248,11 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { return tradeOrderItemMapper.selectListByOrderId(orderIds); } + @Override + public String getPickUpVerifyCode(String id) { + return tradeOrderMapper.getPickUpVerifyCode(id); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index 9f3c6cf..fb27cf7 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -126,8 +126,9 @@ public interface TradeOrderUpdateService { * 【管理员】核销订单 * * @param pickUpVerifyCode 自提核销码 + * @param id 用户id */ - void pickUpOrderByAdmin(String pickUpVerifyCode); + void pickUpOrderByAdmin(Long id, String pickUpVerifyCode); /** * 【管理员】根据自提核销码,查询订单 diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index 75323a7..5754eba 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -40,6 +40,7 @@ import cn.iocoder.yudao.module.trade.enums.order.*; import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils; +import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; import cn.iocoder.yudao.module.trade.service.cart.CartService; import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; import cn.iocoder.yudao.module.trade.service.message.TradeMessageService; @@ -107,6 +108,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Resource private TradeOrderProperties tradeOrderProperties; + @Resource + private BrokerageUserService brokerageUserService; + + // =================== Order =================== @Override @@ -679,7 +684,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Override @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(String pickUpVerifyCode) { + public void pickUpOrderByAdmin(Long id, String pickUpVerifyCode) { + boolean b = brokerageUserService.updateUserPriceByBindUserId(id, 30); getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java index 5876837..222e667 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java @@ -3,6 +3,9 @@ package cn.iocoder.yudao.module.member.api.level; import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; +import java.util.Collection; +import java.util.List; + /** * 会员等级 API 接口 * @@ -38,4 +41,11 @@ public interface MemberLevelApi { */ void reduceExperience(Long userId, Integer experience, Integer bizType, String bizId); + /** + * 获得会员等级列表 + * + * @param ids 编号 + * @return 会员等级列表 + */ + List getLevelList(Collection ids); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java index c9fb801..31402d7 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java @@ -57,4 +57,27 @@ public interface MemberUserApi { * @return 用户信息 */ MemberUserRespDTO getUserByMobile(String mobile); + + /** + * 注册帮扶人 + * + * @param userId 用户编号 + * @return 更新结果 + */ + boolean updateUserLevelId(Long userId); + /** + * 购买1188升级帮扶员 + * + * @param userId 用户编号 + * @return 更新结果 + */ + void updateUserUpgradesLevel(Long userId); + + /** + * 商品回调 + * + * @param orderId 订单id + * @return 更新结果 + */ + void updateUserUpgradesLevelcallback(Long orderId); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java index ee970a5..7cb63de 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java @@ -54,5 +54,7 @@ public interface ErrorCodeConstants { //========== 用户分组 1-004-012-000 ========== ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1_004_012_000, "用户分组不存在"); ErrorCode GROUP_HAS_USER = new ErrorCode(1_004_012_001, "用户分组下存在用户,无法删除"); - + ErrorCode DISTRIBUTION_CONFIG_NOT_EXISTS = new ErrorCode(1_004_012_002, "分销配置不存在"); + ErrorCode DISTRIBUTION_LOG_NOT_EXISTS = new ErrorCode(1_004_012_003, "分销记录不存在"); + ErrorCode DISTRIBUTION_STATISTICS_NOT_EXISTS = new ErrorCode(1_004_012_004, "分销统计不存在"); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java index 79fed98..8a6e566 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.member.api.level; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; @@ -9,6 +10,9 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT; @@ -43,4 +47,9 @@ public class MemberLevelApiImpl implements MemberLevelApi { addExperience(userId, -experience, bizType, bizId); } + @Override + public List getLevelList(Collection ids) { + return BeanUtils.toBean(memberLevelService.getLevelList(ids),MemberLevelRespDTO.class); + } + } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java index 8da857c..1d092a1 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java @@ -44,4 +44,20 @@ public class MemberUserApiImpl implements MemberUserApi { return MemberUserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile)); } + @Override + public boolean updateUserLevelId(Long userId) { + return userService.updateUserLevelId(userId); + } + + @Override + public void updateUserUpgradesLevel(Long userId) { + userService.updateUserUpgradesLevel(userId); + } + + @Override + public void updateUserUpgradesLevelcallback(Long orderId) { + userService.updateUserUpgradesLevelcallback(orderId); + } + + } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java new file mode 100644 index 0000000..7c90453 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java @@ -0,0 +1,125 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig; + +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.convert.distributionconfig.DistributionConfigConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.service.distributionconfig.DistributionConfigService; + +@Tag(name = "管理后台 - 分销配置") +@RestController +@RequestMapping("/member/distribution-config") +@Validated +public class DistributionConfigController { + + @Resource + private DistributionConfigService distributionConfigService; + + @Resource + private MemberLevelApi memberLevelApi; + + @Resource + private ProductSpuApi spuApi; + + @PostMapping("/create") + @Operation(summary = "创建分销配置") + @PreAuthorize("@ss.hasPermission('member:distribution-config:create')") + public CommonResult createDistributionConfig(@Valid @RequestBody DistributionConfigSaveReqVO createReqVO) { + return success(distributionConfigService.createDistributionConfig(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分销配置") + @PreAuthorize("@ss.hasPermission('member:distribution-config:update')") + public CommonResult updateDistributionConfig(@Valid @RequestBody DistributionConfigSaveReqVO updateReqVO) { + distributionConfigService.updateDistributionConfig(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分销配置") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:distribution-config:delete')") + public CommonResult deleteDistributionConfig(@RequestParam("id") Long id) { + distributionConfigService.deleteDistributionConfig(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销配置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:distribution-config:query')") + public CommonResult getDistributionConfig(@RequestParam("id") Long id) { + DistributionConfigDO distributionConfig = distributionConfigService.getDistributionConfig(id); + return success(BeanUtils.toBean(distributionConfig, DistributionConfigRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销配置分页") + @PreAuthorize("@ss.hasPermission('member:distribution-config:query')") + public CommonResult> getDistributionConfigPage(@Valid DistributionConfigPageReqVO pageReqVO) { + PageResult pageResult = distributionConfigService.getDistributionConfigPage(pageReqVO); + // 处理用户级别返显 + List levels = memberLevelApi.getLevelList( + convertSet(pageResult.getList(), DistributionConfigDO::getLevelId)); + // 拼接数据 + List spuList = spuApi.getSpuList(convertList(pageResult.getList(), DistributionConfigDO::getProductId)); + return success(DistributionConfigConvert.INSTANCE.convertPage(pageResult, levels,spuList)); +// return success(BeanUtils.toBean(pageResult, DistributionConfigRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分销配置 Excel") + @PreAuthorize("@ss.hasPermission('member:distribution-config:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDistributionConfigExcel(@Valid DistributionConfigPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = distributionConfigService.getDistributionConfigPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "分销配置.xls", "数据", DistributionConfigRespVO.class, + BeanUtils.toBean(list, DistributionConfigRespVO.class)); + } + + // ==================== 子表(分销配置关联会员等级) ==================== + + @GetMapping("/distribution-meb-config/list-by-config-id") + @Operation(summary = "获得分销配置关联会员等级列表") + @Parameter(name = "configId", description = "分销配置id") + @PreAuthorize("@ss.hasPermission('member:distribution-config:query')") + public CommonResult> getDistributionMebConfigListByConfigId(@RequestParam("configId") Long configId) { + return success(distributionConfigService.getDistributionMebConfigListByConfigId(configId)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java new file mode 100644 index 0000000..9ffa72f --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 分销配置分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DistributionConfigPageReqVO extends PageParam { + + @Schema(description = "分销商品id", example = "18678") + private Long productId; + @Schema(description = "购买人提升会员等级", example = "18678") + private Long levelId; + + @Schema(description = "启用状态", example = "2") + private String status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java new file mode 100644 index 0000000..541f6db --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 分销配置 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DistributionConfigRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16387") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "分销商品id", example = "18678") + @ExcelProperty("分销商品id") + private Long productId; + + @Schema(description = "购买人提升会员等级", example = "18678") + @ExcelProperty("购买人提升会员等级") + private Long levelId; + + @Schema(description = "启用状态", example = "2") + @ExcelProperty("启用状态") + private String status; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "购买人提升会员等级", example = "18678") + @ExcelProperty("购买人提升会员等级") + private String levelName; + + @Schema(description = "商品名称", example = "18678") + @ExcelProperty("商品名称") + private String supName; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java new file mode 100644 index 0000000..2d424d9 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo; + +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 分销配置新增/修改 Request VO") +@Data +public class DistributionConfigSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16387") + private Long id; + + @Schema(description = "分销商品id", example = "18678") + private Long productId; + + @Schema(description = "购买人提升会员等级", example = "18678") + private Long levelId; + + @Schema(description = "启用状态", example = "2") + private String status; + + @Schema(description = "分销配置关联会员等级列表") + private List distributionMebConfigs; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java new file mode 100644 index 0000000..28845d3 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java @@ -0,0 +1,108 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog; + +import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert; +import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.service.user.MemberUserService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.service.distributionlog.DistributionLogService; + +@Tag(name = "管理后台 - 分销记录") +@RestController +@RequestMapping("/member/distribution-log") +@Validated +public class DistributionLogController { + + @Resource + private DistributionLogService distributionLogService; + + @Resource + private MemberUserService memberUserService; + + @PostMapping("/create") + @Operation(summary = "创建分销记录") + @PreAuthorize("@ss.hasPermission('member:distribution-log:create')") + public CommonResult createDistributionLog(@Valid @RequestBody DistributionLogSaveReqVO createReqVO) { + return success(distributionLogService.createDistributionLog(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分销记录") + @PreAuthorize("@ss.hasPermission('member:distribution-log:update')") + public CommonResult updateDistributionLog(@Valid @RequestBody DistributionLogSaveReqVO updateReqVO) { + distributionLogService.updateDistributionLog(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分销记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:distribution-log:delete')") + public CommonResult deleteDistributionLog(@RequestParam("id") Long id) { + distributionLogService.deleteDistributionLog(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:distribution-log:query')") + public CommonResult getDistributionLog(@RequestParam("id") Long id) { + DistributionLogDO distributionLog = distributionLogService.getDistributionLog(id); + return success(BeanUtils.toBean(distributionLog, DistributionLogRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销记录分页") + @PreAuthorize("@ss.hasPermission('member:distribution-log:query')") + public CommonResult> getDistributionLogPage(@Valid DistributionLogPageReqVO pageReqVO) { + pageReqVO.setGameStatus("0"); + PageResult pageResult = distributionLogService.getDistributionLogPage(pageReqVO); + // 拼接结果返回 + List users = memberUserService.getUserList( + convertSet(pageResult.getList(), DistributionLogDO::getMebId)); + return success(DistributionLogConvert.INSTANCE.convertPage(pageResult, users)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分销记录 Excel") + @PreAuthorize("@ss.hasPermission('member:distribution-log:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDistributionLogExcel(@Valid DistributionLogPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = distributionLogService.getDistributionLogPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "分销记录.xls", "数据", DistributionLogRespVO.class, + BeanUtils.toBean(list, DistributionLogRespVO.class)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java new file mode 100644 index 0000000..b16eb32 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 分销记录分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DistributionLogPageReqVO extends PageParam { + + @Schema(description = "推荐人id", example = "5267") + private Long referrerId; + + @Schema(description = "推荐人id(便于回溯)", example = "23906") + private Long oldReferrerId; + + @Schema(description = "购买人id", example = "6637") + private Long mebId; + + @Schema(description = "佣金") + private Integer brokerage; + + @Schema(description = "分佣结算核销状态", example = "2") + private String status; + + @Schema(description = "游戏状态", example = "2") + private String gameStatus; + + @Schema(description = "游戏兑换状态", example = "1") + private String convertStatus; + + @Schema(description = "推荐人会员等级id", example = "10242") + private Long levelId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java new file mode 100644 index 0000000..9f5d504 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 分销记录 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DistributionLogRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "推荐人id", example = "5267") + @ExcelProperty("推荐人id") + private Long referrerId; + + @Schema(description = "推荐人id(便于回溯)", example = "23906") + @ExcelProperty("推荐人id(便于回溯)") + private Long oldReferrerId; + + @Schema(description = "购买人id", example = "6637") + @ExcelProperty("购买人id") + private Long mebId; + + @Schema(description = "佣金") + @ExcelProperty("佣金") + private Integer brokerage; + + @Schema(description = "分佣结算核销状态", example = "2") + @ExcelProperty("分佣结算核销状态") + private String status; + + @Schema(description = "游戏状态", example = "2") + @ExcelProperty("游戏状态") + private String gameStatus; + + @Schema(description = "游戏兑换状态", example = "1") + @ExcelProperty("游戏兑换状态") + private String convertStatus; + + @Schema(description = "推荐人会员等级id", example = "10242") + @ExcelProperty("推荐人会员等级id") + private Long levelId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "用户昵称", example = "2") + @ExcelProperty("用户昵称") + private String nickname; + + @Schema(description = "用户名称", example = "2") + @ExcelProperty("用户名称") + private String userName; + + @Schema(description = "手机号", example = "2") + @ExcelProperty("手机号") + private String phone; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java new file mode 100644 index 0000000..2e0635b --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 分销记录新增/修改 Request VO") +@Data +public class DistributionLogSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693") + private Long id; + + @Schema(description = "推荐人id", example = "5267") + private Long referrerId; + + @Schema(description = "推荐人id(便于回溯)", example = "23906") + private Long oldReferrerId; + + @Schema(description = "购买人id", example = "6637") + private Long mebId; + + @Schema(description = "佣金") + private Integer brokerage; + + @Schema(description = "分佣结算核销状态", example = "2") + private String status; + + @Schema(description = "游戏状态", example = "2") + private String gameStatus; + + @Schema(description = "游戏兑换状态", example = "1") + private String convertStatus; + + @Schema(description = "推荐人会员等级id", example = "10242") + private Long levelId; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java new file mode 100644 index 0000000..bc6ea0c --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java @@ -0,0 +1,124 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics; + +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert; +import cn.iocoder.yudao.module.member.convert.distributionstatistics.DistributionStatisticsConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.service.user.MemberUserService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.service.distributionstatistics.DistributionStatisticsService; + +@Tag(name = "管理后台 - 分销统计") +@RestController +@RequestMapping("/member/distribution-statistics") +@Validated +public class DistributionStatisticsController { + + @Resource + private DistributionStatisticsService distributionStatisticsService; + + @Resource + private MemberUserService memberUserService; + + @Resource + private MemberLevelApi memberLevelApi; + + @PostMapping("/create") + @Operation(summary = "创建分销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:create')") + public CommonResult createDistributionStatistics(@Valid @RequestBody DistributionStatisticsSaveReqVO createReqVO) { + return success(distributionStatisticsService.createDistributionStatistics(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')") + public CommonResult updateDistributionStatistics(@Valid @RequestBody DistributionStatisticsSaveReqVO updateReqVO) { + distributionStatisticsService.updateDistributionStatistics(updateReqVO); + return success(true); + } + + @PutMapping("/updateAlready") + @Operation(summary = "结算分销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')") + public CommonResult updateAlready(@Valid @RequestBody DistributionStatisticsSaveReqVO updateReqVO) { + distributionStatisticsService.updateAlready(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分销统计") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:delete')") + public CommonResult deleteDistributionStatistics(@RequestParam("id") Long id) { + distributionStatisticsService.deleteDistributionStatistics(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销统计") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:query')") + public CommonResult getDistributionStatistics(@RequestParam("id") Long id) { + DistributionStatisticsDO distributionStatistics = distributionStatisticsService.getDistributionStatistics(id); + return success(BeanUtils.toBean(distributionStatistics, DistributionStatisticsRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销统计分页") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:query')") + public CommonResult> getDistributionStatisticsPage(@Valid DistributionStatisticsPageReqVO pageReqVO) { + PageResult pageResult = distributionStatisticsService.getDistributionStatisticsPage1(pageReqVO); + // 拼接结果返回 + // 处理用户级别返显 + List levels = memberLevelApi.getLevelList( + convertSet(pageResult.getList(), DistributionStatisticsRespVO::getLevelId)); + List users = memberUserService.getUserList( + convertSet(pageResult.getList(), DistributionStatisticsRespVO::getMebId)); + return success(DistributionStatisticsConvert.INSTANCE.convertPage(pageResult, users,levels)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分销统计 Excel") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDistributionStatisticsExcel(@Valid DistributionStatisticsPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = distributionStatisticsService.getDistributionStatisticsPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "分销统计.xls", "数据", DistributionStatisticsRespVO.class, + BeanUtils.toBean(list, DistributionStatisticsRespVO.class)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java new file mode 100644 index 0000000..5afd5d0 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 分销统计分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DistributionStatisticsPageReqVO extends PageParam { + + @Schema(description = "会员等级id", example = "19012") + private Long levelId; + + @Schema(description = "会员id", example = "10495") + private Long mebId; + + @Schema(description = "推荐记录id", example = "5711") + private Long logId; + + @Schema(description = "推荐人id", example = "2750") + private Long referrerId; + + @Schema(description = "分佣结算核销状态", example = "1") + private String status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java new file mode 100644 index 0000000..cdd1f86 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 分销统计 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DistributionStatisticsRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25196") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "会员等级id", example = "19012") + @ExcelProperty("会员等级id") + private Long levelId; + + @Schema(description = "会员id", example = "10495") + @ExcelProperty("会员id") + private Long mebId; + + @Schema(description = "推荐记录id", example = "5711") + @ExcelProperty("推荐记录id") + private Long logId; + + @Schema(description = "推荐人id", example = "2750") + @ExcelProperty("推荐人id") + private Long referrerId; + + @Schema(description = "分佣结算核销状态", example = "1") + @ExcelProperty("分佣结算核销状态") + private String status; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + + @Schema(description = "用户昵称", example = "2") + @ExcelProperty("用户昵称") + private String nickname; + + @Schema(description = "用户名称", example = "2") + @ExcelProperty("用户名称") + private String userName; + + @Schema(description = "手机号", example = "2") + @ExcelProperty("手机号") + private String phone; + + @Schema(description = "会员等级", example = "2") + @ExcelProperty("会员等级") + private String levelName; + + @Schema(description = "已结算", example = "2") + @ExcelProperty("已结算") + private Integer haveAlready; + + @Schema(description = "未结算", example = "2") + @ExcelProperty("未结算") + private Integer unAlready; + + + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java new file mode 100644 index 0000000..39231c5 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 分销统计新增/修改 Request VO") +@Data +public class DistributionStatisticsSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25196") + private Long id; + + @Schema(description = "会员等级id", example = "19012") + private Long levelId; + + @Schema(description = "会员id", example = "10495") + private Long mebId; + + @Schema(description = "推荐记录id", example = "5711") + private Long logId; + + @Schema(description = "推荐人id", example = "2750") + private Long referrerId; + + @Schema(description = "分佣结算核销状态", example = "1") + private String status; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java new file mode 100644 index 0000000..747c5ca --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.member.convert.distributionconfig; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + +@Mapper +public interface DistributionConfigConvert { + DistributionConfigConvert INSTANCE = Mappers.getMapper(DistributionConfigConvert.class); + + default PageResult convertPage(PageResult page, + List levels + , List spuList) { + PageResult pageResult = convertPage(page); + Map levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName); + // 拼接关联属性 + Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); + // 拼接数据 + pageResult.getList().forEach(record ->{ + findAndThen(spuMap, record.getProductId(), spu -> { + record.setSupName(spu.getName()); + }); + MapUtils.findAndThen(levelMap, record.getLevelId(), + level -> record.setLevelName(levelMap.get(record.getLevelId()))); + }); + return pageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java new file mode 100644 index 0000000..1e62cc3 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.member.convert.distributionlog; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO; +import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + +@Mapper +public interface DistributionLogConvert { + DistributionLogConvert INSTANCE = Mappers.getMapper(DistributionLogConvert.class); + + default PageResult convertPage(PageResult pageResult, List users) { + PageResult voPageResult = convertPage(pageResult); + // user 拼接 + Map userMap = convertMap(users, MemberUserDO::getId); + voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getMebId(), + memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setUserName(memberUserRespDTO.getName()).setPhone(memberUserRespDTO.getMobile()))); + return voPageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java new file mode 100644 index 0000000..dacb5c2 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.member.convert.distributionstatistics; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.DistributionStatisticsRespVO; +import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + +@Mapper +public interface DistributionStatisticsConvert { + DistributionStatisticsConvert INSTANCE = Mappers.getMapper(DistributionStatisticsConvert.class); + + default PageResult convertPage(PageResult pageResult, List users,List levels) { + PageResult voPageResult = convertPage(pageResult); + // user 拼接 + Map userMap = convertMap(users, MemberUserDO::getId); + Map levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName); + voPageResult.getList().forEach(record -> { + MapUtils.findAndThen(userMap, record.getMebId(), + memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setUserName(memberUserRespDTO.getName()).setPhone(memberUserRespDTO.getMobile())); + MapUtils.findAndThen(levelMap, record.getLevelId(), + level -> record.setLevelName(levelMap.get(record.getLevelId()))); + }); + return voPageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java index aae9a76..e2670bf 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java @@ -29,6 +29,7 @@ public interface MemberUserConvert { @Mapping(source = "level", target = "level") @Mapping(source = "bean.experience", target = "experience") + @Mapping(source = "bean.id",target = "id") AppMemberUserInfoRespVO convert(MemberUserDO bean, MemberLevelDO level); MemberUserRespDTO convert2(MemberUserDO bean); diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java new file mode 100644 index 0000000..fe8710e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销配置 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_config") +@KeySequence("member_distribution_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionConfigDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 分销商品id + */ + private Long productId; + /** + * 启用状态 + */ + private String status; + /** + * 购买人提升会员等级 + */ + private Long levelId; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java new file mode 100644 index 0000000..696e490 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销配置关联会员等级 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_meb_config") +@KeySequence("member_distribution_meb_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionMebConfigDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 分销配置id + */ + private Long configId; + /** + * 会员等级 + */ + private Long levelId; + /** + * 佣金 + */ + private Integer brokerage; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java new file mode 100644 index 0000000..3dcb22e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionlog; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销记录 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_log") +@KeySequence("member_distribution_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionLogDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 推荐人id + */ + private Long referrerId; + /** + * 推荐人id(便于回溯) + */ + private Long oldReferrerId; + /** + * 购买人id + */ + private Long mebId; + /** + * 佣金 + */ + private Integer brokerage; + /** + * 分佣结算核销状态 + */ + private String status; + /** + * 游戏状态 + */ + private String gameStatus; + /** + * 游戏兑换状态 + */ + private String convertStatus; + /** + * 推荐人会员等级id + */ + private Long levelId; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java new file mode 100644 index 0000000..0b1c8e7 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java @@ -0,0 +1,51 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销统计 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_statistics") +@KeySequence("member_distribution_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionStatisticsDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 会员等级id + */ + private Long levelId; + /** + * 会员id + */ + private Long mebId; + /** + * 推荐记录id + */ + private Long logId; + /** + * 推荐人id + */ + private Long referrerId; + /** + * 分佣结算核销状态 + */ + private String status; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java new file mode 100644 index 0000000..6193d03 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionconfig; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; + +/** + * 分销配置 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionConfigMapper extends BaseMapperX { + + default PageResult selectPage(DistributionConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DistributionConfigDO::getProductId, reqVO.getProductId()) + .eqIfPresent(DistributionConfigDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(DistributionConfigDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DistributionConfigDO::getId)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java new file mode 100644 index 0000000..5d1f7d7 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionconfig; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 分销配置关联会员等级 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionMebConfigMapper extends BaseMapperX { + + default List selectListByConfigId(Long configId) { + return selectList(DistributionMebConfigDO::getConfigId, configId); + } + + default int deleteByConfigId(Long configId) { + return delete(DistributionMebConfigDO::getConfigId, configId); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java new file mode 100644 index 0000000..ea5c7c2 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionlog; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; + +/** + * 分销记录 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionLogMapper extends BaseMapperX { + + default PageResult selectPage(DistributionLogPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DistributionLogDO::getReferrerId, reqVO.getReferrerId()) + .eqIfPresent(DistributionLogDO::getOldReferrerId, reqVO.getOldReferrerId()) + .eqIfPresent(DistributionLogDO::getMebId, reqVO.getMebId()) + .eqIfPresent(DistributionLogDO::getBrokerage, reqVO.getBrokerage()) + .eqIfPresent(DistributionLogDO::getStatus, reqVO.getStatus()) + .eqIfPresent(DistributionLogDO::getGameStatus, reqVO.getGameStatus()) + .eqIfPresent(DistributionLogDO::getConvertStatus, reqVO.getConvertStatus()) + .eqIfPresent(DistributionLogDO::getLevelId, reqVO.getLevelId()) + .betweenIfPresent(DistributionLogDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DistributionLogDO::getId)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java new file mode 100644 index 0000000..24fea50 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + * 分销统计 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionStatisticsMapper extends BaseMapperX { + + default PageResult selectPage(DistributionStatisticsPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DistributionStatisticsDO::getLevelId, reqVO.getLevelId()) + .eqIfPresent(DistributionStatisticsDO::getMebId, reqVO.getMebId()) + .eqIfPresent(DistributionStatisticsDO::getLogId, reqVO.getLogId()) + .eqIfPresent(DistributionStatisticsDO::getReferrerId, reqVO.getReferrerId()) + .eqIfPresent(DistributionStatisticsDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(DistributionStatisticsDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DistributionStatisticsDO::getId)); + } + @Select({""}) + IPage selectPage1(IPage page, @Param("status") String status); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java new file mode 100644 index 0000000..cd98e17 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.member.service.distributionconfig; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; + +/** + * 分销配置 Service 接口 + * + * @author 芋道源码 + */ +public interface DistributionConfigService { + + /** + * 创建分销配置 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDistributionConfig(@Valid DistributionConfigSaveReqVO createReqVO); + + /** + * 更新分销配置 + * + * @param updateReqVO 更新信息 + */ + void updateDistributionConfig(@Valid DistributionConfigSaveReqVO updateReqVO); + + /** + * 删除分销配置 + * + * @param id 编号 + */ + void deleteDistributionConfig(Long id); + + /** + * 获得分销配置 + * + * @param id 编号 + * @return 分销配置 + */ + DistributionConfigDO getDistributionConfig(Long id); + + /** + * 获得分销配置分页 + * + * @param pageReqVO 分页查询 + * @return 分销配置分页 + */ + PageResult getDistributionConfigPage(DistributionConfigPageReqVO pageReqVO); + + // ==================== 子表(分销配置关联会员等级) ==================== + + /** + * 获得分销配置关联会员等级列表 + * + * @param configId 分销配置id + * @return 分销配置关联会员等级列表 + */ + List getDistributionMebConfigListByConfigId(Long configId); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java new file mode 100644 index 0000000..49fb2fb --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java @@ -0,0 +1,112 @@ +package cn.iocoder.yudao.module.member.service.distributionconfig; + +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionMebConfigMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 分销配置 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DistributionConfigServiceImpl implements DistributionConfigService { + + @Resource + private DistributionConfigMapper distributionConfigMapper; + @Resource + private DistributionMebConfigMapper distributionMebConfigMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createDistributionConfig(DistributionConfigSaveReqVO createReqVO) { + // 插入 + DistributionConfigDO distributionConfig = BeanUtils.toBean(createReqVO, DistributionConfigDO.class); + distributionConfigMapper.insert(distributionConfig); + + // 插入子表 + createDistributionMebConfigList(distributionConfig.getId(), createReqVO.getDistributionMebConfigs()); + // 返回 + return distributionConfig.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateDistributionConfig(DistributionConfigSaveReqVO updateReqVO) { + // 校验存在 + validateDistributionConfigExists(updateReqVO.getId()); + // 更新 + DistributionConfigDO updateObj = BeanUtils.toBean(updateReqVO, DistributionConfigDO.class); + distributionConfigMapper.updateById(updateObj); + + // 更新子表 + updateDistributionMebConfigList(updateReqVO.getId(), updateReqVO.getDistributionMebConfigs()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteDistributionConfig(Long id) { + // 校验存在 + validateDistributionConfigExists(id); + // 删除 + distributionConfigMapper.deleteById(id); + + // 删除子表 + deleteDistributionMebConfigByConfigId(id); + } + + private void validateDistributionConfigExists(Long id) { + if (distributionConfigMapper.selectById(id) == null) { + throw exception(DISTRIBUTION_CONFIG_NOT_EXISTS); + } + } + + @Override + public DistributionConfigDO getDistributionConfig(Long id) { + return distributionConfigMapper.selectById(id); + } + + @Override + public PageResult getDistributionConfigPage(DistributionConfigPageReqVO pageReqVO) { + return distributionConfigMapper.selectPage(pageReqVO); + } + + // ==================== 子表(分销配置关联会员等级) ==================== + + @Override + public List getDistributionMebConfigListByConfigId(Long configId) { + return distributionMebConfigMapper.selectListByConfigId(configId); + } + + private void createDistributionMebConfigList(Long configId, List list) { + list.forEach(o -> o.setConfigId(configId)); + distributionMebConfigMapper.insertBatch(list); + } + + private void updateDistributionMebConfigList(Long configId, List list) { + deleteDistributionMebConfigByConfigId(configId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createDistributionMebConfigList(configId, list); + } + + private void deleteDistributionMebConfigByConfigId(Long configId) { + distributionMebConfigMapper.deleteByConfigId(configId); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java new file mode 100644 index 0000000..598c6ec --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.member.service.distributionlog; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 分销记录 Service 接口 + * + * @author 芋道源码 + */ +public interface DistributionLogService { + + /** + * 创建分销记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDistributionLog(@Valid DistributionLogSaveReqVO createReqVO); + + /** + * 更新分销记录 + * + * @param updateReqVO 更新信息 + */ + void updateDistributionLog(@Valid DistributionLogSaveReqVO updateReqVO); + + /** + * 删除分销记录 + * + * @param id 编号 + */ + void deleteDistributionLog(Long id); + + /** + * 获得分销记录 + * + * @param id 编号 + * @return 分销记录 + */ + DistributionLogDO getDistributionLog(Long id); + + /** + * 获得分销记录分页 + * + * @param pageReqVO 分页查询 + * @return 分销记录分页 + */ + PageResult getDistributionLogPage(DistributionLogPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java new file mode 100644 index 0000000..b0d2283 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.member.service.distributionlog; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 分销记录 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DistributionLogServiceImpl implements DistributionLogService { + + @Resource + private DistributionLogMapper distributionLogMapper; + + @Override + public Long createDistributionLog(DistributionLogSaveReqVO createReqVO) { + // 插入 + DistributionLogDO distributionLog = BeanUtils.toBean(createReqVO, DistributionLogDO.class); + distributionLogMapper.insert(distributionLog); + // 返回 + return distributionLog.getId(); + } + + @Override + public void updateDistributionLog(DistributionLogSaveReqVO updateReqVO) { + // 校验存在 + validateDistributionLogExists(updateReqVO.getId()); + // 更新 + DistributionLogDO updateObj = BeanUtils.toBean(updateReqVO, DistributionLogDO.class); + distributionLogMapper.updateById(updateObj); + } + + @Override + public void deleteDistributionLog(Long id) { + // 校验存在 + validateDistributionLogExists(id); + // 删除 + distributionLogMapper.deleteById(id); + } + + private void validateDistributionLogExists(Long id) { + if (distributionLogMapper.selectById(id) == null) { + throw exception(DISTRIBUTION_LOG_NOT_EXISTS); + } + } + + @Override + public DistributionLogDO getDistributionLog(Long id) { + return distributionLogMapper.selectById(id); + } + + @Override + public PageResult getDistributionLogPage(DistributionLogPageReqVO pageReqVO) { + return distributionLogMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java new file mode 100644 index 0000000..3c72f2a --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java @@ -0,0 +1,68 @@ +package cn.iocoder.yudao.module.member.service.distributionstatistics; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 分销统计 Service 接口 + * + * @author 芋道源码 + */ +public interface DistributionStatisticsService { + + /** + * 创建分销统计 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDistributionStatistics(@Valid DistributionStatisticsSaveReqVO createReqVO); + + /** + * 更新分销统计 + * + * @param updateReqVO 更新信息 + */ + void updateDistributionStatistics(@Valid DistributionStatisticsSaveReqVO updateReqVO); + /** + * 更新分销统计 + * + * @param updateReqVO 更新信息 + */ + void updateAlready(@Valid DistributionStatisticsSaveReqVO updateReqVO); + + /** + * 删除分销统计 + * + * @param id 编号 + */ + void deleteDistributionStatistics(Long id); + + /** + * 获得分销统计 + * + * @param id 编号 + * @return 分销统计 + */ + DistributionStatisticsDO getDistributionStatistics(Long id); + + /** + * 获得分销统计分页 + * + * @param pageReqVO 分页查询 + * @return 分销统计分页 + */ + PageResult getDistributionStatisticsPage(DistributionStatisticsPageReqVO pageReqVO); + /** + * 获得分销统计分页 + * + * @param pageReqVO 分页查询 + * @return 分销统计分页 + */ + PageResult getDistributionStatisticsPage1(DistributionStatisticsPageReqVO pageReqVO); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java new file mode 100644 index 0000000..8d474e6 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java @@ -0,0 +1,96 @@ +package cn.iocoder.yudao.module.member.service.distributionstatistics; + +import cn.hutool.core.util.ArrayUtil; +import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 分销统计 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DistributionStatisticsServiceImpl implements DistributionStatisticsService { + + @Resource + private DistributionStatisticsMapper distributionStatisticsMapper; + + @Override + public Long createDistributionStatistics(DistributionStatisticsSaveReqVO createReqVO) { + // 插入 + DistributionStatisticsDO distributionStatistics = BeanUtils.toBean(createReqVO, DistributionStatisticsDO.class); + distributionStatisticsMapper.insert(distributionStatistics); + // 返回 + return distributionStatistics.getId(); + } + + @Override + public void updateDistributionStatistics(DistributionStatisticsSaveReqVO updateReqVO) { + // 校验存在 + validateDistributionStatisticsExists(updateReqVO.getId()); + // 更新 + DistributionStatisticsDO updateObj = BeanUtils.toBean(updateReqVO, DistributionStatisticsDO.class); + distributionStatisticsMapper.updateById(updateObj); + } + + @Override + public void updateAlready(DistributionStatisticsSaveReqVO updateReqVO) { + // 结算 + distributionStatisticsMapper.update(new UpdateWrapper().lambda().set(DistributionStatisticsDO::getStatus,0).eq(DistributionStatisticsDO::getMebId,updateReqVO.getMebId()).eq(DistributionStatisticsDO::getLevelId,updateReqVO.getLevelId())); + } + + @Override + public void deleteDistributionStatistics(Long id) { + // 校验存在 + validateDistributionStatisticsExists(id); + // 删除 + distributionStatisticsMapper.deleteById(id); + } + + private void validateDistributionStatisticsExists(Long id) { + if (distributionStatisticsMapper.selectById(id) == null) { + throw exception(DISTRIBUTION_STATISTICS_NOT_EXISTS); + } + } + + @Override + public DistributionStatisticsDO getDistributionStatistics(Long id) { + return distributionStatisticsMapper.selectById(id); + } + + @Override + public PageResult getDistributionStatisticsPage(DistributionStatisticsPageReqVO pageReqVO) { + return distributionStatisticsMapper.selectPage(pageReqVO); + } + + @Override + public PageResult getDistributionStatisticsPage1(DistributionStatisticsPageReqVO pageReqVO) { + IPage pageResult = distributionStatisticsMapper.selectPage1( + MyBatisUtils.buildPage(pageReqVO), + pageReqVO.getStatus()); + return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); +// return distributionStatisticsMapper.selectPage1(pageReqVO); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java index fb2e9cd..3f22993 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java @@ -186,5 +186,28 @@ public interface MemberUserService { * @return 更新结果 */ boolean updateUserPoint(Long userId, Integer point); + /** + * 注册帮扶人 + * + * @param userId 用户编号 + * @return 更新结果 + */ + boolean updateUserLevelId(Long userId); + /** + * 购买1188升级帮扶员 + * + * @param userId 用户编号 + * @return 更新结果 + */ + void updateUserUpgradesLevel(Long userId); + /** + * 商品回调 + * + * @param userId 用户编号 + * @param orderId 订单id + * @param productId 商品id + * @return 更新结果 + */ + void updateUserUpgradesLevelcallback(Long orderId); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index f81e9a1..f47e8bb 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -8,12 +8,24 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; import cn.iocoder.yudao.module.member.controller.app.user.vo.*; import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionMebConfigMapper; +import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper; +import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper; +import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; +import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelRecordMapper; import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; import cn.iocoder.yudao.module.member.mq.producer.user.MemberUserProducer; import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; @@ -21,8 +33,17 @@ import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; +import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper; +import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,6 +54,7 @@ import javax.annotation.Resource; import javax.validation.Valid; import java.time.LocalDateTime; import java.util.Collection; +import java.util.Date; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -64,6 +86,33 @@ public class MemberUserServiceImpl implements MemberUserService { @Resource private MemberUserProducer memberUserProducer; + @Resource + private MemberLevelRecordMapper levelLogMapper; + + @Resource + private MemberLevelMapper memberLevelMapper; + + @Resource + private BrokerageUserMapper brokerageUserMapper; + @Resource + private TradeOrderItemMapper tradeOrderItemMapper; + + @Resource + @Lazy + private TradeOrderApi tradeOrderApi; + + @Resource + private DistributionConfigMapper distributionConfigMapper; + + @Resource + private BrokerageRecordMapper brokerageRecordMapper; + @Resource + private DistributionMebConfigMapper distributionMebConfigMapper; + @Resource + private DistributionLogMapper distributionLogMapper; + @Resource + private DistributionStatisticsMapper distributionStatisticsMapper; + @Override public MemberUserDO getUserByMobile(String mobile) { return memberUserMapper.selectByMobile(mobile); @@ -314,4 +363,233 @@ public class MemberUserServiceImpl implements MemberUserService { return true; } + @Override + public boolean updateUserLevelId(Long userId) { + //查询帮扶人等级id + MemberLevelDO memberLevelDO = memberLevelMapper.selectOne(new LambdaQueryWrapperX() + .eq(MemberLevelDO::getStatus, 0) + .eq(MemberLevelDO::getDeleted, 0) + .eq(MemberLevelDO::getLevel, 1) + .orderByAsc(MemberLevelDO::getLevel)); + int i = memberUserMapper.updateById(new MemberUserDO() + .setId(userId) + .setLevelId(memberLevelDO.getId()) + ); + brokerageUserMapper.updateById(new BrokerageUserDO() + .setId(userId) + .setLevel(1) + ); + if(i>0){ + return true; + } + return false; + } + @Override + public void updateUserUpgradesLevel(Long userId) { + } + + @Override + public void updateUserUpgradesLevelcallback(Long orderId) { + //查询订单信息 + Long productId = null; + List tradeOrderItemDOS = tradeOrderItemMapper.selectListByOrderId(orderId); + if(ObjectUtil.isNotEmpty(tradeOrderItemDOS)){ + productId = tradeOrderItemDOS.get(0).getSpuId(); + } + TradeOrderRespDTO order = tradeOrderApi.getOrder(orderId); + Long userId = order.getUserId(); + + //判断订单是否已支付 + //根据商品id查询配置规则 + List distributionConfigDOS = distributionConfigMapper.selectList(new LambdaQueryWrapperX() + .eq(DistributionConfigDO::getProductId, productId) + .eq(DistributionConfigDO::getDeleted, 0) + .eq(DistributionConfigDO::getStatus, 0) + .orderByDesc(DistributionConfigDO::getCreateTime)); + if(ObjectUtil.isNotEmpty(distributionConfigDOS)){ + DistributionConfigDO distributionConfigDO = distributionConfigDOS.get(0); + //查询会员当前等级 + MemberUserDO user = memberUserMapper.selectById(userId); + MemberLevelDO memberLevelDO = memberLevelMapper.selectById(user.getLevelId()); + //查询推广员配置信息 + MemberLevelDO configLevelDO = memberLevelMapper.selectById(distributionConfigDO.getLevelId()); + if(ObjectUtil.isEmpty(memberLevelDO)){ + //修改购买人会员等级 + int i = memberUserMapper.updateById(new MemberUserDO() + .setId(userId) + .setLevelId(distributionConfigDO.getLevelId()) + ); + brokerageUserMapper.updateById(new BrokerageUserDO() + .setId(userId) + .setLevel(configLevelDO.getLevel()) + ); + }else{ + if(memberLevelDO.getLevel() distributionMebConfigDOS = distributionMebConfigMapper.selectList(new LambdaQueryWrapperX() + .eq(DistributionMebConfigDO::getConfigId, distributionConfigDO.getId()) + .eq(DistributionMebConfigDO::getDeleted, 0) + .orderByAsc(DistributionMebConfigDO::getLevelId)); + //添加5占一 + if(ObjectUtil.isNotEmpty(distributionMebConfigDOS)){ + //添加5占一游戏 + DistributionLogDO distributionLogDO = new DistributionLogDO(); + distributionLogDO.setMebId(userId); + distributionLogDO.setStatus("1"); +// distributionLogDO.setBrokerage(); + distributionLogDO.setGameStatus("1"); + distributionLogDO.setConvertStatus("1"); + distributionLogMapper.insert(distributionLogDO); + //查询5占一总数 + List distributionLogDOS = distributionLogMapper.selectList(new LambdaQueryWrapperX() + .orderByAsc(DistributionLogDO::getCreateTime)); + int i1 = distributionLogDOS.size() % 5; + if(i1 == 0){ +// DistributionLogDO vo = distributionLogDOS.get((distributionLogDOS.size()/5)-1); +// vo.setGameStatus("0"); +// distributionLogMapper.updateById(vo); + List distributionLogDOS1 = distributionLogDOS.subList(0, (distributionLogDOS.size() / 5)); + for (DistributionLogDO dt:distributionLogDOS1) { + dt.setGameStatus("0"); + } + distributionLogMapper.updateBatch(distributionLogDOS1); +// distributionLogMapper.up + } + } + + //发放直销奖励 + //查询推广员 + BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); + if(ObjectUtil.isNotEmpty(brokerageUserDO)){ + if(ObjectUtil.isNotEmpty(brokerageUserDO.getBindUserId())){ + //查询推广员会员信息 + MemberUserDO memberUserDO = memberUserMapper.selectById(brokerageUserDO.getBindUserId()); + if(ObjectUtil.isNotEmpty(memberUserDO)){ + if(ObjectUtil.isNotEmpty(distributionMebConfigDOS)){ + for (DistributionMebConfigDO eg :distributionMebConfigDOS) { + if(eg.getLevelId() == memberUserDO.getLevelId()){ + //添加佣金记录 + BrokerageRecordDO brokerageRecordDO = new BrokerageRecordDO(); + brokerageRecordDO.setUserId(memberUserDO.getId()); + brokerageRecordDO.setBizType(1); + brokerageRecordDO.setTitle("分销直推佣金"); + brokerageRecordDO.setPrice(eg.getBrokerage()*100); + //查询当前总佣金 + Integer totalPrice = 0; + List brokerageRecordDOS = brokerageRecordMapper.selectList(new LambdaQueryWrapperX() + .eq(BrokerageRecordDO::getUserId, memberUserDO.getId()) + .eq(BrokerageRecordDO::getDeleted, 0) + .orderByDesc(BrokerageRecordDO::getCreateTime)); + if(ObjectUtil.isNotEmpty(brokerageRecordDOS)){ + totalPrice = brokerageRecordDOS.get(0).getTotalPrice(); + } + brokerageRecordDO.setTotalPrice(totalPrice+eg.getBrokerage()*100);//当前总佣金 + brokerageRecordDO.setStatus(1); + brokerageRecordDO.setSourceUserLevel(configLevelDO.getLevel()); + brokerageRecordDO.setSourceUserId(userId); + brokerageRecordMapper.insert(brokerageRecordDO); + break; + } + } + } + recursionMemberLevel(brokerageUserDO.getId(),orderId); + } + } + } + } + } + + private void recursionMemberLevel(Long userId,Long orderId){ + //查询会员信息 + MemberUserDO memberUserDO = memberUserMapper.selectById(userId); + DistributionStatisticsDO distributionStatisticsDO = new DistributionStatisticsDO(); + distributionStatisticsDO.setLevelId(memberUserDO.getLevelId()); + distributionStatisticsDO.setMebId(memberUserDO.getId()); + distributionStatisticsDO.setLogId(orderId); + distributionStatisticsDO.setStatus("1"); + distributionStatisticsMapper.insert(distributionStatisticsDO); + //查询会员当前等级 + MemberLevelDO memberLevelDO = memberLevelMapper.selectById(memberUserDO.getLevelId()); + if(ObjectUtil.isNotEmpty(memberLevelDO)){ + //查询上一级会员等级 + MemberLevelDO upLevelDO = memberLevelMapper.selectOne(new LambdaQueryWrapperX() + .eq(MemberLevelDO::getStatus, 0) + .eq(MemberLevelDO::getDeleted, 0) + .eq(MemberLevelDO::getLevel, (memberLevelDO.getLevel()+1)) + .orderByAsc(MemberLevelDO::getLevel)); + if(ObjectUtil.isNotEmpty(upLevelDO)){ + if(ObjectUtil.equal(memberLevelDO.getLevel(),1)){//帮扶人不升级 + //添加推荐统计 + } + if(ObjectUtil.equal(memberLevelDO.getLevel(),2)){//帮扶员升级帮扶驿站 + //查询会员邀请记录下级会员 + List brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + .eq(BrokerageUserDO::getBindUserId, userId) + .ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) + .eq(BrokerageUserDO::getDeleted, 0) + ); + if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ + if(brokerageUserDOS.size()>=3){ + //升级会员 + memberUserMapper.updateById(new MemberUserDO() + .setId(userId) + .setLevelId(upLevelDO.getId()) + ); + brokerageUserMapper.updateById(new BrokerageUserDO() + .setId(userId) + .setLevel(upLevelDO.getLevel()) + ); + } + } + //判断上级会员是否升级 + BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); + recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId); + } + if(ObjectUtil.equal(memberLevelDO.getLevel(),3)){//帮扶驿站升级帮扶中心 + //查询会员邀请记录下级会员 + List brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + .eq(BrokerageUserDO::getBindUserId, userId) + .ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) + .eq(BrokerageUserDO::getDeleted, 0) + ); + //查询会员邀请记录下级会员 + List brokerageUserDOS1 = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + .eq(BrokerageUserDO::getBindUserId, userId) + .ge(BrokerageUserDO::getLevel, 2) + .eq(BrokerageUserDO::getDeleted, 0) + ); + if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ + if(brokerageUserDOS.size()>=10 || brokerageUserDOS1.size()>=300){ + //升级会员 + memberUserMapper.updateById(new MemberUserDO() + .setId(userId) + .setLevelId(upLevelDO.getId()) + ); + brokerageUserMapper.updateById(new BrokerageUserDO() + .setId(userId) + .setLevel(upLevelDO.getLevel()) + ); + } + } + //判断上级会员是否升级 + BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); + recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId); + } + if(ObjectUtil.equal(memberLevelDO.getLevel(),4)){//帮扶中心不做升级 + } + } + } + } } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java new file mode 100644 index 0000000..cad400e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java @@ -0,0 +1,138 @@ +package cn.iocoder.yudao.module.member.service.distributionconfig; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DistributionConfigServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DistributionConfigServiceImpl.class) +public class DistributionConfigServiceImplTest extends BaseDbUnitTest { + + @Resource + private DistributionConfigServiceImpl distributionConfigService; + + @Resource + private DistributionConfigMapper distributionConfigMapper; + + @Test + public void testCreateDistributionConfig_success() { + // 准备参数 + DistributionConfigSaveReqVO createReqVO = randomPojo(DistributionConfigSaveReqVO.class).setId(null); + + // 调用 + Long distributionConfigId = distributionConfigService.createDistributionConfig(createReqVO); + // 断言 + assertNotNull(distributionConfigId); + // 校验记录的属性是否正确 + DistributionConfigDO distributionConfig = distributionConfigMapper.selectById(distributionConfigId); + assertPojoEquals(createReqVO, distributionConfig, "id"); + } + + @Test + public void testUpdateDistributionConfig_success() { + // mock 数据 + DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class); + distributionConfigMapper.insert(dbDistributionConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DistributionConfigSaveReqVO updateReqVO = randomPojo(DistributionConfigSaveReqVO.class, o -> { + o.setId(dbDistributionConfig.getId()); // 设置更新的 ID + }); + + // 调用 + distributionConfigService.updateDistributionConfig(updateReqVO); + // 校验是否更新正确 + DistributionConfigDO distributionConfig = distributionConfigMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, distributionConfig); + } + + @Test + public void testUpdateDistributionConfig_notExists() { + // 准备参数 + DistributionConfigSaveReqVO updateReqVO = randomPojo(DistributionConfigSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> distributionConfigService.updateDistributionConfig(updateReqVO), DISTRIBUTION_CONFIG_NOT_EXISTS); + } + + @Test + public void testDeleteDistributionConfig_success() { + // mock 数据 + DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class); + distributionConfigMapper.insert(dbDistributionConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDistributionConfig.getId(); + + // 调用 + distributionConfigService.deleteDistributionConfig(id); + // 校验数据不存在了 + assertNull(distributionConfigMapper.selectById(id)); + } + + @Test + public void testDeleteDistributionConfig_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> distributionConfigService.deleteDistributionConfig(id), DISTRIBUTION_CONFIG_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDistributionConfigPage() { + // mock 数据 + DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class, o -> { // 等会查询到 + o.setProductId(null); + o.setStatus(null); + o.setCreateTime(null); + }); + distributionConfigMapper.insert(dbDistributionConfig); + // 测试 productId 不匹配 + distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setProductId(null))); + // 测试 status 不匹配 + distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setCreateTime(null))); + // 准备参数 + DistributionConfigPageReqVO reqVO = new DistributionConfigPageReqVO(); + reqVO.setProductId(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = distributionConfigService.getDistributionConfigPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDistributionConfig, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java new file mode 100644 index 0000000..1ce9387 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java @@ -0,0 +1,162 @@ +package cn.iocoder.yudao.module.member.service.distributionlog; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DistributionLogServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DistributionLogServiceImpl.class) +public class DistributionLogServiceImplTest extends BaseDbUnitTest { + + @Resource + private DistributionLogServiceImpl distributionLogService; + + @Resource + private DistributionLogMapper distributionLogMapper; + + @Test + public void testCreateDistributionLog_success() { + // 准备参数 + DistributionLogSaveReqVO createReqVO = randomPojo(DistributionLogSaveReqVO.class).setId(null); + + // 调用 + Long distributionLogId = distributionLogService.createDistributionLog(createReqVO); + // 断言 + assertNotNull(distributionLogId); + // 校验记录的属性是否正确 + DistributionLogDO distributionLog = distributionLogMapper.selectById(distributionLogId); + assertPojoEquals(createReqVO, distributionLog, "id"); + } + + @Test + public void testUpdateDistributionLog_success() { + // mock 数据 + DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class); + distributionLogMapper.insert(dbDistributionLog);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DistributionLogSaveReqVO updateReqVO = randomPojo(DistributionLogSaveReqVO.class, o -> { + o.setId(dbDistributionLog.getId()); // 设置更新的 ID + }); + + // 调用 + distributionLogService.updateDistributionLog(updateReqVO); + // 校验是否更新正确 + DistributionLogDO distributionLog = distributionLogMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, distributionLog); + } + + @Test + public void testUpdateDistributionLog_notExists() { + // 准备参数 + DistributionLogSaveReqVO updateReqVO = randomPojo(DistributionLogSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> distributionLogService.updateDistributionLog(updateReqVO), DISTRIBUTION_LOG_NOT_EXISTS); + } + + @Test + public void testDeleteDistributionLog_success() { + // mock 数据 + DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class); + distributionLogMapper.insert(dbDistributionLog);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDistributionLog.getId(); + + // 调用 + distributionLogService.deleteDistributionLog(id); + // 校验数据不存在了 + assertNull(distributionLogMapper.selectById(id)); + } + + @Test + public void testDeleteDistributionLog_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> distributionLogService.deleteDistributionLog(id), DISTRIBUTION_LOG_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDistributionLogPage() { + // mock 数据 + DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class, o -> { // 等会查询到 + o.setReferrerId(null); + o.setOldReferrerId(null); + o.setMebId(null); + o.setBrokerage(null); + o.setStatus(null); + o.setGameStatus(null); + o.setConvertStatus(null); + o.setLevelId(null); + o.setCreateTime(null); + }); + distributionLogMapper.insert(dbDistributionLog); + // 测试 referrerId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setReferrerId(null))); + // 测试 oldReferrerId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setOldReferrerId(null))); + // 测试 mebId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setMebId(null))); + // 测试 brokerage 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setBrokerage(null))); + // 测试 status 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setStatus(null))); + // 测试 gameStatus 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setGameStatus(null))); + // 测试 convertStatus 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setConvertStatus(null))); + // 测试 levelId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setLevelId(null))); + // 测试 createTime 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setCreateTime(null))); + // 准备参数 + DistributionLogPageReqVO reqVO = new DistributionLogPageReqVO(); + reqVO.setReferrerId(null); + reqVO.setOldReferrerId(null); + reqVO.setMebId(null); + reqVO.setBrokerage(null); + reqVO.setStatus(null); + reqVO.setGameStatus(null); + reqVO.setConvertStatus(null); + reqVO.setLevelId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = distributionLogService.getDistributionLogPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDistributionLog, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java new file mode 100644 index 0000000..8e92974 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java @@ -0,0 +1,150 @@ +package cn.iocoder.yudao.module.member.service.distributionstatistics; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DistributionStatisticsServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DistributionStatisticsServiceImpl.class) +public class DistributionStatisticsServiceImplTest extends BaseDbUnitTest { + + @Resource + private DistributionStatisticsServiceImpl distributionStatisticsService; + + @Resource + private DistributionStatisticsMapper distributionStatisticsMapper; + + @Test + public void testCreateDistributionStatistics_success() { + // 准备参数 + DistributionStatisticsSaveReqVO createReqVO = randomPojo(DistributionStatisticsSaveReqVO.class).setId(null); + + // 调用 + Long distributionStatisticsId = distributionStatisticsService.createDistributionStatistics(createReqVO); + // 断言 + assertNotNull(distributionStatisticsId); + // 校验记录的属性是否正确 + DistributionStatisticsDO distributionStatistics = distributionStatisticsMapper.selectById(distributionStatisticsId); + assertPojoEquals(createReqVO, distributionStatistics, "id"); + } + + @Test + public void testUpdateDistributionStatistics_success() { + // mock 数据 + DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class); + distributionStatisticsMapper.insert(dbDistributionStatistics);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DistributionStatisticsSaveReqVO updateReqVO = randomPojo(DistributionStatisticsSaveReqVO.class, o -> { + o.setId(dbDistributionStatistics.getId()); // 设置更新的 ID + }); + + // 调用 + distributionStatisticsService.updateDistributionStatistics(updateReqVO); + // 校验是否更新正确 + DistributionStatisticsDO distributionStatistics = distributionStatisticsMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, distributionStatistics); + } + + @Test + public void testUpdateDistributionStatistics_notExists() { + // 准备参数 + DistributionStatisticsSaveReqVO updateReqVO = randomPojo(DistributionStatisticsSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> distributionStatisticsService.updateDistributionStatistics(updateReqVO), DISTRIBUTION_STATISTICS_NOT_EXISTS); + } + + @Test + public void testDeleteDistributionStatistics_success() { + // mock 数据 + DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class); + distributionStatisticsMapper.insert(dbDistributionStatistics);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDistributionStatistics.getId(); + + // 调用 + distributionStatisticsService.deleteDistributionStatistics(id); + // 校验数据不存在了 + assertNull(distributionStatisticsMapper.selectById(id)); + } + + @Test + public void testDeleteDistributionStatistics_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> distributionStatisticsService.deleteDistributionStatistics(id), DISTRIBUTION_STATISTICS_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDistributionStatisticsPage() { + // mock 数据 + DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class, o -> { // 等会查询到 + o.setLevelId(null); + o.setMebId(null); + o.setLogId(null); + o.setReferrerId(null); + o.setStatus(null); + o.setCreateTime(null); + }); + distributionStatisticsMapper.insert(dbDistributionStatistics); + // 测试 levelId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setLevelId(null))); + // 测试 mebId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setMebId(null))); + // 测试 logId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setLogId(null))); + // 测试 referrerId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setReferrerId(null))); + // 测试 status 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setCreateTime(null))); + // 准备参数 + DistributionStatisticsPageReqVO reqVO = new DistributionStatisticsPageReqVO(); + reqVO.setLevelId(null); + reqVO.setMebId(null); + reqVO.setLogId(null); + reqVO.setReferrerId(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = distributionStatisticsService.getDistributionStatisticsPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDistributionStatistics, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java index 58834fb..6ca926c 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java @@ -33,6 +33,7 @@ public class PayDemoOrderController { @Resource private PayDemoOrderService payDemoOrderService; + @PostMapping("/create") @Operation(summary = "创建示例订单") public CommonResult createDemoOrder(@Valid @RequestBody PayDemoOrderCreateReqVO createReqVO) { @@ -52,6 +53,8 @@ public class PayDemoOrderController { public CommonResult updateDemoOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { payDemoOrderService.updateDemoOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayOrderId()); + + return success(true); } diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java index b66a71e..69328df 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.core.client.PayClient; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java index 95510d5..96c46c9 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java @@ -58,5 +58,8 @@ public interface PayOrderMapper extends BaseMapperX { .eq(PayOrderDO::getStatus, status) .lt(PayOrderDO::getExpireTime, expireTime)); } + default PayOrderDO selectPayOrderDOById(Long id) { + return selectById(id); + } } diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java index a058b95..fe9d7ec 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java @@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; @@ -75,6 +76,9 @@ public class PayOrderServiceImpl implements PayOrderService { @Resource private PayNotifyService notifyService; + @Resource + private MemberUserApi memberUserApi; + @Override public PayOrderDO getOrder(Long id) { return orderMapper.selectById(id); @@ -268,6 +272,9 @@ public class PayOrderServiceImpl implements PayOrderService { // 情况一:支付成功的回调 if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) { notifyOrderSuccess(channel, notify); + PayOrderExtensionDO orderExtension = updateOrderSuccess(notify); + PayOrderDO payOrderDO = orderMapper.selectPayOrderDOById(orderExtension.getOrderId()); + memberUserApi.updateUserUpgradesLevelcallback(Long.valueOf(payOrderDO.getMerchantOrderId())); return; } // 情况二:支付失败的回调 diff --git a/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImpl.java index d2cfa71..89852ae 100644 --- a/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImpl.java @@ -178,7 +178,8 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { if (userType.equals(UserTypeEnum.ADMIN.getValue())) { AdminUserDO user = adminUserService.getUser(userId); return MapUtil.builder(LoginUser.INFO_KEY_NICKNAME, user.getNickname()) - .put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId())).build(); + .put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId())) + .put(LoginUser.INFO_KEY_MOBILE,StrUtil.toStringOrNull(user.getMobile())).build(); } else if (userType.equals(UserTypeEnum.MEMBER.getValue())) { // 注意:目前 Member 暂时不读取,可以按需实现 return Collections.emptyMap(); diff --git a/yudao-mall-uniapp-master/.env.development b/yudao-mall-uniapp-master/.env.development index eff223b..f3d3497 100644 --- a/yudao-mall-uniapp-master/.env.development +++ b/yudao-mall-uniapp-master/.env.development @@ -1 +1,2 @@ - SHOPRO_DEV_BASE_URL = http://192.168.0.135:48080 \ No newline at end of file + # SHOPRO_DEV_BASE_URL = https://yanghaodong.51vip.biz + SHOPRO_DEV_BASE_URL = http://192.168.1.118:48080 \ No newline at end of file diff --git a/yudao-mall-uniapp-master/manifest.json b/yudao-mall-uniapp-master/manifest.json index 7818b33..abb3b87 100644 --- a/yudao-mall-uniapp-master/manifest.json +++ b/yudao-mall-uniapp-master/manifest.json @@ -1,222 +1,239 @@ { - "name": "芋道商城", - "appid": "__UNI__460BC4C", - "description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。", - "versionName": "2.1.0", - "versionCode": 183, - "transformPx": false, - "app-plus": { - "usingComponents": true, - "nvueCompiler": "uni-app", - "nvueStyleCompiler": "uni-app", - "compilerVersion": 3, - "nvueLaunchMode": "fast", - "splashscreen": { - "alwaysShowBeforeRender": true, - "waiting": true, - "autoclose": true, - "delay": 0 - }, - "safearea": { - "bottom": { - "offset": "none" - } - }, - "modules": { - "Payment": {}, - "Share": {}, - "VideoPlayer": {}, - "OAuth": {} - }, - "distribute": { - "android": { - "permissions": [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "minSdkVersion": 21, - "schemes": "shopro" - }, - "ios": { - "urlschemewhitelist": ["baidumap", "iosamap"], - "dSYMs": false, - "privacyDescription": { - "NSPhotoLibraryUsageDescription": "需要同意访问您的相册选取图片才能完善该条目", - "NSPhotoLibraryAddUsageDescription": "需要同意访问您的相册才能保存该图片", - "NSCameraUsageDescription": "需要同意访问您的摄像头拍摄照片才能完善该条目", - "NSUserTrackingUsageDescription": "开启追踪并不会获取您在其它站点的隐私信息,该行为仅用于标识设备,保障服务安全和提升浏览体验" - }, - "urltypes": "shopro", - "capabilities": { - "entitlements": { - "com.apple.developer.associated-domains": ["applinks:shopro.sheepjs.com"] - } - }, - "idfa": true - }, - "sdkConfigs": { - "speech": { - "ifly": {} - }, - "ad": {}, - "oauth": { - "apple": {}, - "weixin": { - "appid": "wxae7a0c156da9383b", - "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" - } - }, - "payment": { - "weixin": { - "__platform__": ["ios", "android"], - "appid": "wxae7a0c156da9383b", - "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" - }, - "alipay": { - "__platform__": ["ios", "android"] - } - }, - "share": { - "weixin": { - "appid": "wxae7a0c156da9383b", - "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" - } - } - }, - "orientation": ["portrait-primary"], - "splashscreen": { - "androidStyle": "common", - "iosStyle": "common", - "useOriginalMsgbox": true - }, - "icons": { - "android": { - "hdpi": "unpackage/res/icons/72x72.png", - "xhdpi": "unpackage/res/icons/96x96.png", - "xxhdpi": "unpackage/res/icons/144x144.png", - "xxxhdpi": "unpackage/res/icons/192x192.png" - }, - "ios": { - "appstore": "unpackage/res/icons/1024x1024.png", - "ipad": { - "app": "unpackage/res/icons/76x76.png", - "app@2x": "unpackage/res/icons/152x152.png", - "notification": "unpackage/res/icons/20x20.png", - "notification@2x": "unpackage/res/icons/40x40.png", - "proapp@2x": "unpackage/res/icons/167x167.png", - "settings": "unpackage/res/icons/29x29.png", - "settings@2x": "unpackage/res/icons/58x58.png", - "spotlight": "unpackage/res/icons/40x40.png", - "spotlight@2x": "unpackage/res/icons/80x80.png" - }, - "iphone": { - "app@2x": "unpackage/res/icons/120x120.png", - "app@3x": "unpackage/res/icons/180x180.png", - "notification@2x": "unpackage/res/icons/40x40.png", - "notification@3x": "unpackage/res/icons/60x60.png", - "settings@2x": "unpackage/res/icons/58x58.png", - "settings@3x": "unpackage/res/icons/87x87.png", - "spotlight@2x": "unpackage/res/icons/80x80.png", - "spotlight@3x": "unpackage/res/icons/120x120.png" - } - } - } - } - }, - "quickapp": {}, - "quickapp-native": { - "icon": "/static/logo.png", - "package": "com.example.demo", - "features": [{ - "name": "system.clipboard" - }] - }, - "quickapp-webview": { - "icon": "/static/logo.png", - "package": "com.example.demo", - "minPlatformVersion": 1070, - "versionName": "1.0.0", - "versionCode": 100 - }, - "mp-weixin": { - "appid": "wx53b5ac263b9cdb5b", - "setting": { - "urlCheck": false, - "minified": true, - "postcss": true - }, - "optimization": { - "subPackages": true - }, - "plugins": {}, - "lazyCodeLoading": "requiredComponents", - "usingComponents": {}, - "permission": {}, - "requiredPrivateInfos": ["chooseAddress"] - }, - "mp-alipay": { - "usingComponents": true - }, - "mp-baidu": { - "usingComponents": true - }, - "mp-toutiao": { - "usingComponents": true - }, - "mp-jd": { - "usingComponents": true - }, - "h5": { - "template": "index.html", - "router": { - "mode": "hash", - "base": "./" - }, - "sdkConfigs": { - "maps": {} - }, - "async": { - "timeout": 20000 - }, - "title": "芋道商城", - "optimization": { - "treeShaking": { - "enable": true - } - } - }, - "vueVersion": "3", - "_spaceID": "192b4892-5452-4e1d-9f09-eee1ece40639", - "locale": "zh-Hans", - "fallbackLocale": "zh-Hans" + "name": "芋道商城", + "appid": "__UNI__460BC4C", + "description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。", + "versionName": "2.1.0", + "versionCode": 183, + "transformPx": false, + "app-plus": { + "usingComponents": true, + "nvueCompiler": "uni-app", + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "nvueLaunchMode": "fast", + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + "safearea": { + "bottom": { + "offset": "none" + } + }, + "modules": { + "Payment": {}, + "Share": {}, + "VideoPlayer": {}, + "OAuth": {} + }, + "distribute": { + "android": { + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "minSdkVersion": 21, + "schemes": "shopro" + }, + "ios": { + "urlschemewhitelist": [ + "baidumap", + "iosamap" + ], + "dSYMs": false, + "privacyDescription": { + "NSPhotoLibraryUsageDescription": "需要同意访问您的相册选取图片才能完善该条目", + "NSPhotoLibraryAddUsageDescription": "需要同意访问您的相册才能保存该图片", + "NSCameraUsageDescription": "需要同意访问您的摄像头拍摄照片才能完善该条目", + "NSUserTrackingUsageDescription": "开启追踪并不会获取您在其它站点的隐私信息,该行为仅用于标识设备,保障服务安全和提升浏览体验" + }, + "urltypes": "shopro", + "capabilities": { + "entitlements": { + "com.apple.developer.associated-domains": [ + "applinks:shopro.sheepjs.com" + ] + } + }, + "idfa": true + }, + "sdkConfigs": { + "speech": { + "ifly": {} + }, + "ad": {}, + "oauth": { + "apple": {}, + "weixin": { + "appid": "wxae7a0c156da9383b", + "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" + } + }, + "payment": { + "weixin": { + "__platform__": [ + "ios", + "android" + ], + "appid": "wxae7a0c156da9383b", + "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" + }, + "alipay": { + "__platform__": [ + "ios", + "android" + ] + } + }, + "share": { + "weixin": { + "appid": "wxae7a0c156da9383b", + "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" + } + } + }, + "orientation": [ + "portrait-primary" + ], + "splashscreen": { + "androidStyle": "common", + "iosStyle": "common", + "useOriginalMsgbox": true + }, + "icons": { + "android": { + "hdpi": "unpackage/res/icons/72x72.png", + "xhdpi": "unpackage/res/icons/96x96.png", + "xxhdpi": "unpackage/res/icons/144x144.png", + "xxxhdpi": "unpackage/res/icons/192x192.png" + }, + "ios": { + "appstore": "unpackage/res/icons/1024x1024.png", + "ipad": { + "app": "unpackage/res/icons/76x76.png", + "app@2x": "unpackage/res/icons/152x152.png", + "notification": "unpackage/res/icons/20x20.png", + "notification@2x": "unpackage/res/icons/40x40.png", + "proapp@2x": "unpackage/res/icons/167x167.png", + "settings": "unpackage/res/icons/29x29.png", + "settings@2x": "unpackage/res/icons/58x58.png", + "spotlight": "unpackage/res/icons/40x40.png", + "spotlight@2x": "unpackage/res/icons/80x80.png" + }, + "iphone": { + "app@2x": "unpackage/res/icons/120x120.png", + "app@3x": "unpackage/res/icons/180x180.png", + "notification@2x": "unpackage/res/icons/40x40.png", + "notification@3x": "unpackage/res/icons/60x60.png", + "settings@2x": "unpackage/res/icons/58x58.png", + "settings@3x": "unpackage/res/icons/87x87.png", + "spotlight@2x": "unpackage/res/icons/80x80.png", + "spotlight@3x": "unpackage/res/icons/120x120.png" + } + } + } + } + }, + "quickapp": {}, + "quickapp-native": { + "icon": "/static/logo.png", + "package": "com.example.demo", + "features": [ + { + "name": "system.clipboard" + } + ] + }, + "quickapp-webview": { + "icon": "/static/logo.png", + "package": "com.example.demo", + "minPlatformVersion": 1070, + "versionName": "1.0.0", + "versionCode": 100 + }, + "mp-weixin": { + "appid": "wx53b5ac263b9cdb5b", + "setting": { + "urlCheck": false, + "minified": true, + "postcss": true + }, + "optimization": { + "subPackages": true + }, + "plugins": {}, + "lazyCodeLoading": "requiredComponents", + "usingComponents": {}, + "permission": {}, + "requiredPrivateInfos": [ + "chooseAddress" + ] + }, + "mp-alipay": { + "usingComponents": true + }, + "mp-baidu": { + "usingComponents": true + }, + "mp-toutiao": { + "usingComponents": true + }, + "mp-jd": { + "usingComponents": true + }, + "h5": { + "template": "index.html", + "router": { + "mode": "hash", + "base": "./" + }, + "sdkConfigs": { + "maps": {} + }, + "async": { + "timeout": 20000 + }, + "title": "芋道商城", + "optimization": { + "treeShaking": { + "enable": true + } + } + }, + "vueVersion": "3", + "_spaceID": "192b4892-5452-4e1d-9f09-eee1ece40639", + "locale": "zh-Hans", + "fallbackLocale": "zh-Hans" } \ No newline at end of file diff --git a/yudao-mall-uniapp-master/pages.json b/yudao-mall-uniapp-master/pages.json index 1e14b74..77c041b 100644 --- a/yudao-mall-uniapp-master/pages.json +++ b/yudao-mall-uniapp-master/pages.json @@ -261,6 +261,42 @@ "group": "用户中心" } }, + { + "path": "prize", + "style": { + "navigationBarTitleText": "抽奖" + }, + "meta": { + "auth": true, + "sync": true, + "title": "抽奖活动", + "group": "用户中心" + } + }, + { + "path": "PrizesWon", + "style": { + "navigationBarTitleText": "已获奖品" + }, + "meta": { + "auth": true, + "sync": true, + "title": "抽奖活动", + "group": "用户中心" + } + }, + { + "path": "ActivityRules", + "style": { + "navigationBarTitleText": "活动规则" + }, + "meta": { + "auth": true, + "sync": true, + "title": "活动规则", + "group": "用户中心" + } + }, { "path": "goods-collect", "style": { @@ -297,6 +333,18 @@ "group": "用户中心" } }, + { + "path": "address/listt", + "style": { + "navigationBarTitleText": "收货地址" + }, + "meta": { + "auth": true, + "sync": true, + "title": "地址管理", + "group": "用户中心" + } + }, { "path": "address/edit", "style": { @@ -635,7 +683,7 @@ ], "globalStyle": { "navigationBarTextStyle": "black", - "navigationBarTitleText": "芋道商城", + "navigationBarTitleText": "郑大钒水", "navigationBarBackgroundColor": "#FFFFFF", "backgroundColor": "#FFFFFF", "navigationStyle": "custom" diff --git a/yudao-mall-uniapp-master/pages/index/index.vue b/yudao-mall-uniapp-master/pages/index/index.vue index 208c959..e1f87dd 100644 --- a/yudao-mall-uniapp-master/pages/index/index.vue +++ b/yudao-mall-uniapp-master/pages/index/index.vue @@ -51,10 +51,15 @@ onLoad((options) => { // #ifdef MP // 小程序识别二维码 - if (options.scene) { - const sceneParams = decodeURIComponent(options.scene).split('='); + if (options.q) { + const sceneParams = decodeURIComponent(options.q).split('='); console.log("sceneParams=>",sceneParams); options[sceneParams[0]] = sceneParams[1]; + console.log(options,'1123456'); + uni.setStorageSync('bindUserId', sceneParams[1]); + } + if (options.r) { + uni.setStorageSync('bindUserId', options.r); } // #endif diff --git a/yudao-mall-uniapp-master/pages/order/confirm.vue b/yudao-mall-uniapp-master/pages/order/confirm.vue index 69e7f4d..908cc97 100644 --- a/yudao-mall-uniapp-master/pages/order/confirm.vue +++ b/yudao-mall-uniapp-master/pages/order/confirm.vue @@ -1,14 +1,27 @@