Commit 81d94082 by 吕明尚

优惠券增加金额券

parent 1148ac34
...@@ -30,6 +30,12 @@ public class SStore extends BaseEntity ...@@ -30,6 +30,12 @@ public class SStore extends BaseEntity
@Excel(name = "门店名称") @Excel(name = "门店名称")
private String name; private String name;
/**
* 城市名称
*/
@Excel(name = "城市名称")
private String cityName;
/** 门店主图 */ /** 门店主图 */
@Excel(name = "门店主图") @Excel(name = "门店主图")
private String images; private String images;
......
...@@ -2,7 +2,6 @@ package share.system.domain.vo; ...@@ -2,7 +2,6 @@ package share.system.domain.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity; import share.common.core.domain.BaseEntity;
import java.util.List; import java.util.List;
...@@ -26,6 +25,12 @@ public class SStoreVo extends BaseEntity ...@@ -26,6 +25,12 @@ public class SStoreVo extends BaseEntity
@ApiModelProperty(value = "门店名称") @ApiModelProperty(value = "门店名称")
private String name; private String name;
/**
* 城市名称
*/
@ApiModelProperty(value = "城市名称")
private String cityName;
/** 门店主图 */ /** 门店主图 */
@ApiModelProperty(value = "门店主图") @ApiModelProperty(value = "门店主图")
private String images; private String images;
......
...@@ -47,7 +47,10 @@ import share.system.service.QPService; ...@@ -47,7 +47,10 @@ import share.system.service.QPService;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -410,13 +413,17 @@ public class QPServiceImpl implements QPService { ...@@ -410,13 +413,17 @@ public class QPServiceImpl implements QPService {
logger.error("适用店铺查询接口失败: code={}, msg={}", response.getCode(), response.getMsg()); logger.error("适用店铺查询接口失败: code={}, msg={}", response.getCode(), response.getMsg());
throw new RuntimeException(response.getMsg()); throw new RuntimeException(response.getMsg());
} }
List<SStore> stores = storeService.list(); return response.getData();
Map<String, SStore> storeMap = stores.stream() //
.collect(Collectors.toMap(SStore::getOpenShopUuid, s -> s)); // List<SStore> stores = storeService.list(new LambdaQueryWrapper<SStore>().isNotNull(SStore::getOpenShopUuid));
List<CustomerKeyShopScopeResponseEntity> data = response.getData(); // if(CollectionUtils.isEmpty(stores)){
return data.stream() // return data;
.filter(entity -> !storeMap.containsKey(entity.getOpen_shop_uuid())) // }
.collect(Collectors.toList()); // Map<String, SStore> storeMap = stores.stream()
// .collect(Collectors.toMap(SStore::getOpenShopUuid, s -> s));
// return data.stream()
// .filter(entity -> !storeMap.containsKey(entity.getOpen_shop_uuid()))
// .collect(Collectors.toList());
} }
@Override @Override
......
...@@ -270,11 +270,15 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -270,11 +270,15 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
} }
//取绝对值 //取绝对值
if (vo.getIsAvailable().equals(AvailableEnum.AVAILABLE.getCode())) { if (vo.getIsAvailable().equals(AvailableEnum.AVAILABLE.getCode())) {
if (!ObjectUtils.isEmpty(roomLabel)) { if (!vo.getCouponType().equals(CouponTypeEnum.AMOUNT.getCode())) {
vo.setBalance((roomLabel.getPromotionAmount().subtract(vo.getSalePrice())). if (!ObjectUtils.isEmpty(roomLabel)) {
add(((timeLong.subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))).abs()); vo.setBalance((roomLabel.getPromotionAmount().subtract(vo.getSalePrice())).
} else if (!ObjectUtils.isEmpty(finalById)) { add(((timeLong.subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))).abs());
vo.setBalance(finalById.getPrice().subtract(vo.getSalePrice())); } else if (!ObjectUtils.isEmpty(finalById)) {
vo.setBalance(finalById.getPrice().subtract(vo.getSalePrice()));
}
} else {
vo.setBalance(new BigDecimal("999"));
} }
} else { } else {
vo.setBalance(new BigDecimal("999")); vo.setBalance(new BigDecimal("999"));
...@@ -486,9 +490,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -486,9 +490,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
if (sCoupon.getNumber().equals(ZERO)) { if (sCoupon.getNumber().equals(ZERO)) {
throw new RuntimeException("优惠券数量为0"); throw new RuntimeException("优惠券数量为0");
} }
if (!sCoupon.getCouponType().equals(CouponTypeEnum.DURATION.getCode()) && !sCoupon.getCouponType().equals(CouponTypeEnum.PACKAGE.getCode())) {
throw new RuntimeException("只能赠送时长劵或者套餐券");
}
//创建优惠卷领取记录 //创建优惠卷领取记录
SConsumerCoupon newSConsumerCoupon = new SConsumerCoupon(); SConsumerCoupon newSConsumerCoupon = new SConsumerCoupon();
newSConsumerCoupon.setCouponId(sCoupon.getId()); newSConsumerCoupon.setCouponId(sCoupon.getId());
......
...@@ -192,7 +192,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl ...@@ -192,7 +192,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
@Override @Override
public List<SCoupon> queryShopDeal() { public List<SCoupon> queryShopDeal() {
//查询所有门店的shopId //查询所有门店的shopId
List<SStore> sStores = storeService.list(); List<SStore> sStores = storeService.list(new LambdaQueryWrapper<SStore>().isNotNull(SStore::getOpenShopUuid));
//获取所有的openShopUuid,去掉为空的 //获取所有的openShopUuid,去掉为空的
List<String> openShopUuids = sStores.stream().map(SStore::getOpenShopUuid).filter(StringUtils::isNotBlank).collect(Collectors.toList()); List<String> openShopUuids = sStores.stream().map(SStore::getOpenShopUuid).filter(StringUtils::isNotBlank).collect(Collectors.toList());
Map<Long, SCoupon> sCouponList = new LinkedHashMap<>(); Map<Long, SCoupon> sCouponList = new LinkedHashMap<>();
...@@ -231,7 +231,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl ...@@ -231,7 +231,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon.setCouponType(CouponTypeEnum.CASH.getCode()); sCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
sCouponList.put(item.getDealgroup_id(), sCoupon); sCouponList.put(item.getDealgroup_id(), sCoupon);
//从门店列表中获取门店id //从门店列表中获取门店id
sCoupon.setStoreIds(String.valueOf(sStores.stream().filter(store -> store.getOpenShopUuid().equals(openShopUuid)).findFirst().get().getId())); sCoupon.setStoreIds(String.valueOf(sStores.stream().filter(store -> store.getOpenShopUuid().equals(openShopUuid)).findFirst().orElse(null).getId()));
} else { } else {
sCoupon1.setStoreIds(sCoupon1.getStoreIds() + "," + sStores.stream().filter(store -> store.getOpenShopUuid().equals(openShopUuid)).findFirst().get().getId()); sCoupon1.setStoreIds(sCoupon1.getStoreIds() + "," + sStores.stream().filter(store -> store.getOpenShopUuid().equals(openShopUuid)).findFirst().get().getId());
} }
......
...@@ -1903,6 +1903,34 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1903,6 +1903,34 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setCouponFee(priceResponse.getTotalFee().subtract(subtract).abs()); priceResponse.setCouponFee(priceResponse.getTotalFee().subtract(subtract).abs());
} }
break; break;
case AMOUNT://金额券
//判断优惠券最小使用金额
if (consumerCoupon.getMinPrice().compareTo(priceResponse.getTotalFee()) > 0) {
throw new BaseException("总金额小于优惠券最小使用金额");
}
BigDecimal payFee = new BigDecimal(0);
if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
SRoom room = roomService.getById(request.getRoomId());
payFee = (DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).multiply(room.getPrice())).subtract(consumerCoupon.getOriginalPrice());
} else {
SPack byId = packService.getById(roomLabel.getPackId());
payFee = byId.getPrice().subtract(consumerCoupon.getOriginalPrice());
}
} else if (!ObjectUtils.isEmpty(request.getPackId())) {
SPack byId = packService.getById(request.getPackId());
payFee = byId.getPrice().subtract(consumerCoupon.getOriginalPrice());
}
//判断是否为负数
if (payFee.compareTo(BigDecimal.ZERO) < 0) {
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setCouponFee(priceResponse.getTotalFee());
} else {
priceResponse.setPayFee(payFee);
priceResponse.setCouponFee(priceResponse.getTotalFee().subtract(payFee).abs());
}
break;
// //
// BigDecimal timeLong = DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()); // BigDecimal timeLong = DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate());
// if (new BigDecimal(consumerCoupon.getMinDuration()).compareTo(timeLong) > 0) { // if (new BigDecimal(consumerCoupon.getMinDuration()).compareTo(timeLong) > 0) {
......
...@@ -481,17 +481,19 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -481,17 +481,19 @@ public class TiktokServiceImpl implements TiktokService {
TiktokCouponDto tiktokCouponDto = new TiktokCouponDto(); TiktokCouponDto tiktokCouponDto = new TiktokCouponDto();
tiktokCouponDto.setPage(1); tiktokCouponDto.setPage(1);
tiktokCouponDto.setSize(5); tiktokCouponDto.setSize(5);
List<TiktokPoi> tiktokPois = poiQuery(tiktokCouponDto); // List<TiktokPoi> tiktokPois =
List<SStore> list = storeService.list(); return poiQuery(tiktokCouponDto);
//过滤以增加的门店 根据poiId
List<TiktokPoi> collect = tiktokPois.stream().filter(o1 -> { // List<SStore> list = storeService.list();
Optional<SStore> first = list.stream().filter(o2 -> o1.getPoiId().equals(o2.getTiktokPoiId())).findFirst(); // //过滤以增加的门店 根据poiId
if (first.isPresent()) { // List<TiktokPoi> collect = tiktokPois.stream().filter(o1 -> {
return false; // Optional<SStore> first = list.stream().filter(o2 -> o1.getPoiId().equals(o2.getTiktokPoiId())).findFirst();
} // if (first.isPresent()) {
return true; // return false;
}).collect(java.util.stream.Collectors.toList()); // }
return collect; // return true;
// }).collect(java.util.stream.Collectors.toList());
// return collect;
} }
@Override @Override
......
...@@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="listDuration" resultMap="SCouponResult"> <select id="listDuration" resultMap="SCouponResult">
<include refid="selectSCouponVo"/> <include refid="selectSCouponVo"/>
where 1=1 and coupon_type in (4,5) where 1=1 and coupon_type in (4,5,6)
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="startDate != null">and start_date &lt;= #{startDate}</if> <if test="startDate != null">and start_date &lt;= #{startDate}</if>
<!-- <if test="endDate == null">and end_date >= NOW()</if> --> <!-- <if test="endDate == null">and end_date >= NOW()</if> -->
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<resultMap type="SStore" id="SStoreResult"> <resultMap type="SStore" id="SStoreResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="name" column="name" /> <result property="name" column="name" />
<result property="cityName" column="city_name"/>
<result property="images" column="images" /> <result property="images" column="images" />
<result property="address" column="address" /> <result property="address" column="address" />
<result property="longitude" column="longitude" /> <result property="longitude" column="longitude" />
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
<sql id="selectSStoreVo"> <sql id="selectSStoreVo">
select id, select id,
name, name,
city_name,
images, images,
address, address,
longitude, longitude,
...@@ -59,6 +61,7 @@ ...@@ -59,6 +61,7 @@
<include refid="selectSStoreVo"/> <include refid="selectSStoreVo"/>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="cityName != null and cityName != ''">and city_name = #{cityName}</if>
<if test="images != null and images != ''"> and images = #{images}</if> <if test="images != null and images != ''"> and images = #{images}</if>
<if test="address != null and address != ''">and address like concat('%', #{address}, '%')</if> <if test="address != null and address != ''">and address like concat('%', #{address}, '%')</if>
<if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if> <if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
...@@ -91,6 +94,7 @@ ...@@ -91,6 +94,7 @@
insert into s_store insert into s_store
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if> <if test="name != null">name,</if>
<if test="cityName != null">city_name,</if>
<if test="images != null">images,</if> <if test="images != null">images,</if>
<if test="address != null">address,</if> <if test="address != null">address,</if>
<if test="longitude != null">longitude,</if> <if test="longitude != null">longitude,</if>
...@@ -114,6 +118,7 @@ ...@@ -114,6 +118,7 @@
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if> <if test="name != null">#{name},</if>
<if test="cityName != null">#{cityName},</if>
<if test="images != null">#{images},</if> <if test="images != null">#{images},</if>
<if test="address != null">#{address},</if> <if test="address != null">#{address},</if>
<if test="longitude != null">#{longitude},</if> <if test="longitude != null">#{longitude},</if>
...@@ -141,6 +146,7 @@ ...@@ -141,6 +146,7 @@
update s_store update s_store
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if> <if test="name != null">name = #{name},</if>
<if test="cityName != null">city_name = #{cityName},</if>
<if test="images != null">images = #{images},</if> <if test="images != null">images = #{images},</if>
<if test="address != null">address = #{address},</if> <if test="address != null">address = #{address},</if>
<if test="longitude != null">longitude = #{longitude},</if> <if test="longitude != null">longitude = #{longitude},</if>
......
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