Compare commits
2 Commits
0417b46d55
...
a352d84ed6
Author | SHA1 | Date | |
---|---|---|---|
|
a352d84ed6 | ||
|
8c5c07aa0e |
@ -2,6 +2,12 @@ package com.fuint.business.marketingActivity.cardCoupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户优惠卷表2024(CardCouponUser)表数据库访问层
|
||||
@ -9,7 +15,17 @@ import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser;
|
||||
* @author makejava
|
||||
* @since 2024-09-22 15:14:30
|
||||
*/
|
||||
@Mapper
|
||||
public interface CardCouponUserMapper extends BaseMapper<CardCouponUser> {
|
||||
|
||||
/**
|
||||
* 查会员在某店铺当前时间可用的所有优惠券
|
||||
* @author vinjor-M
|
||||
* @date 17:41 2024/9/22
|
||||
* @param storeId 店铺Id
|
||||
* @param userId 用户Id
|
||||
* @param nowDate 结算时间
|
||||
* @return java.util.List<com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO>
|
||||
**/
|
||||
List<CardCouponVO> selectAllList(@Param("storeId") Integer storeId,@Param("userId") Integer userId,@Param("nowDate") String nowDate);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.business.marketingActivity.cardCoupon.mapper.CardCouponUserMapper">
|
||||
<select id="selectAllList" resultType="com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO">
|
||||
SELECT
|
||||
cc.*,
|
||||
main.id AS dataId,
|
||||
main.mt_user_id AS mtUserId
|
||||
FROM
|
||||
card_coupon_user main
|
||||
LEFT JOIN card_coupon cc ON main.card_coupon_id = cc.id
|
||||
WHERE
|
||||
main.store_id = #{storeId}
|
||||
AND main.mt_user_id = #{userId}
|
||||
AND main.`status` = '0'
|
||||
AND cc.`type` != '2'
|
||||
AND main.start_time <= #{nowDate} AND main.end_time >= #{nowDate}
|
||||
</select>
|
||||
</mapper>
|
@ -2,6 +2,11 @@ package com.fuint.business.marketingActivity.cardCoupon.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户优惠卷表2024(CardCouponUser)表服务接口
|
||||
@ -18,5 +23,15 @@ public interface CardCouponUserService extends IService<CardCouponUser> {
|
||||
*/
|
||||
boolean userCanGet(Integer couponId,Integer userId);
|
||||
|
||||
/**
|
||||
* 查会员在某店铺当前时间可用的所有优惠券
|
||||
* @author vinjor-M
|
||||
* @date 17:39 2024/9/22
|
||||
* @param storeId 店铺Id
|
||||
* @param userId 用户Id
|
||||
* @param nowDate 结算时间
|
||||
* @return java.util.List<com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO>
|
||||
**/
|
||||
List<CardCouponVO> selectAllList(Integer storeId, Integer userId, Date nowDate);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.fuint.business.marketingActivity.cardCoupon.mapper.CardCouponUserMapp
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -26,6 +27,8 @@ import java.util.List;
|
||||
public class CardCouponUserServiceImpl extends ServiceImpl<CardCouponUserMapper, CardCouponUser> implements CardCouponUserService {
|
||||
@Autowired
|
||||
private CardCouponService cardCouponService;
|
||||
@Autowired
|
||||
private CardCouponUserMapper cardCouponUserMapper;
|
||||
/**
|
||||
* 判断用户是否还能领取该优惠卷
|
||||
* @param couponId 优惠卷id
|
||||
@ -56,5 +59,20 @@ public class CardCouponUserServiceImpl extends ServiceImpl<CardCouponUserMapper,
|
||||
}).count();
|
||||
return count < cardCoupon.getDayGetLimit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查会员在某店铺当前时间可用的所有优惠券
|
||||
*
|
||||
* @param storeId 店铺Id
|
||||
* @param userId 用户Id
|
||||
* @param nowDate 结算时间
|
||||
* @return java.util.List<com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO>
|
||||
* @author vinjor-M
|
||||
* @date 17:39 2024/9/22
|
||||
**/
|
||||
@Override
|
||||
public List<CardCouponVO> selectAllList(Integer storeId, Integer userId, Date nowDate) {
|
||||
return cardCouponUserMapper.selectAllList(storeId,userId, DateUtil.formatDate(nowDate));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.fuint.business.marketingActivity.cardCoupon.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 优惠券扩展实体,收银台使用
|
||||
* @author vinjor-M
|
||||
* @date 17:35 2024/9/22
|
||||
**/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class CardCouponVO extends CardCoupon {
|
||||
/**
|
||||
* card_coupon_user表主键,也就是优惠券和会员绑定关系的主键
|
||||
*/
|
||||
private Integer dataId;
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private Integer mtUserId;
|
||||
}
|
@ -25,17 +25,30 @@ public class PayCenterController extends BaseController {
|
||||
@Autowired
|
||||
private PayCenterService payCenterService;
|
||||
/**
|
||||
* 收银台获取可用优惠券和可以参加的优惠活动
|
||||
* 收银台获取可以参加的优惠活动
|
||||
* @author vinjor-M
|
||||
* @date 12:01 2024/9/19
|
||||
* @param map 请求参数
|
||||
* @param request
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
**/
|
||||
@PostMapping("/getActivityAndCoupon")
|
||||
public ResponseObject getActivityAndCoupon(@RequestBody Map<String,String> map,HttpServletRequest request) throws Exception {
|
||||
logger.info("收银台获取可用优惠券和可以参加的优惠活动参数:{}", map);
|
||||
return getSuccessResult("查询成功",payCenterService.getActivityAndCoupon(map));
|
||||
@PostMapping("/getActivity")
|
||||
public ResponseObject getActivity(@RequestBody Map<String,String> map,HttpServletRequest request) throws Exception {
|
||||
logger.info("收银台获取可以参加的优惠活动参数:{}", map);
|
||||
return getSuccessResult("查询成功",payCenterService.getActivity(map));
|
||||
}
|
||||
/**
|
||||
* 收银台获取可用优惠券
|
||||
* @author vinjor-M
|
||||
* @date 12:01 2024/9/19
|
||||
* @param map 请求参数
|
||||
* @param request
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
**/
|
||||
@PostMapping("/getCoupon")
|
||||
public ResponseObject getCoupon(@RequestBody Map<String,String> map,HttpServletRequest request) throws Exception {
|
||||
logger.info("收银台获取可用优惠券参数:{}", map);
|
||||
return getSuccessResult("查询成功",payCenterService.getCoupon(map));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,11 +10,19 @@ import java.util.Map;
|
||||
public interface PayCenterService {
|
||||
|
||||
/**
|
||||
* 收银台获取可用优惠券和可以参加的优惠活动
|
||||
* 收银台获取可以参加的优惠活动
|
||||
* @author vinjor-M
|
||||
* @date 14:24 2024/9/19
|
||||
* @param map 请求参数
|
||||
* @return java.lang.Object
|
||||
**/
|
||||
Object getActivityAndCoupon(Map<String,String> map);
|
||||
Object getActivity(Map<String,String> map);
|
||||
/**
|
||||
* 收银台获取可以使用的优惠券
|
||||
* @author vinjor-M
|
||||
* @date 14:24 2024/9/19
|
||||
* @param map 请求参数
|
||||
* @return java.lang.Object
|
||||
**/
|
||||
Object getCoupon(Map<String,String> map);
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import com.fuint.business.marketingActivity.activePrice.service.ActivePriceServi
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActiveSubPriceService;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActiveSubPriceRespVO;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO;
|
||||
import com.fuint.business.userGroup.entity.UserDiscount;
|
||||
import com.fuint.business.userGroup.service.UserDiscountService;
|
||||
import com.fuint.business.userManager.entity.UserBalance;
|
||||
@ -49,6 +51,8 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
private ActiveSubPriceService activeSubPriceService;
|
||||
@Autowired
|
||||
private UserDiscountService userDiscountService;
|
||||
@Autowired
|
||||
private CardCouponUserService cardCouponUserService;
|
||||
/**
|
||||
* 收银台获取可用优惠券和可以参加的优惠活动
|
||||
*
|
||||
@ -58,12 +62,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
* @date 14:24 2024/9/19
|
||||
**/
|
||||
@Override
|
||||
public Object getActivityAndCoupon(Map<String, String> map) {
|
||||
JSONObject rtnObj = new JSONObject();
|
||||
//可参加的营销活动
|
||||
List<ActivityVO> activityVOList = new ArrayList<>();
|
||||
//可用的优惠券
|
||||
List<CouponVO> couponVOList = new ArrayList<>();
|
||||
public Object getActivity(Map<String, String> map) {
|
||||
/*1.先把所有用到的值取出来 */
|
||||
//当前时间,从点击结算的这一刻算
|
||||
Date nowDate = new Date();
|
||||
@ -75,9 +74,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(userId,storeId);
|
||||
if(null==userBalance){
|
||||
//非会员,不能参加任何活动
|
||||
rtnObj.put("activity",activityVOList);
|
||||
rtnObj.put("coupon",couponVOList);
|
||||
return rtnObj;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//会员等级
|
||||
int gradeId = userBalance.getGradeId();
|
||||
@ -105,11 +102,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
actList.addAll(this.getLijianAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId));
|
||||
//2.3 查可参加的折扣营销(会员折扣)
|
||||
actList.addAll(this.getZhekouAct(nowDate,gradeId,storeId,oilAmount));
|
||||
/*3.查询所有可用的优惠券 */
|
||||
List<CouponVO> couponList = this.getCouponList(userId,storeId,oilAmount,orderAmount,nowDate);
|
||||
rtnObj.put("activity",actList);
|
||||
rtnObj.put("coupon",couponList);
|
||||
return rtnObj;
|
||||
return actList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -281,17 +274,38 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前会员可以使用的优惠券
|
||||
* 收银台获取可用优惠券
|
||||
*
|
||||
* @param map 请求参数
|
||||
* @return java.lang.Object
|
||||
* @author vinjor-M
|
||||
* @date 11:46 2024/9/22
|
||||
* @param userId 用户Id
|
||||
* @param storeId 店铺id
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param orderAmount 订单总金额
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @return java.util.List<com.fuint.pay.vo.CouponVO>
|
||||
* @date 14:24 2024/9/19
|
||||
**/
|
||||
public List<CouponVO> getCouponList(Integer userId,Integer storeId,Double oilAmount,Double orderAmount,Date nowDate){
|
||||
@Override
|
||||
public Object getCoupon(Map<String, String> map){
|
||||
/*1.先把所有用到的值取出来 */
|
||||
//当前时间,从点击结算的这一刻算
|
||||
Date nowDate = new Date();
|
||||
//当前店铺id
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
Integer storeId = nowAccountInfo.getStoreId();
|
||||
int userId = Integer.parseInt(map.get("userId"));
|
||||
//油号id
|
||||
Integer oilId = Integer.valueOf(map.get("oilId"));
|
||||
//油单价
|
||||
Double oilPrice = Double.valueOf(map.get("oilPrice"));
|
||||
//加油金额(不含商品金额)
|
||||
Double oilAmount = Double.valueOf(map.get("oilAmount"));
|
||||
//订单总额(含商品金额)
|
||||
Double orderAmount = Double.valueOf(map.get("orderAmount"));
|
||||
//油升数
|
||||
Double oilLiter = Double.valueOf(map.get("oilLiter"));
|
||||
/*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;
|
||||
}
|
||||
|
@ -55,11 +55,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="t-top">
|
||||
<div class="three_box">油品:¥0.00</div>
|
||||
<div class="three_box">油品:¥{{ oilGunClearing.amount || 0.00 }}</div>
|
||||
<div style="color: #F4F5F9">|</div>
|
||||
<div class="three_box">商品:¥0.00</div>
|
||||
<div class="three_box">商品:¥{{ getGoodsNum }}</div>
|
||||
<div style="color: #F4F5F9">|</div>
|
||||
<div class="three_box">合计:¥0.00</div>
|
||||
<div class="three_box">合计:¥{{ orderAmount }}</div>
|
||||
</div>
|
||||
<div class="d-top">
|
||||
<div class="d-b">
|
||||
@ -611,6 +611,8 @@ export default {
|
||||
ruleIndex: 0,
|
||||
tabIndex: 0,
|
||||
newMember: false,
|
||||
//订单总金额
|
||||
orderAmount:0.0,
|
||||
ScanCodePayment: false,
|
||||
cashPayment: false,
|
||||
ruleForm: {
|
||||
@ -643,6 +645,11 @@ export default {
|
||||
deep: true,
|
||||
handler(newValue, oldValue) {
|
||||
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()
|
||||
@ -650,8 +657,13 @@ export default {
|
||||
},
|
||||
//监听商品总金额发生变化
|
||||
getGoodsNum(newVal, oldVal) {
|
||||
// 商品总金额发生变化,重查优惠券
|
||||
console.log('商品总金额发生变化', newVal);
|
||||
// 商品总金额发生变化,重查优惠券
|
||||
if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId")){
|
||||
this.orderAmount = (Number(newVal)+Number(this.oilGunClearing.amount)).toFixed(2)
|
||||
}else {
|
||||
this.orderAmount = newVal
|
||||
}
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@ -687,7 +699,7 @@ export default {
|
||||
this.goodsList.forEach(item => {
|
||||
total += item.retailPrice * item.num
|
||||
})
|
||||
return total
|
||||
return total.toFixed(2)
|
||||
},
|
||||
|
||||
//总数量
|
||||
@ -743,14 +755,13 @@ export default {
|
||||
if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId") && this.chooseVipUser.hasOwnProperty("id")){
|
||||
// 保留两位小数
|
||||
let oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2)
|
||||
let orderAmount = this.oilGunClearing.amount+this.getGoodsNum
|
||||
//油枪已结算,且已选择会员
|
||||
let dataObj = {
|
||||
userId: this.chooseVipUser.id,
|
||||
oilId: this.oilGunClearing.oilNameId,
|
||||
oilPrice:this.oilGunClearing.oilPrice,
|
||||
oilAmount: this.oilGunClearing.amount,
|
||||
orderAmount: orderAmount,
|
||||
orderAmount: this.orderAmount,
|
||||
oilLiter: oilLiter
|
||||
}
|
||||
getActivityAndCoupon(dataObj).then(res => {
|
||||
|
@ -65,7 +65,7 @@ export default {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
// alert('submit!')
|
||||
this.$emit('fatherMethod', this.ruleForm.amount)
|
||||
this.$emit('fatherMethod', this.ruleForm.amount.toFixed(2))
|
||||
} else {
|
||||
console.log('error submit!!')
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user