Parcourir la source

Merge remote-tracking branch 'origin/master'

FengChaoYu il y a 3 semaines
Parent
commit
5f8750a181

+ 6 - 4
src/main/java/com/gree/mall/manager/bean/admin/AdminWebsitVO.java

@@ -5,6 +5,8 @@ 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.StateEnum;
+import com.gree.mall.manager.enums.StatusEnum;
 import com.gree.mall.manager.plus.entity.AdminWebsit;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -41,10 +43,10 @@ public class AdminWebsitVO   {
     @ApiModelProperty(value = "负责人电话")
     private String personMobile;
 
-    @ApiModelProperty(value = "OFF 禁用  ON 启用")
-    private String status;
+    @ApiModelProperty(value = "状态")
+    private StateEnum status;
 
-    @ApiModelProperty(value = "SHIP 旗舰店 CHISE 加盟店")
+    @ApiModelProperty(value = "商家类型")
     private String type;
 
 
@@ -52,7 +54,7 @@ public class AdminWebsitVO   {
     private String address;
 
     @ApiModelProperty(value = "收款商户号")
-    private String payWorkerName;
+    private String payWorkerCodeName;
 
     @ZfireField(hide = true)
     @ApiModelProperty(value = "师傅收款电子支付商户")

+ 94 - 0
src/main/java/com/gree/mall/manager/bean/coupon/CouponVO.java

@@ -0,0 +1,94 @@
+package com.gree.mall.manager.bean.coupon;
+
+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;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel
+@Data
+public class CouponVO  {
+
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "优惠券id")
+    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 CouponUseTypeEnum type;
+
+    @ApiModelProperty(value = "优惠券类型")
+    private CouponTypeEnum couponType;
+
+    @ApiModelProperty(value = "订单满足金额")
+    private BigDecimal orderAmount;
+
+    @ApiModelProperty(value = "优惠券面值")
+    private BigDecimal couponValue;
+
+    @ApiModelProperty(value = "发放总量")
+    private Integer couponAmount;
+
+    @ApiModelProperty(value = "每人限领次数")
+    private Integer receiveLimitCount;
+
+    @ApiModelProperty(value = "显示时间")
+    private Date displayTime;
+
+
+    @ApiModelProperty(value = "优惠券领取开始时间")
+    private Date obtainStartTime;
+
+    @ApiModelProperty(value = "优惠券领取结束时间")
+    private Date obtainEndTime;
+
+    @ApiModelProperty(value = "领券多少天内有效")
+    private Integer activeDay;
+
+    @ApiModelProperty(value = "优惠券使用开始时间")
+    private Date activeStartTime;
+
+    @ApiModelProperty(value = "优惠券使用结束时间")
+    private Date activeEndTime;
+
+    @ApiModelProperty(value = "领取条件")
+    private CouponCrowdEnum receiveCrowd;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    @ApiModelProperty(value = "修改时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+
+    @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);
 }

+ 3 - 1
src/main/java/com/gree/mall/manager/commonmapper/WxCustomerMapper.java

@@ -44,5 +44,7 @@ public interface WxCustomerMapper {
     IPage<UserApplyBean> queryServiceApplyList(Page<Object> objectPage,
                                                @Param("companyWechatIds") List<String> companyWechatIds,
                                                @Param("keyword") String keyword,
-                                               @Param("status") String status);
+                                               @Param("status") String status,
+                                               @Param("adminWebsitIds") List<String> adminWebsitIds
+                                               );
 }

+ 39 - 0
src/main/java/com/gree/mall/manager/controller/coupon/CouponController.java

@@ -1,13 +1,18 @@
 package com.gree.mall.manager.controller.coupon;
 
+import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.admin.AdminWebsitVO;
 import com.gree.mall.manager.bean.coupon.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.coupon.CouponLogic;
 import com.gree.mall.manager.plus.entity.Coupon;
 import com.gree.mall.manager.plus.entity.UserCoupon;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -45,6 +50,30 @@ public class CouponController {
         return ResponseHelper.success(page);
     }
 
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation(value = "优惠券列表V2")
+    public ResponseHelper<IPage<CouponVO>> list(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws RemoteServiceException {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<CouponVO> couponVOIPage = couponLogic.list(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        return ResponseHelper.success(couponVOIPage, new TypeReference<CouponVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @ApiOperation(value = "优惠券列表导出V2")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<CouponVO> couponVOIPage = couponLogic.list(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);        //3.导出
+        FieldUtils.exportData(couponVOIPage.getRecords(), zfireParam.getExportFields(), request, response);
+    }
+
+
     @GetMapping("/detail")
     @ApiOperation(value = "券详情")
     public ResponseHelper<CouponDetailBean> detail(
@@ -74,6 +103,16 @@ public class CouponController {
         return ResponseHelper.success();
     }
 
+    @PostMapping("/cancel")
+    @ApiOperation(value = "取消券")
+    public ResponseHelper cancel(
+            HttpServletRequest request,
+            @ApiParam(value = "id",required = true) @RequestParam String couponId)
+            throws RemoteServiceException {
+        couponLogic.cancel(couponId);
+        return ResponseHelper.success();
+    }
+
 
     @PostMapping("/reissue")
     @ApiOperation(value = "补发业务员券")

+ 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=已使用

+ 27 - 5
src/main/java/com/gree/mall/manager/logic/coupon/CouponLogic.java

@@ -1,11 +1,14 @@
 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;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.ExcelData;
 import com.gree.mall.manager.bean.activity.CustomSecSpecBean;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.admin.AdminWebsitVO;
 import com.gree.mall.manager.bean.coupon.*;
 import com.gree.mall.manager.commonmapper.CouponDateMapper;
 import com.gree.mall.manager.commonmapper.SecKillMapper;
@@ -17,6 +20,8 @@ import com.gree.mall.manager.plus.entity.*;
 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;
@@ -153,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);
@@ -165,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()) {
@@ -191,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()) {
@@ -219,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())
@@ -245,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())
@@ -683,4 +688,21 @@ public class CouponLogic {
         userCouponService.saveBatch(userCouponList);
     }
 
+    public void cancel(String couponId) {
+        userCouponService.lambdaUpdate()
+                .eq(UserCoupon::getCouponId,couponId)
+                .eq(UserCoupon::getStatus,false).remove();
+    }
+
+    public IPage<CouponVO> list(Page page, ZfireParamBean zfireParam) {
+
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        //1.组装查询条件
+        FieldUtils.supplyParam(zfireParam, CouponVO.class,adminUser);
+
+        IPage<CouponVO> couponVOIPage = couponDateMapper.couponList(page, zfireParam);
+        return couponVOIPage;
+    }
 }

+ 5 - 1
src/main/java/com/gree/mall/manager/logic/user/UserLogic.java

@@ -109,10 +109,12 @@ public class UserLogic {
         //获取当前登录企业微信id
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
         List<String> companyWechatIds = adminUser.getAdminCompanyIds();
+        List<String> adminWebsitIds = adminUser.getAdminWebsitIds();
 
         LambdaQueryWrapper<User> memberLambdaQueryWrapper = new LambdaQueryWrapper<>();
         memberLambdaQueryWrapper
                 .in(CollectionUtils.isNotEmpty(companyWechatIds), User::getCompanyWechatId, companyWechatIds)
+                .in(CollectionUtils.isNotEmpty(adminWebsitIds), User::getWebsitId, adminWebsitIds)
                 .eq(isExchangeCode != null,User::getIsExchangeCode,isExchangeCode)
                 .eq(promotionGroupLeader != null, User::getPromotionGroupLeader, promotionGroupLeader)
                 .eq(StringUtils.isNotEmpty(type), User::getType, type)
@@ -563,7 +565,8 @@ public class UserLogic {
         //获取当前登录企业微信id
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
         List<String> companyWechatIds = adminUser.getAdminCompanyIds();
-        IPage<UserApplyBean> page = wxCustomerMapper.queryServiceApplyList(new Page<>(pageNum, pageSize), companyWechatIds, keyword, status);
+        List<String> adminWebsitIds = adminUser.getAdminWebsitIds();
+        IPage<UserApplyBean> page = wxCustomerMapper.queryServiceApplyList(new Page<>(pageNum, pageSize), companyWechatIds, keyword, status,adminWebsitIds);
         return page;
     }
 
@@ -614,6 +617,7 @@ public class UserLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         return userServiceWaitService.lambdaQuery()
                 .eq(UserServiceWait::getCompanyWechatId, adminUser.getCompanyWechatId())
+                .eq(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),UserServiceWait::getWebsitId, adminUser.getAdminWebsitIds())
                 .like(StringUtils.isNotBlank(websitId), UserServiceWait::getWebsitId, websitId)
                 .like(StringUtils.isNotBlank(websitName), UserServiceWait::getWebsitName, websitName)
                 .like(StringUtils.isNotBlank(workUserId), UserServiceWait::getWorkerId, workUserId)

+ 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>

+ 6 - 0
src/main/resources/mapper/WxCustomerMapper.xml

@@ -129,6 +129,12 @@
                 #{item}
             </foreach>
         </if>
+        <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+            AND b.adminWebsitIds IN
+            <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="keyword != null and keyword != ''">
             AND (a.mobile LIKE concat('%',#{keyword,jdbcType=VARCHAR},'%') OR b.nick_name LIKE
             concat('%',#{keyword,jdbcType=VARCHAR},'%'))