From 1703d0819d3cab4619709c097224d8d74de0ef4a Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 18 May 2022 21:44:05 +0800 Subject: [PATCH] 20220518 --- src/main/java/cc/mrbird/febs/mall/mapper/MallActAwardSetMapper.java | 14 src/main/resources/templates/febs/views/modules/act/luckdrawList.html | 148 ++++ src/main/java/cc/mrbird/febs/mall/mapper/MallActSetMapper.java | 14 src/main/java/cc/mrbird/febs/mall/dto/AddMallActAwardDto.java | 22 src/main/java/cc/mrbird/febs/mall/dto/MallActAwardUpdateDto.java | 23 src/main/java/cc/mrbird/febs/mall/entity/MallActAwardSet.java | 42 + src/main/resources/templates/febs/views/modules/act/actAddNew.html | 323 ++++++++ src/main/resources/mapper/modules/MallActWinRecordMapper.xml | 9 src/main/resources/templates/febs/views/modules/act/actUpdateNew.html | 337 +++++++++ src/main/java/cc/mrbird/febs/mall/vo/AdminMallActLuckdrawRecordVo.java | 27 src/main/java/cc/mrbird/febs/mall/mapper/MallActWinRecordMapper.java | 11 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallActServiceImpl.java | 15 src/main/java/cc/mrbird/febs/mall/controller/ApiMallActController.java | 19 src/main/java/cc/mrbird/febs/mall/entity/MallActWinRecord.java | 31 src/main/java/cc/mrbird/febs/mall/dto/MallActUpdateDto.java | 30 src/main/resources/mapper/modules/MallActSetMapper.xml | 26 src/main/java/cc/mrbird/febs/mall/controller/AdminMallActController.java | 97 ++ src/main/resources/mapper/modules/MallActLuckdrawRecordMapper.xml | 30 src/main/java/cc/mrbird/febs/mall/service/IApiMallActService.java | 4 src/main/java/cc/mrbird/febs/mall/vo/AdminMallActSetVo.java | 54 + src/main/java/cc/mrbird/febs/mall/dto/AddMallActDto.java | 30 src/main/java/cc/mrbird/febs/mall/controller/ViewMallActController.java | 74 ++ src/main/java/cc/mrbird/febs/mall/entity/MallActLuckdrawRecord.java | 31 src/main/java/cc/mrbird/febs/mall/service/IAdminMallActService.java | 35 src/main/java/cc/mrbird/febs/mall/entity/MallActSet.java | 47 + src/main/resources/templates/febs/views/modules/act/actList.html | 209 +++++ src/main/resources/mapper/modules/MallActAwardSetMapper.xml | 13 src/main/java/cc/mrbird/febs/mall/mapper/MallActLuckdrawRecordMapper.java | 15 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallActServiceImpl.java | 315 ++++++++ src/main/resources/templates/febs/views/modules/act/winRecordInfo.html | 69 + 30 files changed, 2,114 insertions(+), 0 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminMallActController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminMallActController.java new file mode 100644 index 0000000..0b238be --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminMallActController.java @@ -0,0 +1,97 @@ +package cc.mrbird.febs.mall.controller; + +import cc.mrbird.febs.common.annotation.ControllerEndpoint; +import cc.mrbird.febs.common.controller.BaseController; +import cc.mrbird.febs.common.entity.FebsResponse; +import cc.mrbird.febs.common.entity.QueryRequest; +import cc.mrbird.febs.mall.dto.AddMallActDto; +import cc.mrbird.febs.mall.dto.AddMallGoodsDto; +import cc.mrbird.febs.mall.dto.MallActUpdateDto; +import cc.mrbird.febs.mall.dto.MallGoodsUpdateDto; +import cc.mrbird.febs.mall.entity.MallActLuckdrawRecord; +import cc.mrbird.febs.mall.entity.MallActSet; +import cc.mrbird.febs.mall.entity.MallGoods; +import cc.mrbird.febs.mall.service.IAdminMallActService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.Map; + +@Slf4j +@Validated +@RestController +@RequiredArgsConstructor +@RequestMapping(value = "/admin/act") +public class AdminMallActController extends BaseController { + + private final IAdminMallActService iAdminMallActService; + + /** + * 活动-列表 + */ + @GetMapping("actList") + public FebsResponse getActList(MallActSet mallActSet, QueryRequest request) { + Map<String, Object> data = getDataTable(iAdminMallActService.getActListInPage(mallActSet, request)); + return new FebsResponse().success().data(data); + } + + /** + * 活动-新增 + */ + @PostMapping("addMallAct") + @ControllerEndpoint(operation = "活动-新增", exceptionMessage = "新增失败") + public FebsResponse addMallAct(@RequestBody @Valid AddMallActDto addMallActDto) { + return iAdminMallActService.addMallAct(addMallActDto); + } + + /** + * 活动-开启 + */ + @GetMapping("startMallAct/{id}") + @ControllerEndpoint(operation = "活动-开启", exceptionMessage = "开启失败") + public FebsResponse startMallAct(@NotNull(message = "{required}") @PathVariable Long id) { + return iAdminMallActService.startMallAct(id); + } + + /** + * 活动-关闭 + */ + @GetMapping("closeMallAct/{id}") + @ControllerEndpoint(operation = "活动-关闭", exceptionMessage = "关闭失败") + public FebsResponse closeMallAct(@NotNull(message = "{required}") @PathVariable Long id) { + return iAdminMallActService.closeMallAct(id); + } + + /** + * 活动-删除 + */ + @GetMapping("delMallAct/{id}") + @ControllerEndpoint(operation = "活动-删除", exceptionMessage = "删除失败") + public FebsResponse delMallAct(@NotNull(message = "{required}") @PathVariable Long id) { + return iAdminMallActService.delMallAct(id); + } + + /** + * 活动-编辑 + */ + @PostMapping("updateMallAct") + @ControllerEndpoint(operation = "商品-编辑", exceptionMessage = "操作失败") + public FebsResponse updateMallAct(@RequestBody @Valid MallActUpdateDto mallActUpdateDto) { + return iAdminMallActService.updateMallAct(mallActUpdateDto); + } + + /** + * 抽奖记录-列表 + */ + @GetMapping("luckdrawList") + public FebsResponse getLuckdrawList(MallActLuckdrawRecord mallActLuckdrawRecord, QueryRequest request) { + Map<String, Object> data = getDataTable(iAdminMallActService.getLuckdrawListInPage(mallActLuckdrawRecord, request)); + return new FebsResponse().success().data(data); + } + + +} diff --git a/src/main/java/cc/mrbird/febs/mall/controller/ApiMallActController.java b/src/main/java/cc/mrbird/febs/mall/controller/ApiMallActController.java new file mode 100644 index 0000000..84c0402 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/controller/ApiMallActController.java @@ -0,0 +1,19 @@ +package cc.mrbird.febs.mall.controller; + +import cc.mrbird.febs.mall.service.IApiMallActService; +import io.swagger.annotations.Api; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController +@RequestMapping(value = "/api/act") +@RequiredArgsConstructor +@Api(value = "ApiApplyController", tags = "活动接口类") +public class ApiMallActController { + + private final IApiMallActService iApiMallActService; + +} diff --git a/src/main/java/cc/mrbird/febs/mall/controller/ViewMallActController.java b/src/main/java/cc/mrbird/febs/mall/controller/ViewMallActController.java new file mode 100644 index 0000000..178b63c --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/controller/ViewMallActController.java @@ -0,0 +1,74 @@ +package cc.mrbird.febs.mall.controller; + +import cc.mrbird.febs.common.controller.BaseController; +import cc.mrbird.febs.common.entity.FebsConstant; +import cc.mrbird.febs.common.utils.FebsUtil; +import cc.mrbird.febs.mall.entity.MallActSet; +import cc.mrbird.febs.mall.entity.MallActWinRecord; +import cc.mrbird.febs.mall.entity.MallGoods; +import cc.mrbird.febs.mall.service.IAdminMallActService; +import lombok.RequiredArgsConstructor; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller("actView") +@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/act") +@RequiredArgsConstructor +public class ViewMallActController extends BaseController { + + private final IAdminMallActService iAdminMallActService; + + /** + * 活动-列表 + */ + @GetMapping("actList") + @RequiresPermissions("actList:view") + public String actList() { + return FebsUtil.view("modules/act/actList"); + } + + /** + * 活动-新增 + */ + @GetMapping("actAddNew") + @RequiresPermissions("actAddNew:add") + public String goodsAddNew() { + return FebsUtil.view("modules/act/actAddNew"); + } + + /** + * 活动-编辑-详情 + */ + @GetMapping("actUpdateNew/{id}") + @RequiresPermissions("actUpdateNew:update") + public String goodsUpdate(@PathVariable long id, Model model) { + MallActSet data = iAdminMallActService.selectMallActById(id); + model.addAttribute("actInfo", data); + return FebsUtil.view("modules/act/actUpdateNew"); + } + + /** + * 抽奖记录-列表 + */ + @GetMapping("luckdrawList") + @RequiresPermissions("luckdrawList:view") + public String luckdrawList() { + return FebsUtil.view("modules/act/luckdrawList"); + } + + /** + * 抽奖记录-查看奖品 + */ + @GetMapping("luckdrawWin/{id}") + @RequiresPermissions("luckdrawWin:see") + public String luckdrawWin(@PathVariable long id, Model model) { + MallActWinRecord data = iAdminMallActService.selectMallActWinInfoById(id); + model.addAttribute("winInfo", data); + return FebsUtil.view("modules/act/winRecordInfo"); + } + +} diff --git a/src/main/java/cc/mrbird/febs/mall/dto/AddMallActAwardDto.java b/src/main/java/cc/mrbird/febs/mall/dto/AddMallActAwardDto.java new file mode 100644 index 0000000..6bac9ad --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/dto/AddMallActAwardDto.java @@ -0,0 +1,22 @@ +package cc.mrbird.febs.mall.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +@Data +@ApiModel(value = "AddMallActAwardDto", description = "参数接收类") +public class AddMallActAwardDto { + + //奖品名称 + private String awardName; + //奖品图片 + private String awardImage; + //奖品总数 + private Integer awardTotal; + //已中奖数量 + private Integer awardCnt; + //类型 1:积分 2:佣金 3:谢谢参与 + private Integer awardType; + //积分或佣金数量 + private Integer awardValue; +} diff --git a/src/main/java/cc/mrbird/febs/mall/dto/AddMallActDto.java b/src/main/java/cc/mrbird/febs/mall/dto/AddMallActDto.java new file mode 100644 index 0000000..80e25a6 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/dto/AddMallActDto.java @@ -0,0 +1,30 @@ +package cc.mrbird.febs.mall.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +@ApiModel(value = "AddMallActDto", description = "参数接收类") +public class AddMallActDto { + + //活动编码 + private String actCode; + //活动名称 + private String actName; + //开始时间 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actStartTime; + //结束时间 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actEndTime; + //每次参与需要积分数目 + private Integer actScoreCnt; + //活动说明 + private String actRemark; + + private List<AddMallActAwardDto> addMallActAwardDtos; +} diff --git a/src/main/java/cc/mrbird/febs/mall/dto/MallActAwardUpdateDto.java b/src/main/java/cc/mrbird/febs/mall/dto/MallActAwardUpdateDto.java new file mode 100644 index 0000000..411bfd2 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/dto/MallActAwardUpdateDto.java @@ -0,0 +1,23 @@ +package cc.mrbird.febs.mall.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +@Data +@ApiModel(value = "MallActAwardUpdateDto", description = "参数接收类") +public class MallActAwardUpdateDto { + + private Long id; + //奖品名称 + private String awardName; + //奖品图片 + private String awardImage; + //奖品总数 + private Integer awardTotal; + //已中奖数量 + private Integer awardCnt; + //类型 1:积分 2:佣金 3:谢谢参与 + private Integer awardType; + //积分或佣金数量 + private Integer awardValue; +} diff --git a/src/main/java/cc/mrbird/febs/mall/dto/MallActUpdateDto.java b/src/main/java/cc/mrbird/febs/mall/dto/MallActUpdateDto.java new file mode 100644 index 0000000..6f7738c --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/dto/MallActUpdateDto.java @@ -0,0 +1,30 @@ +package cc.mrbird.febs.mall.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; +import java.util.List; +@Data +@ApiModel(value = "MallActUpdateDto", description = "参数接收类") +public class MallActUpdateDto { + + private Long id; + //活动编码 + private String actCode; + //活动名称 + private String actName; + //开始时间 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actStartTime; + //结束时间 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actEndTime; + //每次参与需要积分数目 + private Integer actScoreCnt; + //活动说明 + private String actRemark; + + private List<MallActAwardUpdateDto> updateMallActAwardDtos; +} diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallActAwardSet.java b/src/main/java/cc/mrbird/febs/mall/entity/MallActAwardSet.java new file mode 100644 index 0000000..43eedf8 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/entity/MallActAwardSet.java @@ -0,0 +1,42 @@ +package cc.mrbird.febs.mall.entity; + +import cc.mrbird.febs.common.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * 活动奖品设置表 + */ +@Data +@TableName("mall_act_award_set") +public class MallActAwardSet extends BaseEntity { + + /** + * 积分 + */ + public static final Integer AWARD_TYPE_JF = 1; + /** + * 佣金 + */ + public static final Integer AWARD_TYPE_YJ = 2; + /** + * 谢谢参与 + */ + public static final Integer AWARD_TYPE_XXCY = 3; + + //奖品名称 + private String awardName; + //奖品图片 + private String awardImage; + //奖品总数 + private Integer awardTotal; + //已中奖数量 + private Integer awardCnt; + //类型 1:积分 2:佣金 3:谢谢参与 + private Integer awardType; + //积分或佣金数量 + private Integer awardValue; + //活动主表ID + private Long actId; + +} diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallActLuckdrawRecord.java b/src/main/java/cc/mrbird/febs/mall/entity/MallActLuckdrawRecord.java new file mode 100644 index 0000000..c79de77 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/entity/MallActLuckdrawRecord.java @@ -0,0 +1,31 @@ +package cc.mrbird.febs.mall.entity; + +import cc.mrbird.febs.common.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * 抽奖记录表 + */ +@Data +@TableName("mall_act_luckdraw_record") +public class MallActLuckdrawRecord extends BaseEntity { + + //参与人ID + private Long memberId; + //活动ID + private Long actId; + //活动名称 + private String actName; + //消耗积分数目 + private Integer actScoreCnt; + //是否中奖 0:没有 1中奖 + private Integer status; + + @TableField(exist = false) + private String name; + @TableField(exist = false) + private String account; + +} diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallActSet.java b/src/main/java/cc/mrbird/febs/mall/entity/MallActSet.java new file mode 100644 index 0000000..a15ba82 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/entity/MallActSet.java @@ -0,0 +1,47 @@ +package cc.mrbird.febs.mall.entity; + +import cc.mrbird.febs.common.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * 转盘活动设置 + */ +@Data +@TableName("mall_act_set") +public class MallActSet extends BaseEntity { + + /** + * 开启 + */ + public static final Integer ACT_STATUS_ENABLE = 1; + /** + * 关闭 + */ + public static final Integer ACT_STATUS_DISABLED = 0; + //活动编码 + private String actCode; + //活动名称 + private String actName; + //开始时间 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actStartTime; + //结束时间 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actEndTime; + //每次参与需要积分数目 + private Integer actScoreCnt; + //活动状态 1-开启 0-关闭 + private Integer actStatus; + //活动说明 + private String actRemark; + + @TableField(exist = false) + private List<MallActAwardSet> mallActAwardSets; + +} diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallActWinRecord.java b/src/main/java/cc/mrbird/febs/mall/entity/MallActWinRecord.java new file mode 100644 index 0000000..a407112 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/entity/MallActWinRecord.java @@ -0,0 +1,31 @@ +package cc.mrbird.febs.mall.entity; + +import cc.mrbird.febs.common.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * 中奖记录表 + */ +@Data +@TableName("mall_act_win_record") +public class MallActWinRecord extends BaseEntity { + + //参与人ID + private Long memberId; + //活动ID + private Long actId; + //活动名称 + private String actName; + //奖品ID + private Long awardId; + //奖品名称 + private String awardName; + //类型 1:积分 2:佣金 + private Integer awardType; + //积分或佣金数量 + private Integer awardValue; + //抽奖记录ID + private Long recordId; + +} diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/MallActAwardSetMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/MallActAwardSetMapper.java new file mode 100644 index 0000000..90f8696 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/mapper/MallActAwardSetMapper.java @@ -0,0 +1,14 @@ +package cc.mrbird.febs.mall.mapper; + +import cc.mrbird.febs.mall.entity.MallActAwardSet; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface MallActAwardSetMapper extends BaseMapper<MallActAwardSet> { + + void deleteByActId(Long id); + + List<MallActAwardSet> selectMallActAwardByActId(@Param("id") long id); +} diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/MallActLuckdrawRecordMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/MallActLuckdrawRecordMapper.java new file mode 100644 index 0000000..1097a39 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/mapper/MallActLuckdrawRecordMapper.java @@ -0,0 +1,15 @@ +package cc.mrbird.febs.mall.mapper; + +import cc.mrbird.febs.mall.entity.MallActLuckdrawRecord; +import cc.mrbird.febs.mall.vo.AdminMallActLuckdrawRecordVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; + +public interface MallActLuckdrawRecordMapper extends BaseMapper<MallActLuckdrawRecord> { + + IPage<AdminMallActLuckdrawRecordVo> selectMallActLuckdrawsInPage(Page<AdminMallActLuckdrawRecordVo> page, + @Param("record")MallActLuckdrawRecord mallActLuckdrawRecord); + +} diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/MallActSetMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/MallActSetMapper.java new file mode 100644 index 0000000..39c372c --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/mapper/MallActSetMapper.java @@ -0,0 +1,14 @@ +package cc.mrbird.febs.mall.mapper; + +import cc.mrbird.febs.mall.entity.MallActSet; +import cc.mrbird.febs.mall.vo.AdminMallActSetVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; + +public interface MallActSetMapper extends BaseMapper<MallActSet> { + + IPage<AdminMallActSetVo> selectMallActsInPage(Page<AdminMallActSetVo> page, @Param("record")MallActSet mallActSet); + +} diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/MallActWinRecordMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/MallActWinRecordMapper.java new file mode 100644 index 0000000..6e4775d --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/mapper/MallActWinRecordMapper.java @@ -0,0 +1,11 @@ +package cc.mrbird.febs.mall.mapper; + +import cc.mrbird.febs.mall.entity.MallActWinRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +public interface MallActWinRecordMapper extends BaseMapper<MallActWinRecord> { + + MallActWinRecord selectByLuckDrawId(@Param("id")long id); + +} diff --git a/src/main/java/cc/mrbird/febs/mall/service/IAdminMallActService.java b/src/main/java/cc/mrbird/febs/mall/service/IAdminMallActService.java new file mode 100644 index 0000000..4e13e61 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/service/IAdminMallActService.java @@ -0,0 +1,35 @@ +package cc.mrbird.febs.mall.service; + +import cc.mrbird.febs.common.entity.FebsResponse; +import cc.mrbird.febs.common.entity.QueryRequest; +import cc.mrbird.febs.mall.dto.AddMallActDto; +import cc.mrbird.febs.mall.dto.MallActUpdateDto; +import cc.mrbird.febs.mall.entity.MallActLuckdrawRecord; +import cc.mrbird.febs.mall.entity.MallActSet; +import cc.mrbird.febs.mall.entity.MallActWinRecord; +import cc.mrbird.febs.mall.entity.MallGoods; +import cc.mrbird.febs.mall.vo.AdminMallActLuckdrawRecordVo; +import cc.mrbird.febs.mall.vo.AdminMallActSetVo; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface IAdminMallActService extends IService<MallActSet> { + + IPage<AdminMallActSetVo> getActListInPage(MallActSet mallActSet, QueryRequest request); + + FebsResponse addMallAct(AddMallActDto addMallActDto); + + FebsResponse startMallAct(Long id); + + FebsResponse closeMallAct(Long id); + + FebsResponse delMallAct(Long id); + + MallActSet selectMallActById(long id); + + FebsResponse updateMallAct(MallActUpdateDto mallActUpdateDto); + + IPage<AdminMallActLuckdrawRecordVo> getLuckdrawListInPage(MallActLuckdrawRecord mallActLuckdrawRecord, QueryRequest request); + + MallActWinRecord selectMallActWinInfoById(long id); +} diff --git a/src/main/java/cc/mrbird/febs/mall/service/IApiMallActService.java b/src/main/java/cc/mrbird/febs/mall/service/IApiMallActService.java new file mode 100644 index 0000000..6439ac6 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/service/IApiMallActService.java @@ -0,0 +1,4 @@ +package cc.mrbird.febs.mall.service; + +public interface IApiMallActService { +} diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallActServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallActServiceImpl.java new file mode 100644 index 0000000..b75b780 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallActServiceImpl.java @@ -0,0 +1,315 @@ +package cc.mrbird.febs.mall.service.impl; + +import cc.mrbird.febs.common.entity.FebsResponse; +import cc.mrbird.febs.common.entity.QueryRequest; +import cc.mrbird.febs.mall.dto.AddMallActAwardDto; +import cc.mrbird.febs.mall.dto.AddMallActDto; +import cc.mrbird.febs.mall.dto.MallActAwardUpdateDto; +import cc.mrbird.febs.mall.dto.MallActUpdateDto; +import cc.mrbird.febs.mall.entity.*; +import cc.mrbird.febs.mall.mapper.MallActAwardSetMapper; +import cc.mrbird.febs.mall.mapper.MallActLuckdrawRecordMapper; +import cc.mrbird.febs.mall.mapper.MallActSetMapper; +import cc.mrbird.febs.mall.mapper.MallActWinRecordMapper; +import cc.mrbird.febs.mall.service.IAdminMallActService; +import cc.mrbird.febs.mall.vo.AdminMallActLuckdrawRecordVo; +import cc.mrbird.febs.mall.vo.AdminMallActSetVo; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +@Transactional +public class AdminMallActServiceImpl extends ServiceImpl<MallActSetMapper, MallActSet> implements IAdminMallActService { + + private final MallActAwardSetMapper mallActAwardSetMapper; + private final MallActLuckdrawRecordMapper mallActLuckdrawRecordMapper; + private final MallActWinRecordMapper mallActWinRecordMapper; + + @Override + public IPage<AdminMallActSetVo> getActListInPage(MallActSet mallActSet, QueryRequest request) { + Page<AdminMallActSetVo> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<AdminMallActSetVo> adminMallActSetVos = this.baseMapper.selectMallActsInPage(page, mallActSet); + return adminMallActSetVos; + } + + @Override + @Transactional + public FebsResponse addMallAct(AddMallActDto addMallActDto) { + String actName = addMallActDto.getActName(); + if (StrUtil.isEmpty(actName)) { + return new FebsResponse().fail().message("活动名称不能为空"); + } + String actCode = addMallActDto.getActCode(); + if (StrUtil.isEmpty(actCode)) { + return new FebsResponse().fail().message("活动编码不能为空"); + } + Date actStartTime = addMallActDto.getActStartTime(); + if(ObjectUtil.isEmpty(actStartTime)){ + return new FebsResponse().fail().message("开始日期不能为空"); + } + Date actEndTime = addMallActDto.getActEndTime(); + if(ObjectUtil.isEmpty(actEndTime)){ + return new FebsResponse().fail().message("结束日期不能为空"); + } + int compare = DateUtil.compare(actStartTime, actEndTime); + if(compare >= 0){ + return new FebsResponse().fail().message("开始日期要小于结束日期"); + } + Integer actScoreCnt = addMallActDto.getActScoreCnt()==null?0:addMallActDto.getActScoreCnt(); + if(actScoreCnt <= 0){ + return new FebsResponse().fail().message("请输入正整数"); + } + List<AddMallActAwardDto> addMallActAwardDtos = addMallActDto.getAddMallActAwardDtos(); + if(CollUtil.isEmpty(addMallActAwardDtos)){ + return new FebsResponse().fail().message("请设置奖品"); + } + for(AddMallActAwardDto addMallActAwardDto : addMallActAwardDtos){ + String awardName = addMallActAwardDto.getAwardName(); + if (StrUtil.isEmpty(awardName)) { + return new FebsResponse().fail().message("奖品名称不能为空"); + } + String awardImage = addMallActAwardDto.getAwardImage(); + if (StrUtil.isEmpty(awardImage)) { + return new FebsResponse().fail().message("奖品图不能为空"); + } + Integer awardTotal = addMallActAwardDto.getAwardTotal()==null?0:addMallActAwardDto.getAwardTotal(); + if(awardTotal <= 0){ + return new FebsResponse().fail().message("奖品总数要大于零"); + } + Integer awardCnt = addMallActAwardDto.getAwardCnt()==null?0:addMallActAwardDto.getAwardCnt(); + if(awardCnt < 0){ + return new FebsResponse().fail().message("请输入正整数"); + } + if(awardCnt > awardTotal){ + return new FebsResponse().fail().message("要小于奖品总数"); + } + Integer awardType = addMallActAwardDto.getAwardType(); + if(awardType != MallActAwardSet.AWARD_TYPE_JF && awardType != MallActAwardSet.AWARD_TYPE_YJ && awardType != MallActAwardSet.AWARD_TYPE_XXCY){ + return new FebsResponse().fail().message("请选择正确的奖品类型"); + } + Integer awardValue = addMallActAwardDto.getAwardValue()==null?0:addMallActAwardDto.getAwardValue(); + if(awardValue < 0){ + return new FebsResponse().fail().message("奖金数量不能小于零"); + } + } + MallActSet mallActSet = new MallActSet(); + mallActSet.setActCode(actCode); + mallActSet.setActName(actName); + mallActSet.setActStartTime(actStartTime); + mallActSet.setActEndTime(actEndTime); + mallActSet.setActScoreCnt(actScoreCnt); + mallActSet.setActStatus(MallActSet.ACT_STATUS_DISABLED); + String actRemark = addMallActDto.getActRemark(); + if(StrUtil.isNotEmpty(actRemark)){ + mallActSet.setActRemark(actRemark); + } + this.baseMapper.insert(mallActSet); + + //新增奖品 + for(AddMallActAwardDto addMallActAwardDto : addMallActAwardDtos){ + String awardName = addMallActAwardDto.getAwardName(); + Integer awardTotal = addMallActAwardDto.getAwardTotal(); + Integer awardCnt = addMallActAwardDto.getAwardCnt(); + Integer awardType = addMallActAwardDto.getAwardType(); + Integer awardValue = addMallActAwardDto.getAwardValue(); + String awardImage = addMallActAwardDto.getAwardImage(); + Long actId = mallActSet.getId(); + MallActAwardSet mallActAwardSet = new MallActAwardSet(); + mallActAwardSet.setActId(actId); + mallActAwardSet.setAwardName(awardName); + mallActAwardSet.setAwardTotal(awardTotal); + mallActAwardSet.setAwardCnt(awardCnt); + mallActAwardSet.setAwardType(awardType); + mallActAwardSet.setAwardValue(awardValue); + mallActAwardSet.setAwardImage(awardImage); + mallActAwardSetMapper.insert(mallActAwardSet); + } + + return new FebsResponse().success().message("操作成功"); + } + + @Override + @Transactional + public FebsResponse startMallAct(Long id) { + MallActSet mallActSet = this.baseMapper.selectById(id); + if (ObjectUtil.isEmpty(mallActSet)) { + return new FebsResponse().fail().message("活动不存在,请刷新当前页面"); + } + mallActSet.setActStatus(MallActSet.ACT_STATUS_ENABLE); + this.baseMapper.updateById(mallActSet); + return new FebsResponse().success(); + } + + @Override + @Transactional + public FebsResponse closeMallAct(Long id) { + MallActSet mallActSet = this.baseMapper.selectById(id); + if (ObjectUtil.isEmpty(mallActSet)) { + return new FebsResponse().fail().message("活动不存在,请刷新当前页面"); + } + mallActSet.setActStatus(MallActSet.ACT_STATUS_DISABLED); + this.baseMapper.updateById(mallActSet); + return new FebsResponse().success(); + } + + @Override + @Transactional + public FebsResponse delMallAct(Long id) { + MallActSet mallActSet = this.baseMapper.selectById(id); + if (ObjectUtil.isEmpty(mallActSet)) { + return new FebsResponse().fail().message("活动不存在,请刷新当前页面"); + } + Integer actStatus = mallActSet.getActStatus(); + if (MallActSet.ACT_STATUS_ENABLE == actStatus) { + return new FebsResponse().fail().message("请先关闭该活动"); + } + this.baseMapper.deleteById(id); + mallActAwardSetMapper.deleteByActId(id); + return new FebsResponse().success(); + } + + @Override + public MallActSet selectMallActById(long id) { + MallActSet mallActSet = this.baseMapper.selectById(id); + List<MallActAwardSet> mallActAwardSets = mallActAwardSetMapper.selectMallActAwardByActId(id); + mallActSet.setMallActAwardSets(mallActAwardSets); + return mallActSet; + } + + @Override + @Transactional + public FebsResponse updateMallAct(MallActUpdateDto mallActUpdateDto) { + Long id = mallActUpdateDto.getId()==null?0:mallActUpdateDto.getId(); + MallActSet mallActSet = this.baseMapper.selectById(id); + if (ObjectUtil.isEmpty(mallActSet)) { + return new FebsResponse().fail().message("活动不存在,请刷新当前页面"); + } + String actName = mallActUpdateDto.getActName(); + if (StrUtil.isEmpty(actName)) { + return new FebsResponse().fail().message("活动名称不能为空"); + } + String actCode = mallActUpdateDto.getActCode(); + if (StrUtil.isEmpty(actCode)) { + return new FebsResponse().fail().message("活动编码不能为空"); + } + Date actStartTime = mallActUpdateDto.getActStartTime(); + if(ObjectUtil.isEmpty(actStartTime)){ + return new FebsResponse().fail().message("开始日期不能为空"); + } + Date actEndTime = mallActUpdateDto.getActEndTime(); + if(ObjectUtil.isEmpty(actEndTime)){ + return new FebsResponse().fail().message("结束日期不能为空"); + } + int compare = DateUtil.compare(actStartTime, actEndTime); + if(compare >= 0){ + return new FebsResponse().fail().message("开始日期要小于结束日期"); + } + Integer actScoreCnt = mallActUpdateDto.getActScoreCnt()==null?0:mallActUpdateDto.getActScoreCnt(); + if(actScoreCnt <= 0){ + return new FebsResponse().fail().message("请输入正整数"); + } + List<MallActAwardUpdateDto> mallActAwardUpdateDtos = mallActUpdateDto.getUpdateMallActAwardDtos(); + if(CollUtil.isEmpty(mallActAwardUpdateDtos)){ + return new FebsResponse().fail().message("请设置奖品"); + } + for(MallActAwardUpdateDto mallActAwardUpdateDto : mallActAwardUpdateDtos){ + String awardName = mallActAwardUpdateDto.getAwardName(); + if (StrUtil.isEmpty(awardName)) { + return new FebsResponse().fail().message("奖品名称不能为空"); + } + String awardImage = mallActAwardUpdateDto.getAwardImage(); + if (StrUtil.isEmpty(awardImage)) { + return new FebsResponse().fail().message("奖品图不能为空"); + } + Integer awardTotal = mallActAwardUpdateDto.getAwardTotal()==null?0:mallActAwardUpdateDto.getAwardTotal(); + if(awardTotal <= 0){ + return new FebsResponse().fail().message("奖品总数要大于零"); + } + Integer awardCnt = mallActAwardUpdateDto.getAwardCnt()==null?0:mallActAwardUpdateDto.getAwardCnt(); + if(awardCnt < 0){ + return new FebsResponse().fail().message("请输入正整数"); + } + if(awardCnt > awardTotal){ + return new FebsResponse().fail().message("要小于奖品总数"); + } + Integer awardType = mallActAwardUpdateDto.getAwardType(); + if(awardType != MallActAwardSet.AWARD_TYPE_JF && awardType != MallActAwardSet.AWARD_TYPE_YJ && awardType != MallActAwardSet.AWARD_TYPE_XXCY){ + return new FebsResponse().fail().message("请选择正确的奖品类型"); + } + Integer awardValue = mallActAwardUpdateDto.getAwardValue()==null?0:mallActAwardUpdateDto.getAwardValue(); + if(awardValue < 0){ + return new FebsResponse().fail().message("奖金数量不能小于零"); + } + } + mallActSet.setActCode(actCode); + mallActSet.setActName(actName); + mallActSet.setActStartTime(actStartTime); + mallActSet.setActEndTime(actEndTime); + mallActSet.setActScoreCnt(actScoreCnt); + mallActSet.setActStatus(MallActSet.ACT_STATUS_DISABLED); + String actRemark = mallActUpdateDto.getActRemark(); + if(StrUtil.isNotEmpty(actRemark)){ + mallActSet.setActRemark(actRemark); + } + this.baseMapper.updateById(mallActSet); + //新增奖品 + for(MallActAwardUpdateDto mallActAwardUpdateDto : mallActAwardUpdateDtos){ + String awardName = mallActAwardUpdateDto.getAwardName(); + Integer awardTotal = mallActAwardUpdateDto.getAwardTotal(); + Integer awardCnt = mallActAwardUpdateDto.getAwardCnt(); + Integer awardType = mallActAwardUpdateDto.getAwardType(); + Integer awardValue = mallActAwardUpdateDto.getAwardValue(); + String awardImage = mallActAwardUpdateDto.getAwardImage(); + if(ObjectUtil.isEmpty(mallActAwardUpdateDto.getId())){ + MallActAwardSet mallActAwardSet = new MallActAwardSet(); + mallActAwardSet.setActId(id); + mallActAwardSet.setAwardName(awardName); + mallActAwardSet.setAwardTotal(awardTotal); + mallActAwardSet.setAwardCnt(awardCnt); + mallActAwardSet.setAwardType(awardType); + mallActAwardSet.setAwardValue(awardValue); + mallActAwardSet.setAwardImage(awardImage); + mallActAwardSetMapper.insert(mallActAwardSet); + }else{ + MallActAwardSet mallActAwardSet = mallActAwardSetMapper.selectById(mallActAwardUpdateDto.getId()); + mallActAwardSet.setActId(id); + mallActAwardSet.setAwardName(awardName); + mallActAwardSet.setAwardTotal(awardTotal); + mallActAwardSet.setAwardCnt(awardCnt); + mallActAwardSet.setAwardType(awardType); + mallActAwardSet.setAwardValue(awardValue); + mallActAwardSet.setAwardImage(awardImage); + mallActAwardSetMapper.updateById(mallActAwardSet); + } + } + + return new FebsResponse().success().message("操作成功"); + } + + @Override + public IPage<AdminMallActLuckdrawRecordVo> getLuckdrawListInPage(MallActLuckdrawRecord mallActLuckdrawRecord, QueryRequest request) { + Page<AdminMallActLuckdrawRecordVo> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<AdminMallActLuckdrawRecordVo> adminMallActLuckdrawRecordVos = mallActLuckdrawRecordMapper.selectMallActLuckdrawsInPage(page, mallActLuckdrawRecord); + return adminMallActLuckdrawRecordVos; + } + + @Override + public MallActWinRecord selectMallActWinInfoById(long id) { + MallActWinRecord mallActWinRecord = mallActWinRecordMapper.selectByLuckDrawId(id); + return mallActWinRecord; + } +} diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallActServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallActServiceImpl.java new file mode 100644 index 0000000..05ebb48 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallActServiceImpl.java @@ -0,0 +1,15 @@ +package cc.mrbird.febs.mall.service.impl; + +import cc.mrbird.febs.mall.entity.MallActSet; +import cc.mrbird.febs.mall.mapper.MallActSetMapper; +import cc.mrbird.febs.mall.service.IApiMallActService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ApiMallActServiceImpl extends ServiceImpl<MallActSetMapper, MallActSet> implements IApiMallActService { +} diff --git a/src/main/java/cc/mrbird/febs/mall/vo/AdminMallActLuckdrawRecordVo.java b/src/main/java/cc/mrbird/febs/mall/vo/AdminMallActLuckdrawRecordVo.java new file mode 100644 index 0000000..20be830 --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/vo/AdminMallActLuckdrawRecordVo.java @@ -0,0 +1,27 @@ +package cc.mrbird.febs.mall.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +@Data +@ApiModel(value = "AdminMallActLuckdrawRecordVo", description = "返回参数类") +public class AdminMallActLuckdrawRecordVo { + + private Long id; + //参与人ID + private Long memberId; + //活动ID + private Long actId; + //活动名称 + private String actName; + //消耗积分数目 + private Integer actScoreCnt; + //是否中奖 0:没有 1中奖 + private Integer status; + + private String name; + + private String phone; + +} diff --git a/src/main/java/cc/mrbird/febs/mall/vo/AdminMallActSetVo.java b/src/main/java/cc/mrbird/febs/mall/vo/AdminMallActSetVo.java new file mode 100644 index 0000000..9b5336a --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/vo/AdminMallActSetVo.java @@ -0,0 +1,54 @@ +package cc.mrbird.febs.mall.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@ApiModel(value = "AdminMallActSetVo", description = "返回参数类") +public class AdminMallActSetVo { + + private Long id; + + //活动编码 + + + @ApiModelProperty(value = "活动编码") + private String actCode; + //活动名称 + + + @ApiModelProperty(value = "活动名称") + private String actName; + //开始时间 + + + @ApiModelProperty(value = "开始时间") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actStartTime; + //结束时间 + + + @ApiModelProperty(value = "结束时间") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date actEndTime; + //每次参与需要积分数目 + + + @ApiModelProperty(value = "每次参与需要积分数目") + private Integer actScoreCnt; + //活动状态 1-开启 0-关闭 + + + @ApiModelProperty(value = "活动状态 1-开启 0-关闭") + private Integer actStatus; + //活动说明 + + + @ApiModelProperty(value = "活动说明") + private String actRemark; + +} diff --git a/src/main/resources/mapper/modules/MallActAwardSetMapper.xml b/src/main/resources/mapper/modules/MallActAwardSetMapper.xml new file mode 100644 index 0000000..ea9f139 --- /dev/null +++ b/src/main/resources/mapper/modules/MallActAwardSetMapper.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cc.mrbird.febs.mall.mapper.MallActAwardSetMapper"> + + <delete id="deleteByActId"> + delete from mall_act_award_set where act_id = #{id} + </delete> + + <select id="selectMallActAwardByActId" resultType="cc.mrbird.febs.mall.entity.MallActAwardSet"> + select a.* from mall_act_award_set a where a.act_id = #{id} + </select> + +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/modules/MallActLuckdrawRecordMapper.xml b/src/main/resources/mapper/modules/MallActLuckdrawRecordMapper.xml new file mode 100644 index 0000000..89e2e0c --- /dev/null +++ b/src/main/resources/mapper/modules/MallActLuckdrawRecordMapper.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cc.mrbird.febs.mall.mapper.MallActLuckdrawRecordMapper"> + + <select id="selectMallActLuckdrawsInPage" resultType="cc.mrbird.febs.mall.vo.AdminMallActLuckdrawRecordVo"> + select + a.*, + b.name, + b.phone + from mall_act_luckdraw_record a + left join mall_member b on a.member_id = b.id + <where> + <if test="record != null"> + <if test="record.name != null and record.name != ''"> + and b.name like CONCAT('%', CONCAT(#{record.name}, '%')) + </if> + <if test="record.account!=null and record.account!=''"> + and ( + b.phone like concat('%', #{record.account},'%') + or b.email like concat('%', #{record.account},'%') + or b.bind_phone like concat('%', #{record.account},'%') + or b.invite_id like concat('%', #{record.account},'%') + ) + </if> + </if> + </where> + order by a.created_time desc + </select> + +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/modules/MallActSetMapper.xml b/src/main/resources/mapper/modules/MallActSetMapper.xml new file mode 100644 index 0000000..efb8206 --- /dev/null +++ b/src/main/resources/mapper/modules/MallActSetMapper.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cc.mrbird.febs.mall.mapper.MallActSetMapper"> + + <select id="selectMallActsInPage" resultType="cc.mrbird.febs.mall.vo.AdminMallActSetVo"> + select + a.id, + a.act_code actCode, + a.act_name actName, + a.act_start_time actStartTime, + a.act_end_time actEndTime, + a.act_score_cnt actScoreCnt, + a.act_status actStatus, + a.act_remark actRemark + from mall_act_set a + <where> + <if test="record != null"> + <if test="record.actName != null and record.actName != ''"> + and a.act_name like CONCAT('%', CONCAT(#{record.actName}, '%')) + </if> + </if> + </where> + order by a.created_time desc + </select> + +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/modules/MallActWinRecordMapper.xml b/src/main/resources/mapper/modules/MallActWinRecordMapper.xml new file mode 100644 index 0000000..5cbb9fb --- /dev/null +++ b/src/main/resources/mapper/modules/MallActWinRecordMapper.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cc.mrbird.febs.mall.mapper.MallActWinRecordMapper"> + + <select id="selectByLuckDrawId" resultType="cc.mrbird.febs.mall.entity.MallActWinRecord"> + select a.* from mall_act_win_record a where a.record_id = #{id} + </select> + +</mapper> \ No newline at end of file diff --git a/src/main/resources/templates/febs/views/modules/act/actAddNew.html b/src/main/resources/templates/febs/views/modules/act/actAddNew.html new file mode 100644 index 0000000..be057b6 --- /dev/null +++ b/src/main/resources/templates/febs/views/modules/act/actAddNew.html @@ -0,0 +1,323 @@ +<div class="layui-fluid layui-anim febs-anim" id="febs-act-add" lay-title="新增活动"> + <div class="layui-row febs-container"> + <div class="layui-col-md12"> + <div class="layui-fluid" id="act-add"> + <form class="layui-form" action="" lay-filter="act-add-form"> + <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief"> + <ul class="layui-tab-title"> + <li class="layui-this">基础信息</li> + </ul> + <div class="layui-tab-content"> + <div class="layui-tab-item layui-show"> + <blockquote class="layui-elem-quote blue-border">基本信息设置</blockquote> + <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">活动名称:</label> + <div class="layui-input-block"> + <input type="text" name="actName" lay-verify="required" + placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">活动编码:</label> + <div class="layui-input-block"> + <input type="text" name="actCode" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + <div class="layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">开始时间:</label> + <div class="layui-input-block"> + <input type="text" name="actStartTime" id="febs-form-group-date" lay-verify="date" + placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input"> + </div> + </div> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">结束时间:</label> + <div class="layui-input-block"> + <input type="text" name="actEndTime" id="febs-form-group-date" lay-verify="date" + placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + <div class="layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">抽奖一次需要积分数目:</label> + <div class="layui-input-block"> + <input type="text" name="actScoreCnt" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">活动说明:</label> + <div class="layui-input-block"> + <label> + <textarea name="actRemark" rows="5" autocomplete="off" class="layui-textarea" ></textarea> + </label> + </div> + </div> + + <blockquote class="layui-elem-quote blue-border">奖品信息设置</blockquote> + <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">奖品类型</label> + <div class="layui-input-block"> + <select name="awardType" class="award-type" lay-filter="award-type-select"> + <option value="1">积分</option> + <option value="2">佣金</option> + <option value="3">谢谢参与</option> + </select> + </div> + </div> + <div class="layui-col-lg6"> + <button type="button" class="layui-btn layui-btn-normal layui-btn" id="test3" >添加奖品</button> + </div> + + <div class="layui-form-item"> + <div class="layui-input-block"> + <table id="multiAwardSku" lay-filter="multiAwardSku"></table> + </div> + </div> + </div> + </div> + </div> + </div> + + <div class="layui-form-item febs-hide"> + <button class="layui-btn" lay-submit="" lay-filter="act-add-form-submit" id="submit">保存</button> + </div> + </form> + </div> + </div> + </div> +</div> +<style> + .blue-border { + border-left-color: #2db7f5; + font-size: 18px; + } + .layui-table-cell { + height:auto; + } +</style> +<script type="text/html" id="toolbar"> + <div class="layui-btn-container"> + <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" lay-event="delAct">删除</button> + </div> +</script> +<script type="text/html" id="awardtableImgUpload"> + <div class="layui-upload"> + <button type="button" class="layui-btn layui-btn-normal layui-btn-xs sku-img" id="awardImg{{d.index}}">上传</button></br> + <img class="layui-upload-img" id="awardImageUrls{{d.index}}" style="width: 100px; display:none;" src="{{d.awardImage}}" > + <input type="text" id="awardImage{{d.index}}" name="awardImage{{d.index}}" autocomplete="off" value="{{d.awardImage}}" class="layui-input febs-hide"> + </div> +</script> +<!-- 表格操作栏 end --> +<script data-th-inline="javascript"> + layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','dropdown', 'laydate', 'layedit', 'upload', 'element', 'table', 'xmSelect'], function () { + var $ = layui.jquery, + febs = layui.febs, + layer = layui.layer, + table = layui.table, + formSelects = layui.formSelects, + treeSelect = layui.treeSelect, + form = layui.form, + laydate = layui.laydate, + eleTree = layui.eleTree, + $view = $('#act-add'), + layedit = layui.layedit, + upload = layui.upload, + validate = layui.validate, + element = layui.element; + + form.render(); + + laydate.render({ + elem: '#febs-form-group-date' + }); + + formSelects.render(); + + var category = xmSelect.render({ + el: '#goods-category', + language: 'zn', + prop : { + value : 'id', + children : 'child' + }, + radio: true, + clickClose: true, + tree: { + show: true, + //非严格模式 + strict: false, + }, + data: [] + }) + + febs.get(ctx + 'admin/goodsCategory/categoryTree', null, function(res) { + category.update({ + data : res.data, + autoRow: true, + }); + }) + + var tableAwardData=[]; + var tableIns = table.render({ + elem: '#multiAwardSku' + ,limit:999 + ,toolbar:"#toolbar" + ,defaultToolbar:[] + ,cols: [[ //表头 + {type: 'checkbox'} + ,{field: 'index', title: '序号', width:70} + ,{field: 'awardName', title: '奖品名称', edit:'text'} + ,{field: 'awardImage', title: '奖品图'} + ,{templet: '#awardtableImgUpload', title: '缩略图', width:150} + ,{field: 'awardTotal', title: '奖品总数', edit:'text'} + ,{field: 'awardCnt', title: '已中奖数量', edit:'text'} + ,{field: 'awardType', title: '奖品类型', + templet: function (d) { + if (d.awardType == '1') { + return '<span style="color:blue;">积分</span>' + } else if (d.awardType == '2') { + return '<span style="color:green;">佣金</span>' + }else if (d.awardType == '3') { + return '<span>谢谢参与</span>' + }else{ + return '' + } + }, minWidth: 80,align:'center'} + ,{field: 'awardValue', title: '奖金数量', edit:'text'} + ]] + ,data: [] + }); + + table.on('toolbar(multiAwardSku)', function(obj){ + var data = obj.data; + + var hasData = table.cache['multiAwardSku']; + var checkData = table.checkStatus('multiAwardSku').data; + + if (checkData.length <= 0) { + febs.alert.warn('请选择删除数据'); + return; + } + if(obj.event === 'delAct'){ + for (let i = 0; i < checkData.length; i++) { + var delData = checkData[i]; + for (let j = 0; j < hasData.length; j++) { + if (hasData[j].index == delData.index) { + hasData.splice(j, 1); + break; + } + } + } + + for (let i = 0; i < hasData.length; i++) { + hasData[i].index = i + 1; + } + + tableAwardData=hasData; + reloadTable(hasData); + } + }); + + function addTableDate(data) { + var hasData = table.cache['multiAwardSku']; + + data.index = hasData.length + 1; + tableAwardData.push(data); + + reloadTable(tableAwardData); + return data.index; + } + + function reloadTable(data) { + table.reload('multiAwardSku', { + data : data + }); + + for (let i = 0; i < data.length; i++) { + if (data[i].awardImage) { + $('#awardImageUrls'+ (i+1)).css('display','block'); + } + // 重新绑定图片上传 + bindUpload(i+1); + } + } + + table.on('edit(multiAwardSku)', function(obj){ + var value = obj.value //得到修改后的值 + ,data = obj.data //得到所在行所有键值 + ,field = obj.field; //得到字段 + + for (let i = 0; i < tableAwardData.length; i++) { + if (tableAwardData[i].index == data.index) { + tableAwardData[i] = data; + } + } + }); + + $('#test3').on('click', function (){ + var awardTypeVal = $("select[name='awardType']").val(); + if(awardTypeVal == null || awardTypeVal == ""){ + febs.alert.warn('奖品类型不能为空'); + return false; + } + + var data = {}; + data.awardType = awardTypeVal; + addTableDate(data); + }); + + function bindUpload(index) { + // 普通图片上传 + upload.render({ + elem: '#awardImg' + index + ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 + ,done: function(res){ + febs.alert.success(res.data.src); + $('#awardImageUrls' + index).attr('src', res.data.src); + $('#awardImageUrls'+ index).css('display','block'); + $('#awardImage'+ index).val(res.data.src); + + for (let i = 0; i < tableAwardData.length; i++) { + if(tableAwardData[i].index == index) { + tableAwardData[i].awardImage = res.data.src; + } + } + + reloadTable(tableAwardData); + } + }); + } + + form.on('submit(act-add-form-submit)', function (data) { + data.field.addMallActAwardDtos = tableAwardData; + $.ajax({ + 'url':ctx + 'admin/act/addMallAct', + 'type':'post', + 'dataType':'json', + 'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式 + 'traditional': true,//ajax传递数组必须添加属性 + 'data':JSON.stringify(data.field), + 'success':function (data) { + if(data.code==200){ + layer.closeAll(); + febs.alert.success(data.message); + $('#febs-act').find('#reset').click(); + }else{ + febs.alert.warn(data.message); + } + }, + 'error':function () { + febs.alert.warn('服务器繁忙'); + } + }) + return false; + }); + }); +</script> \ No newline at end of file diff --git a/src/main/resources/templates/febs/views/modules/act/actList.html b/src/main/resources/templates/febs/views/modules/act/actList.html new file mode 100644 index 0000000..1c37454 --- /dev/null +++ b/src/main/resources/templates/febs/views/modules/act/actList.html @@ -0,0 +1,209 @@ +<div class="layui-fluid layui-anim febs-anim" id="febs-act" lay-title="活动列表"> + <div class="layui-row febs-container"> + <div class="layui-col-md12"> + <div class="layui-card"> + <div class="layui-card-body febs-table-full"> + <form class="layui-form layui-table-form" lay-filter="user-table-form"> + <div class="layui-row"> + <div class="layui-col-md10"> + <div class="layui-form-item"> + <div class="layui-inline"> + <div class="layui-input-inline"> + <input type="text" placeholder="名称" name="actName" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + </div> + <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> + <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add"> + 新增 + </div> + <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> + <i class="layui-icon"></i> + </div> + <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> + <i class="layui-icon"></i> + </div> + </div> + </div> + </form> + <table lay-filter="actTable" lay-data="{id: 'actTable'}"></table> + <style type="text/css"> + .layui-table-cell{ + text-align:center; + height: auto; + white-space: nowrap; /*文本不会换行,在同一行显示*/ + overflow: hidden; /*超出隐藏*/ + text-overflow: ellipsis; /*省略号显示*/ + } + .layui-table img{ + max-width:100px + } + </style> + </div> + </div> + </div> + </div> +</div> +<!-- 表格操作栏 start --> +<script type="text/html" id="user-option"> + <span shiro:lacksPermission="user:view,user:update,user:delete"> + <span class="layui-badge-dot febs-bg-orange"></span> 无权限 + </span> + <a lay-event="edit" shiro:hasPermission="user:update"><i + class="layui-icon febs-edit-area febs-blue"></i></a> +</script> +<script type="text/html" id="startOrCloseSwitch"> + {{# if(d.actStatus === 1) { }} + <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="startOrCloseSwitch"> + {{# } else { }} + <input type="checkbox" value={{d.id}} lay-text="开启|关闭" lay-skin="switch" lay-filter="startOrCloseSwitch"> + {{# } }} +</script> +<style> + .layui-form-onswitch { + background-color: #5FB878 !important; + } +</style> +<!-- 表格操作栏 end --> +<script data-th-inline="none" type="text/javascript"> + // 引入组件并初始化 + layui.use([ 'jquery', 'form', 'table', 'febs'], function () { + var $ = layui.jquery, + febs = layui.febs, + form = layui.form, + table = layui.table, + $view = $('#febs-act'), + $query = $view.find('#query'), + $reset = $view.find('#reset'), + $searchForm = $view.find('form'), + $add = $view.find('#add'), + sortObject = {field: 'phone', type: null}, + tableIns; + + form.render(); + + // 表格初始化 + initTable(); + + // 初始化表格操作栏各个按钮功能 + table.on('tool(actTable)', function (obj) { + var data = obj.data, + layEvent = obj.event; + if (layEvent === 'closeAct') { + febs.modal.confirm('关闭', '确认关闭该活动?', function () { + closeAct(data.id); + }); + } + if (layEvent === 'startAct') { + febs.modal.confirm('开启', '确认开启该活动?', function () { + startAct(data.id); + }); + } + if (layEvent === 'delAct') { + febs.modal.confirm('删除', '确认删除该活动?', function () { + delAct(data.id); + }); + } + if (layEvent === 'actUpdate') { + febs.modal.open('编辑', 'modules/act/actUpdateNew/' + data.id, { + btn: ['提交', '取消'], + area:['100%','100%'], + yes: function (index, layero) { + $('#febs-act-update').find('#submit').trigger('click'); + }, + btn2: function () { + layer.closeAll(); + } + }); + } + }); + function closeAct(id) { + febs.get(ctx + 'admin/act/closeMallAct/' + id, null, function () { + febs.alert.success('关闭成功'); + $query.click(); + }); + } + function startAct(id) { + febs.get(ctx + 'admin/act/startMallAct/' + id, null, function () { + febs.alert.success('开启成功'); + $query.click(); + }); + } + function delAct(id) { + febs.get(ctx + 'admin/act/delMallAct/' + id, null, function () { + febs.alert.success('删除成功'); + $query.click(); + }); + } + + // 查询按钮 + $query.on('click', function () { + var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); + tableIns.reload({where: params, page: {curr: 1}}); + }); + + // 刷新按钮 + $reset.on('click', function () { + $searchForm[0].reset(); + sortObject.type = 'null'; + tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); + }); + + $add.on('click', function () { + febs.modal.open('新增活动', 'modules/act/actAddNew/', { + btn: ['提交', '取消'], + area:['100%','100%'], + yes: function (index, layero) { + $('#febs-act-add').find('#submit').trigger('click'); + }, + btn2: function () { + layer.closeAll(); + } + }); + }); + + function initTable() { + tableIns = febs.table.init({ + elem: $view.find('table'), + id: 'actTable', + url: ctx + 'admin/act/actList', + cols: [[ + {field: 'actCode', title: '活动编码', minWidth: 150,align:'left'}, + {field: 'actName', title: '活动名称', minWidth: 150,align:'left'}, + {field: 'actStartTime', title: '开始时间', minWidth: 150,align:'left'}, + {field: 'actEndTime', title: '结束时间', minWidth: 150,align:'left'}, + {field: 'actScoreCnt', title: '每次消耗积分', minWidth: 150,align:'left'}, + {field: 'actStatus', title: '活动状态', templet: '#startOrCloseSwitch', minWidth: 130,align:'center'}, + {field: 'actRemark', title: '活动说明', minWidth: 150,align:'left'}, + {title: '操作', + templet: function (d) { + if (d.actStatus === 1) { + return ''; + }else{ + return '' + + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="actUpdate" shiro:hasPermission="user:update">编辑</button>' + + '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-red" lay-event="delAct" shiro:hasPermission="user:update">删除</button>' + } + },minWidth: 160,align:'center'} + ]] + }); + } + + form.on('switch(startOrCloseSwitch)', function (data) { + if (data.elem.checked) { + startAct(data.value); + } else { + closeAct(data.value); + } + }) + + // 获取查询参数 + function getQueryParams() { + return { + actName: $searchForm.find('input[name="actName"]').val().trim(), + }; + } + + }) +</script> \ No newline at end of file diff --git a/src/main/resources/templates/febs/views/modules/act/actUpdateNew.html b/src/main/resources/templates/febs/views/modules/act/actUpdateNew.html new file mode 100644 index 0000000..f2d699d --- /dev/null +++ b/src/main/resources/templates/febs/views/modules/act/actUpdateNew.html @@ -0,0 +1,337 @@ +<div class="layui-fluid layui-anim febs-anim" id="febs-act-update" lay-title="编辑活动"> + <div class="layui-row febs-container"> + <div class="layui-col-md12"> + <!-- <div class="layui-card">--> + <!-- <div class="layui-card-body febs-table-full">--> + <div class="layui-fluid" id="act-update"> + <form class="layui-form" action="" lay-filter="act-update-form"> + <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief"> + <ul class="layui-tab-title"> + <li class="layui-this">基础信息</li> + </ul> + <input type="text" name="id" + placeholder="" autoComplete="off" class="layui-input febs-hide"> + <div class="layui-tab-content"> + <div class="layui-tab-item layui-show"> + <blockquote class="layui-elem-quote blue-border">基本信息设置</blockquote> + <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">活动名称:</label> + <div class="layui-input-block"> + <input type="text" name="actName" lay-verify="required" + placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">活动编码:</label> + <div class="layui-input-block"> + <input type="text" name="actCode" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + <div class="layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">开始时间:</label> + <div class="layui-input-block"> + <input type="text" name="actStartTime" id="febs-form-group-date" lay-verify="date" + placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input"> + </div> + </div> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">结束时间:</label> + <div class="layui-input-block"> + <input type="text" name="actEndTime" id="febs-form-group-date" lay-verify="date" + placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + <div class="layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">抽奖一次需要积分数目:</label> + <div class="layui-input-block"> + <input type="text" name="actScoreCnt" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label">活动说明:</label> + <div class="layui-input-block"> + <label> + <textarea name="actRemark" rows="5" autocomplete="off" class="layui-textarea" ></textarea> + </label> + </div> + </div> + + <blockquote class="layui-elem-quote blue-border">奖品信息设置</blockquote> + <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">奖品类型</label> + <div class="layui-input-block"> + <select name="awardType" class="award-type" lay-filter="award-type-select"> + <option value="1">积分</option> + <option value="2">佣金</option> + <option value="3">谢谢参与</option> + </select> + </div> + </div> + <div class="layui-col-lg6"> + <button type="button" class="layui-btn layui-btn-normal layui-btn" id="test3" >添加奖品</button> + </div> + + <div class="layui-form-item"> + <div class="layui-input-block"> + <table id="multiAward" lay-filter="multiAward"></table> + </div> + </div> + </div> + + </div> + </div> + </div> + <div class="layui-form-item febs-hide" style="text-align:center"> + <button class="layui-btn" lay-submit="" lay-filter="act-update-form-submit" + id="submit"> + </button> + </div> + </form> + </div> + </div> + </div> +</div> +<style> + .blue-border { + border-left-color: #2db7f5; + font-size: 18px; + } + + .layui-table-cell { + height: auto; + } +</style> +<script type="text/html" id="toolbar"> + <div class="layui-btn-container"> + <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" lay-event="delAwardset">删除</button> + </div> +</script> +<script type="text/html" id="awardtableImgUpload"> + <div class="layui-upload"> + <button type="button" class="layui-btn layui-btn-normal layui-btn-xs sku-img" id="awardImg{{d.index}}">上传</button></br> + <img class="layui-upload-img" id="awardImageUrls{{d.index}}" style="width: 100px; display:none;" src="{{d.awardImage}}" > + <input type="text" id="awardImage{{d.index}}" name="awardImage{{d.index}}" autocomplete="off" value="{{d.awardImage}}" class="layui-input febs-hide"> + </div> +</script> +<!-- 表格操作栏 end --> +<script data-th-inline="javascript"> + layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'dropdown', 'laydate', 'layedit', 'upload', 'element', 'table', 'xmSelect'], function () { + var $ = layui.jquery, + febs = layui.febs, + layer = layui.layer, + table = layui.table, + formSelects = layui.formSelects, + treeSelect = layui.treeSelect, + form = layui.form, + laydate = layui.laydate, + eleTree = layui.eleTree, + actInfo = [[${actInfo}]], + $view = $('#act-update'), + layedit = layui.layedit, + upload = layui.upload, + validate = layui.validate, + element = layui.element; + form.render(); + laydate.render({ + elem: '#febs-form-group-date' + }); + formSelects.render(); + + var tableAwardData=[]; + var tableIns = table.render({ + elem: '#multiAward' + ,limit:999 + ,toolbar:"#toolbar" + ,defaultToolbar:[] + ,cols: [[ //表头 + {type: 'checkbox'} + ,{field: 'index', title: '序号', width:70} + ,{field: 'awardName', title: '奖品名称', edit:'text'} + ,{field: 'awardImage', title: '奖品图'} + ,{templet: '#awardtableImgUpload', title: '缩略图', width:150} + ,{field: 'awardTotal', title: '奖品总数', edit:'text'} + ,{field: 'awardCnt', title: '已中奖数量', edit:'text'} + ,{field: 'awardType', title: '奖品类型', + templet: function (d) { + if (d.awardType == '1') { + return '<span style="color:blue;">积分</span>' + } else if (d.awardType == '2') { + return '<span style="color:green;">佣金</span>' + }else if (d.awardType == '3') { + return '<span>谢谢参与</span>' + }else{ + return '' + } + }, minWidth: 80,align:'center'} + ,{field: 'awardValue', title: '奖金数量', edit:'text'} + ,{field: 'id', title: 'awardId', hide: true} + ]] + ,data: [] + }); + + var delAward = []; + table.on('toolbar(multiAward)', function (obj) { + var data = obj.data; + + var hasData = table.cache['multiAward']; + var checkData = table.checkStatus('multiAward').data; + + if (checkData.length <= 0) { + febs.alert.warn('请选择删除数据'); + return; + } + if (obj.event === 'delAwardset') { + for (let i = 0; i < checkData.length; i++) { + var delData = checkData[i]; + console.log(delData) + for (let j = 0; j < hasData.length; j++) { + if (hasData[j].index == delData.index) { + if (delData.id) { + delAward.push(delData.id); + } + + hasData.splice(j, 1); + break; + } + } + } + console.log(delAward); + + for (let i = 0; i < hasData.length; i++) { + hasData[i].index = i + 1; + } + + tableAwardData = hasData; + reloadTable(hasData); + } + }); + + function addTableDate(data) { + var hasData = table.cache['multiAward']; + + data.index = hasData.length + 1; + tableAwardData.push(data); + + reloadTable(tableAwardData); + return data.index; + } + + function reloadTable(data) { + table.reload('multiAward', { + data : data + }); + + console.log(data) + + for (let i = 0; i < data.length; i++) { + if (data[i].awardImage) { + $('#awardImageUrls'+ (i+1)).css('display','block'); + } + // 重新绑定图片上传 + bindUpload(i+1); + } + } + + table.on('edit(multiAward)', function(obj){ + var value = obj.value //得到修改后的值 + ,data = obj.data //得到所在行所有键值 + ,field = obj.field; //得到字段 + + for (let i = 0; i < tableAwardData.length; i++) { + if (tableAwardData[i].index == data.index) { + tableAwardData[i] = data; + } + } + }); + + $('#test3').on('click', function (){ + var awardTypeVal = $("select[name='awardType']").val(); + if(awardTypeVal == null || awardTypeVal == ""){ + febs.alert.warn('奖品类型不能为空'); + return false; + } + + var data = {}; + data.awardType = awardTypeVal; + addTableDate(data); + }); + + function bindUpload(index) { + // 普通图片上传 + upload.render({ + elem: '#awardImg' + index + ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 + ,done: function(res){ + febs.alert.success(res.data.src); + $('#awardImageUrls' + index).attr('src', res.data.src); + $('#awardImageUrls'+ index).css('display','block'); + $('#awardImage'+ index).val(res.data.src); + + for (let i = 0; i < tableAwardData.length; i++) { + if(tableAwardData[i].index == index) { + tableAwardData[i].awardImage = res.data.src; + } + } + + reloadTable(tableAwardData); + } + }); + } + + function initValue() { + form.val("act-update-form", { + "id": actInfo.id, + "actCode": actInfo.actCode, + "actName": actInfo.actName, + "actStartTime": actInfo.actStartTime, + "actEndTime": actInfo.actEndTime, + "actScoreCnt": actInfo.actScoreCnt, + "actRemark": actInfo.actRemark + }); + + var award = actInfo.mallActAwardSets; + for (let i = 0; i < award.length; i++) { + award[i].index = i+1; + } + tableAwardData = award; + reloadTable(award); + } + + form.on('submit(act-update-form-submit)', function (data) { + data.field.updateMallActAwardDtos = tableAwardData; + $.ajax({ + 'url': ctx + 'admin/act/updateMallAct', + 'type': 'post', + 'dataType': 'json', + 'headers': {'Content-Type': 'application/json;charset=utf-8'}, //接口json格式 + 'traditional': true,//ajax传递数组必须添加属性 + 'data': JSON.stringify(data.field), + 'success': function (data) { + if (data.code == 200) { + layer.closeAll(); + febs.alert.success(data.message); + $('#febs-act').find('#reset').click(); + } else { + febs.alert.warn(data.message); + } + }, + 'error': function () { + febs.alert.warn('服务器繁忙'); + } + }) + return false; + }); + + + initValue(); + + }); +</script> \ No newline at end of file diff --git a/src/main/resources/templates/febs/views/modules/act/luckdrawList.html b/src/main/resources/templates/febs/views/modules/act/luckdrawList.html new file mode 100644 index 0000000..6fd7859 --- /dev/null +++ b/src/main/resources/templates/febs/views/modules/act/luckdrawList.html @@ -0,0 +1,148 @@ +<div class="layui-fluid layui-anim febs-anim" id="febs-luckdraw" lay-title="抽奖列表"> + <div class="layui-row febs-container"> + <div class="layui-col-md12"> + <div class="layui-card"> + <div class="layui-card-body febs-table-full"> + <form class="layui-form layui-table-form" lay-filter="user-table-form"> + <div class="layui-row"> + <div class="layui-col-md10"> + <div class="layui-form-item"> + <div class="layui-inline"> + <div class="layui-input-inline"> + <input type="text" placeholder="名称" name="name" autocomplete="off" class="layui-input"> + </div> + <div class="layui-input-inline"> + <input type="text" placeholder="手机号" name="account" autocomplete="off" class="layui-input"> + </div> + </div> + </div> + </div> + <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> + <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> + <i class="layui-icon"></i> + </div> + <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> + <i class="layui-icon"></i> + </div> + </div> + </div> + </form> + <table lay-filter="actTable" lay-data="{id: 'actTable'}"></table> + <style type="text/css"> + .layui-table-cell{ + text-align:center; + height: auto; + white-space: nowrap; /*文本不会换行,在同一行显示*/ + overflow: hidden; /*超出隐藏*/ + text-overflow: ellipsis; /*省略号显示*/ + } + .layui-table img{ + max-width:100px + } + </style> + </div> + </div> + </div> + </div> +</div> +<!-- 表格操作栏 start --> +<script type="text/html" id="user-option"> + <span shiro:lacksPermission="user:view,user:update,user:delete"> + <span class="layui-badge-dot febs-bg-orange"></span> 无权限 + </span> + <a lay-event="edit" shiro:hasPermission="user:update"><i + class="layui-icon febs-edit-area febs-blue"></i></a> +</script> +<style> + .layui-form-onswitch { + background-color: #5FB878 !important; + } +</style> +<!-- 表格操作栏 end --> +<script data-th-inline="none" type="text/javascript"> + // 引入组件并初始化 + layui.use([ 'jquery', 'form', 'table', 'febs'], function () { + var $ = layui.jquery, + febs = layui.febs, + form = layui.form, + table = layui.table, + $view = $('#febs-luckdraw'), + $query = $view.find('#query'), + $reset = $view.find('#reset'), + $searchForm = $view.find('form'), + $add = $view.find('#add'), + sortObject = {field: 'phone', type: null}, + tableIns; + + form.render(); + + // 表格初始化 + initTable(); + + // 初始化表格操作栏各个按钮功能 + table.on('tool(actTable)', function (obj) { + var data = obj.data, + layEvent = obj.event; + + if (layEvent === 'winRecord') { + febs.modal.open( '中奖信息', 'modules/act/luckdrawWin/' + data.id, { + maxmin: true, + }); + } + }); + + // 查询按钮 + $query.on('click', function () { + var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); + tableIns.reload({where: params, page: {curr: 1}}); + }); + + // 刷新按钮 + $reset.on('click', function () { + $searchForm[0].reset(); + sortObject.type = 'null'; + tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); + }); + + function initTable() { + tableIns = febs.table.init({ + elem: $view.find('table'), + id: 'actTable', + url: ctx + 'admin/act/luckdrawList', + cols: [[ + {field: 'name', title: '名称', minWidth: 150,align:'left'}, + {field: 'phone', title: '手机号', minWidth: 150,align:'left'}, + {field: 'actName', title: '活动名称', minWidth: 150,align:'left'}, + {field: 'actScoreCnt', title: '每次消耗积分', minWidth: 150,align:'left'}, + {field: 'status', title: '是否中奖', + templet: function (d) { + if (d.status == '1') { + return '<span style="color:green;">中奖</span>' + }else{ + return '<span>谢谢参与</span>' + } + }, minWidth: 80,align:'center'}, + {title: '操作', + templet: function (d) { + if (d.status === 1) { + return '' + + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="winRecord" shiro:hasPermission="user:update">查看奖品</button>'; + }else{ + return ''; + + } + },minWidth: 160,align:'center'} + ]] + }); + } + + // 获取查询参数 + function getQueryParams() { + return { + name: $searchForm.find('input[name="name"]').val().trim(), + account: $searchForm.find('input[name="account"]').val().trim(), + }; + } + + }) +</script> \ No newline at end of file diff --git a/src/main/resources/templates/febs/views/modules/act/winRecordInfo.html b/src/main/resources/templates/febs/views/modules/act/winRecordInfo.html new file mode 100644 index 0000000..dbf0362 --- /dev/null +++ b/src/main/resources/templates/febs/views/modules/act/winRecordInfo.html @@ -0,0 +1,69 @@ +<style> + #win-info { + padding: 20px 25px 25px 0; + } + + #win-info .layui-treeSelect .ztree li a, .ztree li span { + margin: 0 0 2px 3px !important; + } + #win-info #data-permission-tree-block { + border: 1px solid #eee; + border-radius: 2px; + padding: 3px 0; + } + #win-info .layui-treeSelect .ztree li span.button.switch { + top: 1px; + left: 3px; + } + +</style> +<div class="layui-fluid" id="win-info"> + <form class="layui-form" action="" lay-filter="win-info-form"> + <div class="layui-form-item"> + <label class="layui-form-label">活动名称:</label> + <div class="layui-input-block"> + <input type="text" name="actName" class="layui-input" readonly> + </div> + </div> + <div class="layui-form-item"> + <label class="layui-form-label">奖品名称:</label> + <div class="layui-input-block"> + <input type="text" name="awardName" class="layui-input" readonly> + </div> + </div> + <div class="layui-form-item"> + <label class="layui-form-label">奖品数量:</label> + <div class="layui-input-block"> + <input type="text" name="awardValue" class="layui-input" readonly> + </div> + </div> + </form> +</div> + +<script data-th-inline="javascript"> + layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree'], function () { + var $ = layui.$, + febs = layui.febs, + layer = layui.layer, + formSelects = layui.formSelects, + treeSelect = layui.treeSelect, + form = layui.form, + eleTree = layui.eleTree, + winInfo = [[${winInfo}]], + $view = $('#win-info'), + validate = layui.validate, + _deptTree; + + form.render(); + + initUserValue(); + + function initUserValue() { + form.val("win-info-form", { + "actName": winInfo.actName, + "awardName": winInfo.awardName, + "awardValue": winInfo.awardValue + }); + } + }); +</script> \ No newline at end of file -- Gitblit v1.9.1