收银台优惠活动查询
This commit is contained in:
parent
a352d84ed6
commit
c7be416570
@ -94,14 +94,32 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
Double orderAmount = Double.valueOf(map.get("orderAmount"));
|
||||
//油升数
|
||||
Double oilLiter = Double.valueOf(map.get("oilLiter"));
|
||||
//支付方式
|
||||
String payWay = map.get("payWay");
|
||||
/*2.查询所有可参加的营销活动 */
|
||||
List<ActivityVO> actList = new ArrayList<>();
|
||||
try {
|
||||
//2.1 查可参加的分时优惠和限时特价
|
||||
actList.addAll(this.getFenshiAndTejiaAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId,oilPrice));
|
||||
actList.addAll(this.getFenshiAndTejiaAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId,oilPrice,payWay));
|
||||
}catch (Exception e){
|
||||
//测试用,数据问题先忽略
|
||||
System.out.println("分时优惠和限时特价"+e);
|
||||
}
|
||||
try {
|
||||
//2.2 查可参加的立减营销
|
||||
actList.addAll(this.getLijianAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId));
|
||||
actList.addAll(this.getLijianAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId,payWay));
|
||||
}catch (Exception e){
|
||||
//测试用,数据问题先忽略
|
||||
System.out.println("立减营销"+e);
|
||||
}
|
||||
try {
|
||||
//2.3 查可参加的折扣营销(会员折扣)
|
||||
actList.addAll(this.getZhekouAct(nowDate,gradeId,storeId,oilAmount));
|
||||
actList.addAll(this.getZhekouAct(nowDate,gradeId,storeId,oilAmount,payWay));
|
||||
}catch (Exception e){
|
||||
//测试用,数据问题先忽略
|
||||
e.printStackTrace();
|
||||
System.out.println("折扣营销"+e);
|
||||
}
|
||||
return actList;
|
||||
}
|
||||
|
||||
@ -118,11 +136,12 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
* @param oilLiter 当前加油升数
|
||||
* @param oilId 当前加油选择的油号id
|
||||
* @param oilPrice 油单价
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
**/
|
||||
private List<ActivityVO> getFenshiAndTejiaAct(Date nowDate,Integer userId,Integer gradeId,Integer storeId,
|
||||
List<Integer> labelIdList,Double oilAmount,Double oilLiter,
|
||||
Integer oilId,Double oilPrice){
|
||||
Integer oilId,Double oilPrice,String payWay){
|
||||
/*1.先查满足条件的所有生效中的活动规则*/
|
||||
List<ActivePriceRuleRespVO> activePriceRuleList = activePriceRuleService.selectAllAct(storeId, nowDate);
|
||||
/*2.进行初步过滤,这里只过滤活动硬性的限制*/
|
||||
@ -136,7 +155,9 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
//适用当前时间段的
|
||||
.filter(rule -> checkUtil.checkTime(rule.getTimeSlots(),rule.getDayStartTime(),rule.getDayEndTime(),nowDate))
|
||||
//适用当前油号的
|
||||
.filter(rule-> checkUtil.checkOil(rule.getOilList(),oilId)).collect(Collectors.toList());
|
||||
.filter(rule-> checkUtil.checkOil(rule.getOilList(),oilId))
|
||||
//适用当前支付方式的
|
||||
.filter(rule-> rule.getPaymentType().contains(payWay)).collect(Collectors.toList());
|
||||
if(filteredList.isEmpty()){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@ -155,6 +176,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if(!filteredList.isEmpty()){
|
||||
for(ActivePriceRuleRespVO rule:filteredList){
|
||||
ActivityVO activityVO = new ActivityVO();
|
||||
activityVO.setId(rule.getActiveType()+"_"+rule.getActiveId()+"_"+rule.getId());
|
||||
activityVO.setActId(rule.getActiveId());
|
||||
activityVO.setRuleId(rule.getId());
|
||||
activityVO.setType(rule.getActiveType());
|
||||
@ -162,6 +184,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
activityVO.setRuleName(rule.getRuleName());
|
||||
activityVO.setPayTypes(rule.getPaymentType());
|
||||
activityVO.setDisAmount(checkUtil.computeDisAmount(rule,oilId,oilPrice,oilAmount,oilLiter));
|
||||
rtnList.add(activityVO);
|
||||
}
|
||||
}
|
||||
return rtnList;
|
||||
@ -179,11 +202,12 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param oilLiter 当前加油升数
|
||||
* @param oilId 当前加油选择的油号id
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
**/
|
||||
private List<ActivityVO> getLijianAct(Date nowDate,Integer userId,Integer gradeId,Integer storeId,
|
||||
List<Integer> labelIdList,Double oilAmount,Double oilLiter,
|
||||
Integer oilId){
|
||||
Integer oilId,String payWay){
|
||||
/*1.先查满足条件的所有生效中的活动规则*/
|
||||
List<ActiveSubPriceRespVO> activeSubPriceList = activeSubPriceService.selectAllAct(storeId,nowDate);
|
||||
/*2.进行初步过滤,这里只过滤活动硬性的限制*/
|
||||
@ -195,7 +219,9 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
//适用当前时间段的
|
||||
.filter(rule -> checkUtil.checkTime(rule.getTimeSlots(),checkUtil.getTimeFromDate(rule.getTimeApplyStart()),checkUtil.getTimeFromDate(rule.getTimeApplyEnd()),nowDate))
|
||||
//适用当前油号的
|
||||
.filter(rule-> checkUtil.checkOilLijian(rule.getApplyOilType(),rule.getApplyOil(),oilId)).collect(Collectors.toList());
|
||||
.filter(rule-> checkUtil.checkOilLijian(rule.getApplyOilType(),rule.getApplyOil(),oilId))
|
||||
//适用当前支付方式的
|
||||
.filter(rule-> rule.getPaymentType().contains(payWay)).collect(Collectors.toList());
|
||||
/*3.再次过滤,这里过滤掉用户已经超出参加次数限制的*/
|
||||
//符合条件的活动规则,查询当前会员已经参与的记录,此处查立减营销的参与记录
|
||||
List<String> actTypeList = Arrays.asList("3".split(StrUtil.COMMA));
|
||||
@ -213,11 +239,13 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if(!filteredList.isEmpty()){
|
||||
for(ActiveSubPriceRespVO rule:filteredList){
|
||||
ActivityVO activityVO = new ActivityVO();
|
||||
activityVO.setId("3_"+rule.getId().toString());
|
||||
activityVO.setActId(rule.getId());
|
||||
activityVO.setType("3");
|
||||
activityVO.setActName(rule.getActiveName());
|
||||
activityVO.setPayTypes(rule.getPaymentType());
|
||||
activityVO.setDisAmount(checkUtil.computeDisAmountLijian(rule,oilAmount,oilLiter));
|
||||
rtnList.add(activityVO);
|
||||
}
|
||||
}
|
||||
return rtnList;
|
||||
@ -231,9 +259,10 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
**/
|
||||
private List<ActivityVO> getZhekouAct(Date nowDate,Integer gradeId,Integer storeId,Double oilAmount){
|
||||
private List<ActivityVO> getZhekouAct(Date nowDate,Integer gradeId,Integer storeId,Double oilAmount,String payWay){
|
||||
/*1.先查满足条件的所有生效中的活动规则*/
|
||||
List<UserDiscount> userDiscountList = userDiscountService.selectAllAct(storeId,nowDate);
|
||||
/*2.进行初步过滤,这里只过滤活动硬性的限制*/
|
||||
@ -245,7 +274,9 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
//适用当前时间段的
|
||||
.filter(rule -> checkUtil.checkTime(rule.getSuitDate(),checkUtil.getTimeFromDate(rule.getSuitTimeSlotFront()),checkUtil.getTimeFromDate(rule.getSuitDateAfter()),nowDate))
|
||||
//是否满足最低消费金额
|
||||
.filter(rule-> rule.getConsumeAmount() <=oilAmount).collect(Collectors.toList());
|
||||
.filter(rule-> rule.getConsumeAmount() <=oilAmount)
|
||||
//适用当前支付方式的
|
||||
.filter(rule-> rule.getUsePaymentWay().contains(payWay)).collect(Collectors.toList());
|
||||
/*3.得到用户最终可以参加的活动,计算优惠金额并转换成统一的对象*/
|
||||
List<ActivityVO> rtnList = new ArrayList<>();
|
||||
if(!filteredList.isEmpty()){
|
||||
@ -257,6 +288,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
discount = filteredList.stream().sorted(Comparator.comparingDouble(UserDiscount::getDiscount)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
ActivityVO activityVO = new ActivityVO();
|
||||
activityVO.setId("4_"+discount.getId().toString());
|
||||
activityVO.setActId(discount.getId());
|
||||
activityVO.setType("4");
|
||||
activityVO.setActName("折扣营销");
|
||||
@ -303,9 +335,6 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
/*1.先查满足条件的所有生效中的优惠券*/
|
||||
List<CardCouponVO> couponVOList = cardCouponUserService.selectAllList(storeId, userId, nowDate);
|
||||
/*2.进行初步过滤,这里只过滤优惠券硬性的限制*/
|
||||
List<CardCouponVO> filteredList = couponVOList.stream()
|
||||
//
|
||||
.filter(rule->rule.getGradeId().equals(gradeId))
|
||||
List<CouponVO> rtnList = new ArrayList<>();
|
||||
return rtnList;
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ public class CheckUtil {
|
||||
* @return boolean
|
||||
**/
|
||||
private static boolean checkDayTime(Date nowDate,String dayStartTime,String dayEndTime){
|
||||
String dayStr = DateUtil.date(nowDate).toString();
|
||||
String dayStr = DateUtil.formatDate(nowDate);
|
||||
//时间范围区间
|
||||
Date startTime = DateUtil.parse(dayStr+" "+(StringUtils.isNotEmpty(dayStartTime)?(dayStartTime+":00"):"00:00:00"));
|
||||
Date endTime = DateUtil.parse(dayStr+" "+(StringUtils.isNotEmpty(dayEndTime)?(dayEndTime+":59"):"23:59:59"));
|
||||
|
@ -11,6 +11,8 @@ import java.io.Serializable;
|
||||
**/
|
||||
@Data
|
||||
public class ActivityVO implements Serializable {
|
||||
/** 唯一Id,活动Id和规则Id下划线拼接 */
|
||||
private String id;
|
||||
/** 活动id */
|
||||
private Integer actId;
|
||||
/** 活动规则id */
|
||||
|
@ -29,9 +29,16 @@ export function getCoupons(param) {
|
||||
params:param
|
||||
})
|
||||
}
|
||||
export function getActivityAndCoupon(data) {
|
||||
export function getActivityList(data) {
|
||||
return request({
|
||||
url: '/pay/paycenter/getActivityAndCoupon',
|
||||
url: '/pay/paycenter/getActivity',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function getCouponList(data) {
|
||||
return request({
|
||||
url: '/pay/paycenter/getCoupon',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
@ -69,17 +69,15 @@
|
||||
</div>
|
||||
<!-- 下拉列表插入-->
|
||||
<div v-if="checkAll == true">
|
||||
<div class="x-d-b">
|
||||
<el-checkbox v-model="checkAll1">优惠1</el-checkbox>
|
||||
<div class="or_num">-¥0.00</div>
|
||||
<div v-if="activityList.length>0">
|
||||
<el-radio-group style="width: 100%" v-model="chooseAct">
|
||||
<div class="x-d-b" v-for="(item,index) in activityList">
|
||||
<el-radio :label="item.id">{{null==item.ruleName?item.actName:item.ruleName}}<div class="or_num">-¥{{item.disAmount}}</div></el-radio>
|
||||
</div>
|
||||
<div class="x-d-b">
|
||||
<el-checkbox v-model="checkAll2">优惠2</el-checkbox>
|
||||
<div class="or_num">-¥0.00</div>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<div class="x-d-b">
|
||||
<el-checkbox v-model="checkAll3">优惠3</el-checkbox>
|
||||
<div class="or_num">-¥0.00</div>
|
||||
<div v-if="activityList.length==0">
|
||||
暂无可用优惠活动
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-b">
|
||||
@ -89,6 +87,7 @@
|
||||
</div>
|
||||
<!-- 下拉列表插入-->
|
||||
<div v-if="checkAll == true">
|
||||
|
||||
<div class="x-d-b">
|
||||
<el-checkbox v-model="checkAll1">优惠券1</el-checkbox>
|
||||
<div class="or_num">-¥0.00</div>
|
||||
@ -120,8 +119,8 @@
|
||||
</div>
|
||||
<div class="er-box"></div>
|
||||
<div class="wrap-box">
|
||||
<div class="f-box" v-for="(item,index) in payList" :class="{'f-acvite' : index == ruleIndex }"
|
||||
@click="setindex(index)" :key="index"
|
||||
<div class="f-box" v-for="(item,index) in payList" :class="{'f-acvite' : item.dictValue == payWay }"
|
||||
@click="setindex(item.dictValue)" :key="item.dictValue"
|
||||
>{{ item.dictLabel }}
|
||||
</div>
|
||||
</div>
|
||||
@ -520,7 +519,7 @@ import pickUp from './newHomeComponents/pickUpTheOrder.vue'
|
||||
import accountPending from './newHomeComponents/accountPending.vue'
|
||||
import memberRecharge from './newHomeComponents/memberRecharge.vue'
|
||||
import refuelingAmount from './newHomeComponents/refuelingAmount.vue'
|
||||
import { cashRegisterList, cashRegisterGoodsList,getActivityAndCoupon } from '@/api/newHome/newHome.js'
|
||||
import { cashRegisterList, cashRegisterGoodsList,getActivityList,getCouponList } from '@/api/newHome/newHome.js'
|
||||
import {QRCodeByStoreId} from "@/api/staff/qrcode";
|
||||
import {userListByPhone} from "@/api/cashier/user";
|
||||
|
||||
@ -536,7 +535,16 @@ export default {
|
||||
authCode:null,
|
||||
seekZero:0.00
|
||||
},
|
||||
|
||||
//可参加的活动
|
||||
activityList:[],
|
||||
//选中的活动 actId_ruleId
|
||||
chooseAct:"",
|
||||
//支付方式--默认支付宝
|
||||
payWay: "ALIPAY",
|
||||
//订单总金额
|
||||
orderAmount:0.0,
|
||||
//加油升数
|
||||
oilLiter:0,
|
||||
openConfirm:false,
|
||||
isPay:false,
|
||||
loading:false,
|
||||
@ -608,11 +616,8 @@ export default {
|
||||
//油枪列表数据
|
||||
dataList: {},
|
||||
userInfo: false,//判断登录状态
|
||||
ruleIndex: 0,
|
||||
tabIndex: 0,
|
||||
newMember: false,
|
||||
//订单总金额
|
||||
orderAmount:0.0,
|
||||
ScanCodePayment: false,
|
||||
cashPayment: false,
|
||||
ruleForm: {
|
||||
@ -644,15 +649,15 @@ export default {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler(newValue, oldValue) {
|
||||
console.log('油枪发生拜年话', newValue);
|
||||
console.log('油枪发生变化', newValue);
|
||||
if(newValue && newValue.hasOwnProperty("oilNameId")){
|
||||
this.orderAmount = (Number(newValue.amount)+Number(this.getGoodsNum)).toFixed(2)
|
||||
}else{
|
||||
this.orderAmount = this.getGoodsNum
|
||||
}
|
||||
this.refuelingAmount = false
|
||||
//查询可用优惠券
|
||||
this.getActivityAndCoupon()
|
||||
//查询可用优惠活动
|
||||
this.getActivity()
|
||||
}
|
||||
},
|
||||
//监听商品总金额发生变化
|
||||
@ -684,9 +689,9 @@ export default {
|
||||
getGoodsItem() {
|
||||
if (this.oilGunClearing.amount && this.oilGunClearing.amount !== undefined) {
|
||||
// 保留两位小数
|
||||
let l = this.oilGunClearing.amount / this.oilGunClearing.oilPrice
|
||||
this.oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2)
|
||||
// 8号枪(21.03L/191.7936元)
|
||||
return `${this.oilGunClearing.gunName}(${l.toFixed(2)}L/${this.oilGunClearing.amount}元)`
|
||||
return `${this.oilGunClearing.gunName}(${this.oilLiter}L/${this.oilGunClearing.amount}元)`
|
||||
|
||||
} else {
|
||||
return ''
|
||||
@ -745,12 +750,40 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* @description 油枪金额和商品金额发生变化,请求后端查询可用优惠活动和优惠券
|
||||
* @description 油枪金额和商品金额发生变化,请求后端查询可用优惠活动
|
||||
* 传入后台的参数,会员的用户id、加油油号、加油订单金额(不包括商品金额)、加油订单总金额(包括商品金额)、加油总升数
|
||||
* @author vinjor-m
|
||||
* @date 2024年9月19日
|
||||
*/
|
||||
getActivityAndCoupon(){
|
||||
getActivity(){
|
||||
//组装请求参数
|
||||
if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId") && this.chooseVipUser.hasOwnProperty("id")){
|
||||
//油枪已结算,且已选择会员
|
||||
let dataObj = {
|
||||
userId: this.chooseVipUser.id,
|
||||
oilId: this.oilGunClearing.oilNameId,
|
||||
oilPrice:this.oilGunClearing.oilPrice,
|
||||
oilAmount: this.oilGunClearing.amount,
|
||||
orderAmount: this.orderAmount,
|
||||
payWay: this.payWay,
|
||||
oilLiter: this.oilLiter
|
||||
}
|
||||
getActivityList(dataObj).then(res => {
|
||||
console.log("返回的可参加活动",res)
|
||||
this.activityList = res.data
|
||||
})
|
||||
}else {
|
||||
//可用活动清空
|
||||
this.activityList =[]
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description 油枪金额和商品金额发生变化,请求后端查询可用优惠券
|
||||
* 传入后台的参数,会员的用户id、加油油号、加油订单金额(不包括商品金额)、加油订单总金额(包括商品金额)、加油总升数
|
||||
* @author vinjor-m
|
||||
* @date 2024年9月19日
|
||||
*/
|
||||
getCoupon(){
|
||||
//组装请求参数
|
||||
if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId") && this.chooseVipUser.hasOwnProperty("id")){
|
||||
// 保留两位小数
|
||||
@ -764,7 +797,7 @@ export default {
|
||||
orderAmount: this.orderAmount,
|
||||
oilLiter: oilLiter
|
||||
}
|
||||
getActivityAndCoupon(dataObj).then(res => {
|
||||
getCouponList(dataObj).then(res => {
|
||||
console.log("返回结果",res)
|
||||
})
|
||||
}
|
||||
@ -1012,8 +1045,12 @@ export default {
|
||||
}
|
||||
|
||||
},
|
||||
setindex(index) {
|
||||
this.ruleIndex = index
|
||||
/**
|
||||
* 设置选中的支付方式
|
||||
* @param value
|
||||
*/
|
||||
setindex(value) {
|
||||
this.payWay = value
|
||||
},
|
||||
setRefuelingAmount(item) {
|
||||
this.refuelingAmount = true
|
||||
@ -1784,4 +1821,10 @@ input {
|
||||
width: 350px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
.el-radio-group label{
|
||||
width: 100%;
|
||||
}
|
||||
.el-radio-group .or_num{
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user