Commit ea4d021b by 吕明尚

删除优惠卷领取记录表增加优惠卷

parent 4f49e546
...@@ -60,4 +60,6 @@ public interface SCouponMapper ...@@ -60,4 +60,6 @@ public interface SCouponMapper
public int deleteSCouponByIds(Long[] ids); public int deleteSCouponByIds(Long[] ids);
List<SCoupon> selectSCouponByName(String dealTitle); List<SCoupon> selectSCouponByName(String dealTitle);
List<SCoupon> selectSCouponByIds(Long[] couponIds);
} }
...@@ -65,4 +65,6 @@ public interface ISCouponService ...@@ -65,4 +65,6 @@ public interface ISCouponService
* @return 结果 * @return 结果
*/ */
List<SCoupon> selectSCouponByName(String dealTitle); List<SCoupon> selectSCouponByName(String dealTitle);
List<SCoupon> selectSCouponByIds(Long[] couponIds);
} }
...@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.*; import share.common.enums.*;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
...@@ -102,7 +103,6 @@ public class QPServiceImpl implements QPService { ...@@ -102,7 +103,6 @@ public class QPServiceImpl implements QPService {
} }
} }
//根据优惠卷名称查询优惠劵配置 查询list,取第一个 //根据优惠卷名称查询优惠劵配置 查询list,取第一个
SCoupon sCoupon = isCouponService.selectSCouponByName(prepare.getDeal_title()).get(0);
TuangouReceiptPrepareResponseEntityVo response = new TuangouReceiptPrepareResponseEntityVo(); TuangouReceiptPrepareResponseEntityVo response = new TuangouReceiptPrepareResponseEntityVo();
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon(); SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId()); sConsumerCoupon.setConsumerId(user.getId());
...@@ -114,7 +114,30 @@ public class QPServiceImpl implements QPService { ...@@ -114,7 +114,30 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode()); sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId())); sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setCreateTime(new Date()); sConsumerCoupon.setCreateTime(new Date());
if (ObjectUtils.isEmpty(sCoupon)) { sConsumerCoupon.setSubPrice(BigDecimal.valueOf(prepare.getDeal_marketprice()));
//根据门店id查询门店信息
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal = queryshopdeal(openShopUuid);
queryshopdeal.stream().forEach(o -> {
//套餐名称相同并且在售卖中
if (prepare.getDeal_title().equals(o.getTitle()) && o.getSale_status().equals(saleStatusEnum.SELLING.getCode())) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date receiptEndDate = sdf.parse(o.getReceipt_end_date());
Date receiptBeginDate = sdf.parse(o.getReceipt_begin_date());
sConsumerCoupon.setStartDate(receiptBeginDate);
sConsumerCoupon.setEndDate(receiptEndDate);
} catch (Exception e) {
e.printStackTrace();
}
}
});
List<SCoupon> sCoupons = isCouponService.selectSCouponByName(prepare.getDeal_title());
SCoupon sCoupon = new SCoupon();
if (!CollectionUtils.isEmpty(sCoupons)) {
sCoupon = isCouponService.selectSCouponByName(prepare.getDeal_title()).get(0);
}
if (!ObjectUtils.isEmpty(sCoupon)) {
sConsumerCoupon.setCouponType(CouponTypeEnum.CASH.getCode()); sConsumerCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
sConsumerCoupon.setStoreType(StoreType.getCodeList()); sConsumerCoupon.setStoreType(StoreType.getCodeList());
sConsumerCoupon.setRoomType(RoomType.getCodeList()); sConsumerCoupon.setRoomType(RoomType.getCodeList());
...@@ -123,24 +146,6 @@ public class QPServiceImpl implements QPService { ...@@ -123,24 +146,6 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setMaxDuration(DEFAULT_MAX_DURATION); sConsumerCoupon.setMaxDuration(DEFAULT_MAX_DURATION);
sConsumerCoupon.setDuration(DEFAULT_DURATION); sConsumerCoupon.setDuration(DEFAULT_DURATION);
sConsumerCoupon.setMinPrice(DEFAULT_MIN_PRICE); sConsumerCoupon.setMinPrice(DEFAULT_MIN_PRICE);
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(prepare.getDeal_marketprice()));
//根据门店id查询门店信息
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal = queryshopdeal(openShopUuid);
queryshopdeal.stream().forEach(o -> {
//套餐名称相同并且在售卖中
if (prepare.getDeal_title().equals(o.getTitle()) && o.getSale_status().equals(saleStatusEnum.SELLING.getCode())) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date receiptEndDate = sdf.parse(o.getReceipt_end_date());
Date receiptBeginDate = sdf.parse(o.getReceipt_begin_date());
sConsumerCoupon.setStartDate(receiptBeginDate);
sConsumerCoupon.setEndDate(receiptEndDate);
} catch (Exception e) {
e.printStackTrace();
}
}
});
sConsumerCoupon.setCouponTimeStart(DEFAULT_START_TIME); sConsumerCoupon.setCouponTimeStart(DEFAULT_START_TIME);
sConsumerCoupon.setCouponTimeEnd(DEFAULT_END_TIME); sConsumerCoupon.setCouponTimeEnd(DEFAULT_END_TIME);
} else { } else {
...@@ -152,12 +157,8 @@ public class QPServiceImpl implements QPService { ...@@ -152,12 +157,8 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration()); sConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
sConsumerCoupon.setDuration(sCoupon.getDuration()); sConsumerCoupon.setDuration(sCoupon.getDuration());
sConsumerCoupon.setMinPrice(sCoupon.getMinPrice()); sConsumerCoupon.setMinPrice(sCoupon.getMinPrice());
sConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(prepare.getReceiptEndDate());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime()); sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime()); sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
} }
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon); isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
response.setConsumerCouponId(sConsumerCoupon.getId()); response.setConsumerCouponId(sConsumerCoupon.getId());
......
...@@ -4,8 +4,11 @@ package share.system.service.impl; ...@@ -4,8 +4,11 @@ package share.system.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -108,6 +111,23 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -108,6 +111,23 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
*/ */
@Override @Override
public int deleteSConsumerCouponByIds(Long[] ids) { public int deleteSConsumerCouponByIds(Long[] ids) {
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SConsumerCoupon::getId, ids);
List<SConsumerCoupon> sConsumerCoupons = sConsumerCouponMapper.selectList(queryWrapper);
//获取sConsumerCoupons里的优惠券id
Long[] couponIds = sConsumerCoupons.stream().map(SConsumerCoupon::getCouponId).toArray(Long[]::new);
//根据优惠券id查询优惠券信息
List<SCoupon> sCoupons = sCouponService.selectSCouponByIds(couponIds);
sCoupons.stream().forEach(item -> {
//判断ids里的优惠券id是否等于sCoupons里的优惠券id
if (Arrays.asList(couponIds).contains(item.getId())) {
//优惠券数量加一
item.setNumber(item.getNumber() + 1);
sCouponService.updateSCoupon(item);
}
});
return sConsumerCouponMapper.deleteSConsumerCouponByIds(ids); return sConsumerCouponMapper.deleteSConsumerCouponByIds(ids);
} }
...@@ -205,14 +225,13 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -205,14 +225,13 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
newSConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime()); newSConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
newSConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime()); newSConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
newSConsumerCoupon.setCouponType(sCoupon.getCouponType()); newSConsumerCoupon.setCouponType(sCoupon.getCouponType());
if (sCoupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
newSConsumerCoupon.setMinPrice(new BigDecimal(0.00)); newSConsumerCoupon.setMinPrice(new BigDecimal(0.00));
newSConsumerCoupon.setSubPrice(sCoupon.getSubPrice()); newSConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
} else if (sCoupon.getCouponType().equals(CouponTypeEnum.DURATION.getCode())) {
newSConsumerCoupon.setMinDuration(sCoupon.getMinDuration()); newSConsumerCoupon.setMinDuration(sCoupon.getMinDuration());
newSConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration()); newSConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
newSConsumerCoupon.setDuration(sCoupon.getDuration()); newSConsumerCoupon.setDuration(sCoupon.getDuration());
}
newSConsumerCoupon.setSourceType(SourceTypeEnum.GIVE.getCode()); newSConsumerCoupon.setSourceType(SourceTypeEnum.GIVE.getCode());
newSConsumerCoupon.setPlatformType(String.valueOf(sCoupon.getPlatformType())); newSConsumerCoupon.setPlatformType(String.valueOf(sCoupon.getPlatformType()));
newSConsumerCoupon.setStartDate(sCoupon.getStartDate()); newSConsumerCoupon.setStartDate(sCoupon.getStartDate());
......
...@@ -129,4 +129,9 @@ public class SCouponServiceImpl implements ISCouponService ...@@ -129,4 +129,9 @@ public class SCouponServiceImpl implements ISCouponService
public List<SCoupon> selectSCouponByName(String dealTitle) { public List<SCoupon> selectSCouponByName(String dealTitle) {
return sCouponMapper.selectSCouponByName(dealTitle); return sCouponMapper.selectSCouponByName(dealTitle);
} }
@Override
public List<SCoupon> selectSCouponByIds(Long[] couponIds) {
return sCouponMapper.selectSCouponByIds(couponIds);
}
} }
...@@ -82,6 +82,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -82,6 +82,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSCouponVo"/> <include refid="selectSCouponVo"/>
where name = #{name} where name = #{name}
</select> </select>
<select id="selectSCouponByIds" resultMap="SCouponResult">
<include refid="selectSCouponVo"/>
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertSCoupon" parameterType="SCoupon" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSCoupon" parameterType="SCoupon" useGeneratedKeys="true" keyProperty="id">
insert into s_coupon insert into s_coupon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment