|
@@ -1,18 +1,18 @@
|
|
package com.gree.mall.contest.logic.coupon;
|
|
package com.gree.mall.contest.logic.coupon;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+
|
|
import com.gree.mall.contest.bean.ExcelData;
|
|
import com.gree.mall.contest.bean.ExcelData;
|
|
|
|
+import com.gree.mall.contest.bean.activity.CustomSecSpecBean;
|
|
import com.gree.mall.contest.bean.admin.AdminUserCom;
|
|
import com.gree.mall.contest.bean.admin.AdminUserCom;
|
|
import com.gree.mall.contest.bean.coupon.*;
|
|
import com.gree.mall.contest.bean.coupon.*;
|
|
import com.gree.mall.contest.bean.user.CurrentCompanyWechat;
|
|
import com.gree.mall.contest.bean.user.CurrentCompanyWechat;
|
|
import com.gree.mall.contest.bean.user.UserCouponCountBean;
|
|
import com.gree.mall.contest.bean.user.UserCouponCountBean;
|
|
-import com.gree.mall.contest.commonmapper.CouponDateMapper;
|
|
|
|
-import com.gree.mall.contest.commonmapper.CoustomUserCouponMapper;
|
|
|
|
-import com.gree.mall.contest.commonmapper.CustomCoupouMapper;
|
|
|
|
|
|
+import com.gree.mall.contest.commonmapper.*;
|
|
import com.gree.mall.contest.constant.Constant;
|
|
import com.gree.mall.contest.constant.Constant;
|
|
import com.gree.mall.contest.enums.QrCodeEnum;
|
|
import com.gree.mall.contest.enums.QrCodeEnum;
|
|
import com.gree.mall.contest.enums.UserTypeEnum;
|
|
import com.gree.mall.contest.enums.UserTypeEnum;
|
|
@@ -27,12 +27,15 @@ import com.gree.mall.contest.logic.user.UserLogic;
|
|
import com.gree.mall.contest.plus.entity.*;
|
|
import com.gree.mall.contest.plus.entity.*;
|
|
import com.gree.mall.contest.plus.service.*;
|
|
import com.gree.mall.contest.plus.service.*;
|
|
import com.gree.mall.contest.utils.CommonUtils;
|
|
import com.gree.mall.contest.utils.CommonUtils;
|
|
|
|
+import com.gree.mall.contest.utils.DateUtils;
|
|
import com.gree.mall.contest.utils.excel.ExcelUtils;
|
|
import com.gree.mall.contest.utils.excel.ExcelUtils;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.integration.redis.util.RedisLockRegistry;
|
|
import org.springframework.integration.redis.util.RedisLockRegistry;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -61,6 +64,9 @@ public class CouponLogic {
|
|
private final CustomCoupouMapper customCoupouMapper;
|
|
private final CustomCoupouMapper customCoupouMapper;
|
|
private final WechatLogic wechatLogic;
|
|
private final WechatLogic wechatLogic;
|
|
private final CoustomUserCouponMapper coustomUserCouponMapper;
|
|
private final CoustomUserCouponMapper coustomUserCouponMapper;
|
|
|
|
+ private final SecKillMapper secKillMapper;
|
|
|
|
+ private final CouponTagService couponTagService;
|
|
|
|
+ private final WxCustomerMapper wxCustomerMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 优惠券列表
|
|
* 优惠券列表
|
|
@@ -83,7 +89,7 @@ public class CouponLogic {
|
|
// couponExportBeans.addAll(couponSelfBeans);
|
|
// couponExportBeans.addAll(couponSelfBeans);
|
|
// }
|
|
// }
|
|
|
|
|
|
- String[] titles = {"优惠券名称", "发放数量", "领取数量", "使用数量", "优惠券金额", "领取来源-网点名称", "领取来源-业务员昵称", "领取来源-业务员电话", "优惠券状态", "领券客户昵称", "领券客户电话",
|
|
|
|
|
|
+ String[] titles = {"优惠券名称","发放数量","领取数量","使用数量","优惠券金额", "领取来源-网点名称", "领取来源-业务员昵称", "领取来源-业务员电话", "优惠券状态", "领券客户昵称", "领券客户电话",
|
|
"用券时间", "订单号", "订单实付金额"};
|
|
"用券时间", "订单号", "订单实付金额"};
|
|
ExcelData excelData = new ExcelData();
|
|
ExcelData excelData = new ExcelData();
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
@@ -124,6 +130,8 @@ public class CouponLogic {
|
|
CouponDetailBean couponBean = new CouponDetailBean();
|
|
CouponDetailBean couponBean = new CouponDetailBean();
|
|
BeanUtils.copyProperties(coupon, couponBean);
|
|
BeanUtils.copyProperties(coupon, couponBean);
|
|
couponBean.setGoodsList(couponGoodsService.lambdaQuery().eq(CouponGoods::getCouponId, couponId).list());
|
|
couponBean.setGoodsList(couponGoodsService.lambdaQuery().eq(CouponGoods::getCouponId, couponId).list());
|
|
|
|
+ couponBean.setTagList(couponDateMapper.couponTagDetail(couponId));
|
|
|
|
+ couponBean.setUserList(couponDateMapper.couponTagUser(couponId));
|
|
return couponBean;
|
|
return couponBean;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -132,6 +140,7 @@ public class CouponLogic {
|
|
*
|
|
*
|
|
* @param couponBean
|
|
* @param couponBean
|
|
*/
|
|
*/
|
|
|
|
+// @Async
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void add(HttpServletRequest request, CouponBean couponBean) throws RemoteServiceException {
|
|
public void add(HttpServletRequest request, CouponBean couponBean) throws RemoteServiceException {
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
@@ -149,7 +158,7 @@ public class CouponLogic {
|
|
couponBean.setCreateTime(new Date());
|
|
couponBean.setCreateTime(new Date());
|
|
couponBean.setCompanyWechatId(adminUser.getLoginCompanyWechatId());
|
|
couponBean.setCompanyWechatId(adminUser.getLoginCompanyWechatId());
|
|
couponBean.setCompanyName(adminUser.getLoginCompanyName());
|
|
couponBean.setCompanyName(adminUser.getLoginCompanyName());
|
|
- couponBean.setActiveType(couponBean.getActiveDay() != null ? 2 : 1);
|
|
|
|
|
|
+ couponBean.setActiveType(couponBean.getActiveDay() != null ? 2:1);
|
|
couponService.save(couponBean);
|
|
couponService.save(couponBean);
|
|
String couponId = couponBean.getCouponId();
|
|
String couponId = couponBean.getCouponId();
|
|
if (couponBean.getCouponType().trim().equals(CouponTypeEnum.GOODS.getName()) && couponBean.getGoodsList() != null) {
|
|
if (couponBean.getCouponType().trim().equals(CouponTypeEnum.GOODS.getName()) && couponBean.getGoodsList() != null) {
|
|
@@ -163,6 +172,31 @@ public class CouponLogic {
|
|
}
|
|
}
|
|
couponGoodsService.saveBatch(couponGoodsList);
|
|
couponGoodsService.saveBatch(couponGoodsList);
|
|
}
|
|
}
|
|
|
|
+ //指定标签
|
|
|
|
+ if (couponBean.getReceiveCrowd() == CouponCrowdEnum.TAG.getFlag() && couponBean.getTagList() != null) {
|
|
|
|
+ List<String> userIds = wxCustomerMapper.queryTagUserIdList(adminUser.getLoginCompanyWechatId(), couponBean.getTagList());
|
|
|
|
+ List<CouponTag> couponTagList = new ArrayList<>();
|
|
|
|
+ for (CouponTag couponTag : couponBean.getTagList()) {
|
|
|
|
+ couponTag.setCouponId(couponId);
|
|
|
|
+ couponTag.setCreateTime(new Date());
|
|
|
|
+ couponTag.setCompanyId(adminUser.getLoginCompanyWechatId());
|
|
|
|
+ couponTag.setCompanyName(adminUser.getLoginCompanyName());
|
|
|
|
+ couponTagList.add(couponTag);
|
|
|
|
+ }
|
|
|
|
+ couponTagService.saveBatch(couponTagList);
|
|
|
|
+
|
|
|
|
+ List<CouponUser> couponUserList = new ArrayList<>();
|
|
|
|
+ CouponUser couponUser = new CouponUser();
|
|
|
|
+ for (String userId : userIds) {
|
|
|
|
+ couponUser.setCouponId(couponId);
|
|
|
|
+ couponUser.setUserId(userId);
|
|
|
|
+ couponUser.setCreateTime(new Date());
|
|
|
|
+ couponUser.setCouponUserId(adminUser.getLoginCompanyWechatId());
|
|
|
|
+ couponUser.setCompanyName(adminUser.getAdminCompanyWechat().getCompanyName());
|
|
|
|
+ couponUserList.add(couponUser);
|
|
|
|
+ }
|
|
|
|
+ couponUserService.saveBatch(couponUserList);
|
|
|
|
+ }
|
|
|
|
|
|
//指定会员
|
|
//指定会员
|
|
if (couponBean.getReceiveCrowd().equals(CouponCrowdEnum.SPECIFY.getFlag()) && couponBean.getUserList() != null) {
|
|
if (couponBean.getReceiveCrowd().equals(CouponCrowdEnum.SPECIFY.getFlag()) && couponBean.getUserList() != null) {
|
|
@@ -219,7 +253,7 @@ public class CouponLogic {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//全部普通用户
|
|
//全部普通用户
|
|
- if (couponBean.getReceiveCrowd().equals(CouponCrowdEnum.ALL_GENRERAL.getFlag())) {
|
|
|
|
|
|
+ if (couponBean.getReceiveCrowd() == CouponCrowdEnum.ALL_GENRERAL.getFlag()) {
|
|
List<CouponUser> couponUserList = new ArrayList<>();
|
|
List<CouponUser> couponUserList = new ArrayList<>();
|
|
List<User> userList = userService.lambdaQuery()
|
|
List<User> userList = userService.lambdaQuery()
|
|
.eq(User::getType, UserTypeEnum.GENERAL.toString())
|
|
.eq(User::getType, UserTypeEnum.GENERAL.toString())
|
|
@@ -244,7 +278,7 @@ public class CouponLogic {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private UserCoupon assignCoupon(AdminUserCom adminUserCom, CouponBean couponBean, String userId) {
|
|
|
|
|
|
+ private UserCoupon assignCoupon(AdminUserCom adminUserCom,CouponBean couponBean, String userId) {
|
|
UserCoupon userCoupon = new UserCoupon();
|
|
UserCoupon userCoupon = new UserCoupon();
|
|
userCoupon.setCompanyWechatId(adminUserCom.getLoginCompanyWechatId());
|
|
userCoupon.setCompanyWechatId(adminUserCom.getLoginCompanyWechatId());
|
|
userCoupon.setCouponName(adminUserCom.getLoginCompanyName());
|
|
userCoupon.setCouponName(adminUserCom.getLoginCompanyName());
|
|
@@ -261,19 +295,19 @@ public class CouponLogic {
|
|
if (couponBean.getActiveDay() == null) {
|
|
if (couponBean.getActiveDay() == null) {
|
|
couponBean.setActiveDay(0);
|
|
couponBean.setActiveDay(0);
|
|
}
|
|
}
|
|
- if (couponBean.getActiveType().equals(CouponActiveTypeEnum.COMMON.getActiveType())) {
|
|
|
|
|
|
+ if (couponBean.getActiveType() == CouponActiveTypeEnum.COMMON.getActiveType()) {
|
|
userCoupon.setActiveStartTime(couponBean.getActiveStartTime());
|
|
userCoupon.setActiveStartTime(couponBean.getActiveStartTime());
|
|
userCoupon.setActiveEndTime(couponBean.getActiveEndTime());
|
|
userCoupon.setActiveEndTime(couponBean.getActiveEndTime());
|
|
}
|
|
}
|
|
//当日起多少天
|
|
//当日起多少天
|
|
- if (couponBean.getActiveType().equals(CouponActiveTypeEnum.TODAY.getActiveType())) {
|
|
|
|
- userCoupon.setActiveStartTime(DateUtil.parseTime(DateUtil.formatDate(DateUtil.date()) + " 00:00:00"));
|
|
|
|
- userCoupon.setActiveEndTime(DateUtil.parseTime(DateUtil.formatDate(DateUtil.offsetDay(DateUtil.date(), couponBean.getActiveDay())) + " 23:59:59"));
|
|
|
|
|
|
+ if (couponBean.getActiveType() == CouponActiveTypeEnum.TODAY.getActiveType()) {
|
|
|
|
+ userCoupon.setActiveStartTime(DateUtils.getStartTime());
|
|
|
|
+ userCoupon.setActiveEndTime(DateUtils.getStartTimeByDay(couponBean.getActiveDay()));
|
|
}
|
|
}
|
|
//次日起多少天
|
|
//次日起多少天
|
|
- if (couponBean.getActiveType().equals(CouponActiveTypeEnum.NEXTDAY.getActiveType())) {
|
|
|
|
- userCoupon.setActiveStartTime(DateUtil.parseTime(DateUtil.formatDate(DateUtil.offsetDay(DateUtil.date(), 1)) + " 00:00:00"));
|
|
|
|
- userCoupon.setActiveEndTime(DateUtil.parseTime(DateUtil.formatDate(DateUtil.offsetDay(DateUtil.date(), couponBean.getActiveDay() + 1)) + " 23:59:59"));
|
|
|
|
|
|
+ if (couponBean.getActiveType() == CouponActiveTypeEnum.NEXTDAY.getActiveType()) {
|
|
|
|
+ userCoupon.setActiveStartTime(DateUtils.getStartTimeByDay(1));
|
|
|
|
+ userCoupon.setActiveEndTime(DateUtils.getStartTimeByDay(couponBean.getActiveDay() + 1));
|
|
}
|
|
}
|
|
userCoupon.setState(new Date().before(couponBean.getActiveEndTime()) && new Date().after(couponBean.getActiveStartTime()));
|
|
userCoupon.setState(new Date().before(couponBean.getActiveEndTime()) && new Date().after(couponBean.getActiveStartTime()));
|
|
return userCoupon;
|
|
return userCoupon;
|
|
@@ -295,8 +329,8 @@ public class CouponLogic {
|
|
throw new RemoteServiceException("优惠券超过领取时间");
|
|
throw new RemoteServiceException("优惠券超过领取时间");
|
|
}
|
|
}
|
|
List<CouponUserTypeBean> userIds = reissueCouponBean.getUserIds();
|
|
List<CouponUserTypeBean> userIds = reissueCouponBean.getUserIds();
|
|
- if (CollectionUtil.isEmpty(userIds)) {
|
|
|
|
- userIds = couponDateMapper.reissueCouponUser(loginCompanyWechatId, coupon.getCouponId());
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(userIds)) {
|
|
|
|
+ userIds = couponDateMapper.reissueCouponUser(loginCompanyWechatId,coupon.getCouponId());
|
|
}
|
|
}
|
|
List<CouponUser> couponUserList = new ArrayList<>();
|
|
List<CouponUser> couponUserList = new ArrayList<>();
|
|
List<UserCoupon> userCouponList = new ArrayList<>();
|
|
List<UserCoupon> userCouponList = new ArrayList<>();
|
|
@@ -354,6 +388,19 @@ public class CouponLogic {
|
|
couponGoodsService.save(couponGoods);
|
|
couponGoodsService.save(couponGoods);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //清除会员
|
|
|
|
+ if (couponBean.getTagList() != null && couponBean.getTagList().size() > 0) {
|
|
|
|
+ couponTagService.lambdaUpdate()
|
|
|
|
+ .eq(CouponTag::getCouponId, couponBean.getCouponId())
|
|
|
|
+ .remove();
|
|
|
|
+ for (CouponTag couponTag : couponBean.getTagList()) {
|
|
|
|
+ couponTag.setCouponId(couponBean.getCouponId());
|
|
|
|
+ couponTag.setCreateTime(now);
|
|
|
|
+ couponTag.setCompanyId(loginCompanyWechatId);
|
|
|
|
+ couponTag.setCompanyName(loginCompanyName);
|
|
|
|
+ couponTagService.save(couponTag);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if (couponBean.getUserList() != null && couponBean.getUserList().size() > 0) {
|
|
if (couponBean.getUserList() != null && couponBean.getUserList().size() > 0) {
|
|
couponUserService.lambdaUpdate()
|
|
couponUserService.lambdaUpdate()
|
|
@@ -480,13 +527,14 @@ public class CouponLogic {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 领取优惠券明细
|
|
* 领取优惠券明细
|
|
- *
|
|
|
|
* @param userCouponId
|
|
* @param userCouponId
|
|
* @param pageNo
|
|
* @param pageNo
|
|
* @param pageSize
|
|
* @param pageSize
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public IPage<UserCouponBean> receiveCouponDetail(String userCouponId, Integer pageNo, Integer pageSize) {
|
|
|
|
|
|
+ public IPage<UserCouponBean> receiveCouponDetail(String userCouponId,Integer pageNo,Integer pageSize){
|
|
|
|
+
|
|
|
|
+ //UserCoupon uc = userCouponService.getById(userCouponId);
|
|
|
|
|
|
IPage page = userCouponService.lambdaQuery()
|
|
IPage page = userCouponService.lambdaQuery()
|
|
.eq(UserCoupon::getTransferor, userCouponId)
|
|
.eq(UserCoupon::getTransferor, userCouponId)
|
|
@@ -495,10 +543,10 @@ public class CouponLogic {
|
|
.page(new Page<>(pageNo, pageSize));
|
|
.page(new Page<>(pageNo, pageSize));
|
|
|
|
|
|
List<UserCouponBean> list = new ArrayList<>();
|
|
List<UserCouponBean> list = new ArrayList<>();
|
|
- for (Object o : page.getRecords()) {
|
|
|
|
- UserCoupon userCoupon = (UserCoupon) o;
|
|
|
|
|
|
+ for(Object o : page.getRecords()){
|
|
|
|
+ UserCoupon userCoupon = (UserCoupon)o;
|
|
UserCouponBean couponUser = new UserCouponBean();
|
|
UserCouponBean couponUser = new UserCouponBean();
|
|
- BeanUtils.copyProperties(userCoupon, couponUser);
|
|
|
|
|
|
+ BeanUtils.copyProperties(userCoupon,couponUser);
|
|
User user = userService.getById(userCoupon.getUserId());
|
|
User user = userService.getById(userCoupon.getUserId());
|
|
couponUser.setUserName(user.getNickName());
|
|
couponUser.setUserName(user.getNickName());
|
|
couponUser.setMobile(user.getMobile());
|
|
couponUser.setMobile(user.getMobile());
|
|
@@ -516,7 +564,7 @@ public class CouponLogic {
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
|
|
|
|
return userService.lambdaQuery()
|
|
return userService.lambdaQuery()
|
|
- .in(CollectionUtil.isNotEmpty(companyWechatIds), User::getCompanyWechatId, companyWechatIds)
|
|
|
|
|
|
+ .in(CollectionUtils.isNotEmpty(companyWechatIds), User::getCompanyWechatId, companyWechatIds)
|
|
.eq(StringUtils.isNotEmpty(type), User::getType, type)
|
|
.eq(StringUtils.isNotEmpty(type), User::getType, type)
|
|
.ge(registerTime != null, User::getCreateTime, registerTime)
|
|
.ge(registerTime != null, User::getCreateTime, registerTime)
|
|
.like(StringUtils.isNotEmpty(tel), User::getMobile, tel.trim())
|
|
.like(StringUtils.isNotEmpty(tel), User::getMobile, tel.trim())
|
|
@@ -525,12 +573,21 @@ public class CouponLogic {
|
|
.page(new Page<>(pageNo, pageSize));
|
|
.page(new Page<>(pageNo, pageSize));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public IPage<CustomSecSpecBean> goodsSpecList(HttpServletRequest request, String categoryId, String keyword, Integer pageNum, Integer pageSize) {
|
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
+
|
|
|
|
+ return secKillMapper.querySpecListforCoupon(new Page<>(pageNum, pageSize), adminUser.getCompanyWechatIds(), categoryId, keyword);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 订单取消,恢复优惠券
|
|
* 订单取消,恢复优惠券
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
public void refundCoupon(String userCouponId) {
|
|
public void refundCoupon(String userCouponId) {
|
|
- if (StringUtils.isEmpty(userCouponId)) {
|
|
|
|
|
|
+ if(StringUtils.isEmpty(userCouponId)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
userCouponService.lambdaUpdate()
|
|
userCouponService.lambdaUpdate()
|
|
@@ -544,7 +601,7 @@ public class CouponLogic {
|
|
}
|
|
}
|
|
log.info("订单取消,恢复用户优惠券id{}", userCouponId);
|
|
log.info("订单取消,恢复用户优惠券id{}", userCouponId);
|
|
UserCoupon userCoupon = userCouponService.getById(userCouponId);
|
|
UserCoupon userCoupon = userCouponService.getById(userCouponId);
|
|
- if (userCoupon.getTransferType() != null && userCoupon.getTransferType()) {
|
|
|
|
|
|
+ if(userCoupon.getTransferType() != null && userCoupon.getTransferType()){
|
|
userCoupon.setLeftShareTimes(userCoupon.getLeftShareTimes() + 1);
|
|
userCoupon.setLeftShareTimes(userCoupon.getLeftShareTimes() + 1);
|
|
userCoupon.updateById();
|
|
userCoupon.updateById();
|
|
}
|
|
}
|