活动逻辑处理
This commit is contained in:
parent
002baf3ffd
commit
c91fc181c9
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.modules.activity.ShopActivityCutprice;
|
import com.suisung.mall.common.modules.activity.ShopActivityCutprice;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
|
import org.springframework.data.util.Pair;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -28,4 +29,13 @@ public interface ShopActivityCutpriceService extends IBaseService<ShopActivityCu
|
|||||||
|
|
||||||
CommonResult doCutPrice(Integer ac_id, Integer user_id);
|
CommonResult doCutPrice(Integer ac_id, Integer user_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 砍价活动是否可以下单
|
||||||
|
*
|
||||||
|
* @param ac_id 活动 自增Id
|
||||||
|
* @param order_user_id 下单用户
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Pair<Boolean, String> canDoOrderCutPriceActivity(Integer ac_id, Integer order_user_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
|||||||
import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
|
import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.util.Pair;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -397,4 +398,41 @@ public class ShopActivityCutpriceServiceImpl extends BaseServiceImpl<ShopActivit
|
|||||||
return CommonResult.success(ach_data);
|
return CommonResult.success(ach_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 砍价活动是否可以下单
|
||||||
|
*
|
||||||
|
* @param activity_id 活动 Id
|
||||||
|
* @param order_user_id 下单用户
|
||||||
|
* <p>
|
||||||
|
* 判断逻辑:
|
||||||
|
* 1、活动是否过期
|
||||||
|
* 2、活动是否是下单用户的
|
||||||
|
* 3、活动是否是砍到最低价
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Pair<Boolean, String> canDoOrderCutPriceActivity(Integer activity_id, Integer order_user_id) {
|
||||||
|
QueryWrapper<ShopStoreActivityBase> params = new QueryWrapper<>();
|
||||||
|
params.eq("activity_id", activity_id);
|
||||||
|
ShopStoreActivityBase storeActivityBase = shopStoreActivityBaseService.getOne(params);
|
||||||
|
if (storeActivityBase == null) {
|
||||||
|
return Pair.of(false, I18nUtil._("该活动不存在!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shopStoreActivityBaseService.isActivityTimeValid(storeActivityBase.getActivity_starttime(), storeActivityBase.getActivity_endtime())) {
|
||||||
|
return Pair.of(false, I18nUtil._("该活动已过期!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<ShopActivityCutprice> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("activity_id", activity_id);
|
||||||
|
queryWrapper.eq("user_id", order_user_id);
|
||||||
|
queryWrapper.orderByDesc("ac_id");
|
||||||
|
ShopActivityCutprice shopActivityCutprice = getOne(queryWrapper);
|
||||||
|
if (shopActivityCutprice == null) {
|
||||||
|
return Pair.of(false, I18nUtil._("未找到用户发起的砍价活动!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1155,13 +1155,13 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 时间槽间隔(分钟)
|
// 时间槽间隔(分钟)
|
||||||
int slotInterval = 30;
|
int slotInterval = 15;
|
||||||
|
|
||||||
// 对于今天,需要特殊处理:第二个时间槽从当前时间+50分钟开始
|
// 对于今天,需要特殊处理:第二个时间槽从当前时间+50分钟开始
|
||||||
Date startTime = openTime;
|
Date startTime = openTime;
|
||||||
if (isToday) {
|
if (isToday) {
|
||||||
// 当前时间+50分钟作为第二个时间槽的开始时间
|
// 当前时间+50分钟作为第二个时间槽的开始时间
|
||||||
Date nowPlusFifty = DateUtil.offsetMinute(new Date(), 50);
|
Date nowPlusFifty = DateUtil.offsetMinute(new Date(), 35);
|
||||||
|
|
||||||
// 如果当前时间+50分钟在营业时间范围内,则从该时间开始
|
// 如果当前时间+50分钟在营业时间范围内,则从该时间开始
|
||||||
if (nowPlusFifty.after(openTime) && nowPlusFifty.before(closeTime)) {
|
if (nowPlusFifty.after(openTime) && nowPlusFifty.before(closeTime)) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.suisung.mall.core.web.service.IBaseService;
|
|||||||
import com.suisung.mall.shop.product.pojo.vo.ProductVo;
|
import com.suisung.mall.shop.product.pojo.vo.ProductVo;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -58,6 +59,15 @@ public interface ShopStoreActivityBaseService extends IBaseService<ShopStoreActi
|
|||||||
List<Long> getActivityAllItemIds(Map activity_row);
|
List<Long> getActivityAllItemIds(Map activity_row);
|
||||||
|
|
||||||
boolean isActivityTimeValid(Map activity_row);
|
boolean isActivityTimeValid(Map activity_row);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证活动时间是否有效
|
||||||
|
*
|
||||||
|
* @param starTime 活动开始时间
|
||||||
|
* @param endTime 活动结束时间
|
||||||
|
* @return 时间是否有效
|
||||||
|
*/
|
||||||
|
boolean isActivityTimeValid(Date starTime, Date endTime);
|
||||||
|
|
||||||
Map listsMarketing();
|
Map listsMarketing();
|
||||||
|
|
||||||
@ -169,4 +179,6 @@ public interface ShopStoreActivityBaseService extends IBaseService<ShopStoreActi
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map getGiftbag(Integer activity_id);
|
Map getGiftbag(Integer activity_id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2055,6 +2055,7 @@ public class ShopStoreActivityBaseServiceImpl extends BaseServiceImpl<ShopStoreA
|
|||||||
* @param activityRow 活动数据
|
* @param activityRow 活动数据
|
||||||
* @return 时间是否有效
|
* @return 时间是否有效
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isActivityTimeValid(Map activityRow) {
|
public boolean isActivityTimeValid(Map activityRow) {
|
||||||
if (CollUtil.isEmpty(activityRow)) {
|
if (CollUtil.isEmpty(activityRow)) {
|
||||||
return false;
|
return false;
|
||||||
@ -2078,6 +2079,23 @@ public class ShopStoreActivityBaseServiceImpl extends BaseServiceImpl<ShopStoreA
|
|||||||
return !now.before(startTime) && !now.after(endTime);
|
return !now.before(startTime) && !now.after(endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证活动时间是否有效
|
||||||
|
*
|
||||||
|
* @param starTime 活动开始时间
|
||||||
|
* @param endTime 活动结束时间
|
||||||
|
* @return 时间是否有效
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isActivityTimeValid(Date starTime, Date endTime) {
|
||||||
|
if (starTime == null || endTime == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
return !now.before(starTime) && !now.after(endTime);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map listsMarketing() {
|
public Map listsMarketing() {
|
||||||
Integer page = Convert.toInt(getParameter("page"), 1);
|
Integer page = Convert.toInt(getParameter("page"), 1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user