‘linchangsheng’ il y a 3 semaines
Parent
commit
36e8571aee

+ 42 - 60
src/main/java/com/gree/mall/manager/bean/coupon/CouponVO.java

@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.enums.CouponCrowdEnum;
+import com.gree.mall.manager.enums.CouponTypeEnum;
+import com.gree.mall.manager.enums.CouponUseTypeEnum;
 import com.gree.mall.manager.plus.entity.Coupon;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -16,54 +20,42 @@ import java.util.Date;
 @Data
 public class CouponVO  {
 
+
+    @ZfireField(hide = true)
     @ApiModelProperty(value = "优惠券id")
-    @TableId(value = "coupon_id", type = IdType.ID_WORKER_STR)
     private String couponId;
 
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "企业微信id")
+    private String companyWechatId;
+
+    @ApiModelProperty(value = "商户")
+    private String companyName;
+
     @ApiModelProperty(value = "优惠券名称")
     private String couponName;
 
-    @ApiModelProperty(value = "发放总量")
-    private Integer couponAmount;
+    @ApiModelProperty(value = "优惠券性质")
+    private CouponUseTypeEnum type;
 
-    @ApiModelProperty(value = "优惠券图片")
-    private String imgSrc;
+    @ApiModelProperty(value = "优惠券类型")
+    private CouponTypeEnum couponType;
 
-    @ApiModelProperty(value = "类型 SATISFY=满减券 DISCOUNT=折扣券 RANDOM=随机金额券  GOODS=商品券")
-    private String couponType;
-
-    @ApiModelProperty(value = "订单满足金额 0=没门槛")
+    @ApiModelProperty(value = "订单满足金额")
     private BigDecimal orderAmount;
 
-    @ApiModelProperty(value = "用券时间类型 1=统一指定时间 2=领券当日起多少天可用 3=领券次日起多少天可用")
-    private Integer activeType;
-
-    @ApiModelProperty(value = "多少天后过期")
-    private Integer activeDay;
-
-    @ApiModelProperty(value = "优惠券使用开始时间")
-    private Date activeStartTime;
-
-    @ApiModelProperty(value = "优惠券使用结束时间")
-    private Date activeEndTime;
+    @ApiModelProperty(value = "优惠券面值")
+    private BigDecimal couponValue;
 
-    @ApiModelProperty(value = "领取人群 0=所有会员 1=指定标签 2=指定会员 3=全部业务员,4=全部普通用户")
-    private Integer receiveCrowd;
+    @ApiModelProperty(value = "发放总量")
+    private Integer couponAmount;
 
-    @ApiModelProperty(value = "每人限领次数 0=不限次数")
+    @ApiModelProperty(value = "每人限领次数")
     private Integer receiveLimitCount;
 
-    @ApiModelProperty(value = "限制原价商品 false=不限制 true=限制")
-    private Boolean originalPriceLimit;
-
-    @ApiModelProperty(value = "排序(降序)")
-    private Integer sortNum;
-
-    @ApiModelProperty(value = "优惠值")
-    private BigDecimal couponValue;
+    @ApiModelProperty(value = "显示时间")
+    private Date displayTime;
 
-    @ApiModelProperty(value = "使用说明")
-    private String note;
 
     @ApiModelProperty(value = "优惠券领取开始时间")
     private Date obtainStartTime;
@@ -71,42 +63,32 @@ public class CouponVO  {
     @ApiModelProperty(value = "优惠券领取结束时间")
     private Date obtainEndTime;
 
-    @ApiModelProperty(value = "券显示时间")
-    private Date displayTime;
-
-    @ApiModelProperty(value = "发布开始时间")
-    private Date releaseStartTime;
-
-    @ApiModelProperty(value = "发布结束时间")
-    private Date releaseEndTime;
-
-    @ApiModelProperty(value = "标志 WAIT=待发布 START=进行中 END=结束 CANCEL=取消")
-    private String flag;
-
-    @ApiModelProperty(value = "领取数量")
-    private Integer receiveAmount;
+    @ApiModelProperty(value = "领券多少天内有效")
+    private Integer activeDay;
 
-    @ApiModelProperty(value = "剩余数量")
-    private Integer leftAmount;
+    @ApiModelProperty(value = "优惠券使用开始时间")
+    private Date activeStartTime;
 
-    @ApiModelProperty(value = "备注")
-    private String remark;
+    @ApiModelProperty(value = "优惠券使用结束时间")
+    private Date activeEndTime;
 
-    @ApiModelProperty(value = "是否可以转让,1:可转让,0:不可转让")
-    private Boolean transferType;
+    @ApiModelProperty(value = "领取条件")
+    private CouponCrowdEnum receiveCrowd;
 
     @ApiModelProperty(value = "创建时间")
     @TableField(fill = FieldFill.INSERT)
     private Date createTime;
 
-    @ApiModelProperty(value = "业务员券分享次数")
-    private Integer shareTimes;
+    @ApiModelProperty(value = "修改时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
 
-    @ApiModelProperty(value = "企业微信id")
-    private String companyWechatId;
-
-    @ApiModelProperty(value = "企业名称")
-    private String companyName;
+    @ApiModelProperty(value = "创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
 
+    @ApiModelProperty(value = "修改人")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateBy;
 
 }

+ 3 - 0
src/main/java/com/gree/mall/manager/commonmapper/CouponDateMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.activity.CustomSecSpecBean;
 import com.gree.mall.manager.bean.coupon.*;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -42,4 +43,6 @@ public interface CouponDateMapper {
     @SqlParser(filter = true)
     List<CouponExportBean> exportSelfCoupon(@Param("companyWechatIds")List<String> companyWechatIds,
                                             @Param("couponName")String couponName, @Param("couponType")String couponType, @Param("flag")String flag);
+
+    IPage<CouponVO> couponList(Page page, @Param("ex") ZfireParamBean zfireParam);
 }

+ 26 - 8
src/main/java/com/gree/mall/manager/enums/CouponCrowdEnum.java

@@ -1,14 +1,32 @@
 package com.gree.mall.manager.enums;
 
-public enum CouponCrowdEnum {
-    TAG(1),SPECIFY(2),ALL_SERVICE(3),ALL_GENRERAL(4);
-    private Integer flag;
-    CouponCrowdEnum(Integer flag){
-        this.flag = flag;
-    }
+import cn.hutool.core.convert.Convert;
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.manager.enums.base.BaseEnum;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum CouponCrowdEnum implements BaseEnum, IEnum<Integer> {
+
+    TAG("1","所有会员"),
+    SPECIFY("2","指定会员"),
+    ALL_SERVICE("3","全部业务员"),
+    ALL_GENRERAL("4","全部普通用户"),;
+
+    @JsonValue
+    @EnumValue
+    private final String key;
+    private final String remark;
 
-    public Integer getFlag(){
-        return flag;
+    @Override
+    public Integer getValue() {
+        return Convert.toInt(key);
     }
 
 }

+ 17 - 9
src/main/java/com/gree/mall/manager/enums/CouponTypeEnum.java

@@ -1,16 +1,24 @@
 package com.gree.mall.manager.enums;
 
-public enum CouponTypeEnum {
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.manager.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 
-    SATISFY("SATISFY"),DISCOUNT("DISCOUNT"),RANDOM("RANDOM"),GOODS("GOODS");
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum CouponTypeEnum implements BaseEnum {
 
-    private String name;
+    SATISFY("SATISFY","满减券"),
+    DISCOUNT("DISCOUNT","折扣券"),
+    RANDOM("RANDOM","随机金额券"),
+    GOODS("GOODS","商品券"),;
 
-    CouponTypeEnum(String name) {
-        this.name = name;
-    }
+    @JsonValue
+    @EnumValue
+    private final String key;
+    private final String remark;
 
-    public String getName(){
-        return name;
-    }
 }

+ 25 - 0
src/main/java/com/gree/mall/manager/enums/CouponUseTypeEnum.java

@@ -0,0 +1,25 @@
+package com.gree.mall.manager.enums;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.manager.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum  CouponUseTypeEnum implements BaseEnum {
+
+    A("A","平台券"),
+    B("B","商家券"),;
+
+
+    @JsonValue
+    @EnumValue
+    private final String key;
+    private final String remark;
+
+
+
+}

+ 1 - 1
src/main/java/com/gree/mall/manager/logic/activity/PromotionLuckDrawLogic.java

@@ -242,7 +242,7 @@ public class PromotionLuckDrawLogic {
             row.add(DateUtils.formatDate(bean.getExchangeStartTime()));
             row.add(DateUtils.formatDate(bean.getExchangeEndTime()));
             row.add(bean.getCouponName());
-            row.add(CouponTypeEnum.valueOf(bean.getCouponType()).getName());
+            row.add(CouponTypeEnum.valueOf(bean.getCouponType()).getRemark());
             row.add(bean.getDiscountAmount());
             row.add(bean.getCode());
             //0=未兑换 1=已兑换未使用 2=已使用

+ 16 - 6
src/main/java/com/gree/mall/manager/logic/coupon/CouponLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.coupon;
 
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUtil;
 import com.aliyuncs.ram.model.v20150501.GetUserResponse;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -20,6 +21,7 @@ import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.DateUtils;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -156,7 +158,7 @@ public class CouponLogic {
         couponBean.setActiveType(couponBean.getActiveDay() != null ? 2:1);
         couponService.save(couponBean);
         String couponId = couponBean.getCouponId();
-        if (couponBean.getCouponType().trim().equals(CouponTypeEnum.GOODS.getName()) && couponBean.getGoodsList() != null) {
+        if (couponBean.getCouponType().trim().equals(CouponTypeEnum.GOODS.getRemark()) && couponBean.getGoodsList() != null) {
             List<CouponGoods> couponGoodsList = new ArrayList<>();
             for (CouponGoods couponGoods : couponBean.getGoodsList()) {
                 couponGoods.setCouponId(couponId);
@@ -168,7 +170,7 @@ public class CouponLogic {
             couponGoodsService.saveBatch(couponGoodsList);
         }
         //指定标签
-        if (couponBean.getReceiveCrowd() == CouponCrowdEnum.TAG.getFlag() && couponBean.getTagList() != null) {
+        if (couponBean.getReceiveCrowd().equals(Convert.toInt(CouponCrowdEnum.TAG.getKey())) && couponBean.getTagList() != null) {
             List<String> userIds = wxCustomerMapper.queryTagUserIdList(adminUser.getLoginCompanyWechatId(), couponBean.getTagList());
             List<CouponTag> couponTagList = new ArrayList<>();
             for (CouponTag couponTag : couponBean.getTagList()) {
@@ -194,7 +196,7 @@ public class CouponLogic {
         }
 
         //指定会员
-        if (couponBean.getReceiveCrowd().equals(CouponCrowdEnum.SPECIFY.getFlag()) && couponBean.getUserList() != null) {
+        if (couponBean.getReceiveCrowd().equals(Convert.toInt(CouponCrowdEnum.SPECIFY.getKey())) && couponBean.getUserList() != null) {
             List<CouponUser> couponUserList = new ArrayList<>();
 //            List<UserCoupon> userCouponList = new ArrayList<>();
             for (CouponUserTypeBean couponUserTypeBean : couponBean.getUserList()) {
@@ -222,7 +224,7 @@ public class CouponLogic {
 
         }
         //全部业务员
-        if (couponBean.getReceiveCrowd() == CouponCrowdEnum.ALL_SERVICE.getFlag()) {
+        if (couponBean.getReceiveCrowd().equals(Convert.toInt(CouponCrowdEnum.ALL_SERVICE.getKey()))) {
             List<UserCoupon> userCouponList = new ArrayList<>();
             List<User> userList = userService.lambdaQuery()
                     .eq(User::getType, UserTypeEnum.SERVICE.toString())
@@ -248,7 +250,7 @@ public class CouponLogic {
             }
         }
         //全部普通用户
-        if (couponBean.getReceiveCrowd() == CouponCrowdEnum.ALL_GENRERAL.getFlag()) {
+        if (couponBean.getReceiveCrowd().equals(Convert.toInt(CouponCrowdEnum.ALL_GENRERAL.getKey()))) {
             List<CouponUser> couponUserList = new ArrayList<>();
             List<User> userList = userService.lambdaQuery()
                     .eq(User::getType, UserTypeEnum.GENERAL.toString())
@@ -693,6 +695,14 @@ public class CouponLogic {
     }
 
     public IPage<CouponVO> list(Page page, ZfireParamBean zfireParam) {
-        return  new Page<>();
+
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        //1.组装查询条件
+        FieldUtils.supplyParam(zfireParam, CouponVO.class,adminUser);
+
+        IPage<CouponVO> couponVOIPage = couponDateMapper.couponList(page, zfireParam);
+        return couponVOIPage;
     }
 }

+ 10 - 0
src/main/resources/mapper/CouponDateMapper.xml

@@ -228,6 +228,16 @@
             and uc.user_id = ur.user_id
         )
     </select>
+    <select id="couponList" resultType="com.gree.mall.manager.bean.coupon.CouponVO">
+        SELECT
+        ${ex.selected}
+        FROM coupon a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 
 
 </mapper>