Commit 81d94082 by 吕明尚

优惠券增加金额券

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