Compare commits

...

2 Commits

Author SHA1 Message Date
Vinjor
a352d84ed6 Merge branch 'main' of http://122.51.230.86:3000/dianliang/oil-station 2024-09-22 18:53:19 +08:00
Vinjor
8c5c07aa0e 收银台 2024-09-22 18:53:15 +08:00
10 changed files with 178 additions and 39 deletions

View File

@ -2,6 +2,12 @@ package com.fuint.business.marketingActivity.cardCoupon.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; 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)表数据库访问层 * 用户优惠卷表2024(CardCouponUser)表数据库访问层
@ -9,7 +15,17 @@ import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser;
* @author makejava * @author makejava
* @since 2024-09-22 15:14:30 * @since 2024-09-22 15:14:30
*/ */
@Mapper
public interface CardCouponUserMapper extends BaseMapper<CardCouponUser> { 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);
} }

View File

@ -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 &lt;= #{nowDate} AND main.end_time &gt;= #{nowDate}
</select>
</mapper>

View File

@ -2,6 +2,11 @@ package com.fuint.business.marketingActivity.cardCoupon.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; 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)表服务接口 * 用户优惠卷表2024(CardCouponUser)表服务接口
@ -18,5 +23,15 @@ public interface CardCouponUserService extends IService<CardCouponUser> {
*/ */
boolean userCanGet(Integer couponId,Integer userId); 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);
} }

View File

@ -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.entity.CardCouponUser;
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService; import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService;
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -26,6 +27,8 @@ import java.util.List;
public class CardCouponUserServiceImpl extends ServiceImpl<CardCouponUserMapper, CardCouponUser> implements CardCouponUserService { public class CardCouponUserServiceImpl extends ServiceImpl<CardCouponUserMapper, CardCouponUser> implements CardCouponUserService {
@Autowired @Autowired
private CardCouponService cardCouponService; private CardCouponService cardCouponService;
@Autowired
private CardCouponUserMapper cardCouponUserMapper;
/** /**
* 判断用户是否还能领取该优惠卷 * 判断用户是否还能领取该优惠卷
* @param couponId 优惠卷id * @param couponId 优惠卷id
@ -56,5 +59,20 @@ public class CardCouponUserServiceImpl extends ServiceImpl<CardCouponUserMapper,
}).count(); }).count();
return count < cardCoupon.getDayGetLimit(); 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));
}
} }

View File

@ -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;
}

View File

@ -25,17 +25,30 @@ public class PayCenterController extends BaseController {
@Autowired @Autowired
private PayCenterService payCenterService; private PayCenterService payCenterService;
/** /**
* 收银台获取可用优惠券和可以参加的优惠活动 * 收银台获取可以参加的优惠活动
* @author vinjor-M * @author vinjor-M
* @date 12:01 2024/9/19 * @date 12:01 2024/9/19
* @param map 请求参数 * @param map 请求参数
* @param request * @param request
* @return com.fuint.framework.web.ResponseObject * @return com.fuint.framework.web.ResponseObject
**/ **/
@PostMapping("/getActivityAndCoupon") @PostMapping("/getActivity")
public ResponseObject getActivityAndCoupon(@RequestBody Map<String,String> map,HttpServletRequest request) throws Exception { public ResponseObject getActivity(@RequestBody Map<String,String> map,HttpServletRequest request) throws Exception {
logger.info("收银台获取可用优惠券和可以参加的优惠活动参数:{}", map); logger.info("收银台获取可以参加的优惠活动参数:{}", map);
return getSuccessResult("查询成功",payCenterService.getActivityAndCoupon(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));
} }
} }

View File

@ -10,11 +10,19 @@ import java.util.Map;
public interface PayCenterService { public interface PayCenterService {
/** /**
* 收银台获取可用优惠券和可以参加的优惠活动 * 收银台获取可以参加的优惠活动
* @author vinjor-M * @author vinjor-M
* @date 14:24 2024/9/19 * @date 14:24 2024/9/19
* @param map 请求参数 * @param map 请求参数
* @return java.lang.Object * @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);
} }

View File

@ -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.service.ActiveSubPriceService;
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO; import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO;
import com.fuint.business.marketingActivity.activePrice.vo.ActiveSubPriceRespVO; 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.entity.UserDiscount;
import com.fuint.business.userGroup.service.UserDiscountService; import com.fuint.business.userGroup.service.UserDiscountService;
import com.fuint.business.userManager.entity.UserBalance; import com.fuint.business.userManager.entity.UserBalance;
@ -49,6 +51,8 @@ public class PayCenterServiceImpl implements PayCenterService {
private ActiveSubPriceService activeSubPriceService; private ActiveSubPriceService activeSubPriceService;
@Autowired @Autowired
private UserDiscountService userDiscountService; private UserDiscountService userDiscountService;
@Autowired
private CardCouponUserService cardCouponUserService;
/** /**
* 收银台获取可用优惠券和可以参加的优惠活动 * 收银台获取可用优惠券和可以参加的优惠活动
* *
@ -58,12 +62,7 @@ public class PayCenterServiceImpl implements PayCenterService {
* @date 14:24 2024/9/19 * @date 14:24 2024/9/19
**/ **/
@Override @Override
public Object getActivityAndCoupon(Map<String, String> map) { public Object getActivity(Map<String, String> map) {
JSONObject rtnObj = new JSONObject();
//可参加的营销活动
List<ActivityVO> activityVOList = new ArrayList<>();
//可用的优惠券
List<CouponVO> couponVOList = new ArrayList<>();
/*1.先把所有用到的值取出来 */ /*1.先把所有用到的值取出来 */
//当前时间从点击结算的这一刻算 //当前时间从点击结算的这一刻算
Date nowDate = new Date(); Date nowDate = new Date();
@ -75,9 +74,7 @@ public class PayCenterServiceImpl implements PayCenterService {
UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(userId,storeId); UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(userId,storeId);
if(null==userBalance){ if(null==userBalance){
//非会员不能参加任何活动 //非会员不能参加任何活动
rtnObj.put("activity",activityVOList); return new ArrayList<>();
rtnObj.put("coupon",couponVOList);
return rtnObj;
} }
//会员等级 //会员等级
int gradeId = userBalance.getGradeId(); 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)); actList.addAll(this.getLijianAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId));
//2.3 查可参加的折扣营销会员折扣 //2.3 查可参加的折扣营销会员折扣
actList.addAll(this.getZhekouAct(nowDate,gradeId,storeId,oilAmount)); actList.addAll(this.getZhekouAct(nowDate,gradeId,storeId,oilAmount));
/*3.查询所有可用的优惠券 */ return actList;
List<CouponVO> couponList = this.getCouponList(userId,storeId,oilAmount,orderAmount,nowDate);
rtnObj.put("activity",actList);
rtnObj.put("coupon",couponList);
return rtnObj;
} }
/** /**
@ -281,17 +274,38 @@ public class PayCenterServiceImpl implements PayCenterService {
} }
/** /**
* 获取当前会员可以使用的优惠券 * 收银台获取可用优惠券
*
* @param map 请求参数
* @return java.lang.Object
* @author vinjor-M * @author vinjor-M
* @date 11:46 2024/9/22 * @date 14:24 2024/9/19
* @param userId 用户Id
* @param storeId 店铺id
* @param oilAmount 当前加油金额
* @param orderAmount 订单总金额
* @param nowDate 结算那一刻的时间
* @return java.util.List<com.fuint.pay.vo.CouponVO>
**/ **/
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<>(); List<CouponVO> rtnList = new ArrayList<>();
return rtnList; return rtnList;
} }

View File

@ -55,11 +55,11 @@
</div> </div>
</div> </div>
<div class="t-top"> <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 style="color: #F4F5F9">|</div>
<div class="three_box">商品:0.00</div> <div class="three_box">商品:{{ getGoodsNum }}</div>
<div style="color: #F4F5F9">|</div> <div style="color: #F4F5F9">|</div>
<div class="three_box">合计:0.00</div> <div class="three_box">合计:{{ orderAmount }}</div>
</div> </div>
<div class="d-top"> <div class="d-top">
<div class="d-b"> <div class="d-b">
@ -611,6 +611,8 @@ export default {
ruleIndex: 0, ruleIndex: 0,
tabIndex: 0, tabIndex: 0,
newMember: false, newMember: false,
//
orderAmount:0.0,
ScanCodePayment: false, ScanCodePayment: false,
cashPayment: false, cashPayment: false,
ruleForm: { ruleForm: {
@ -643,6 +645,11 @@ export default {
deep: true, deep: true,
handler(newValue, oldValue) { 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.refuelingAmount = false
// //
this.getActivityAndCoupon() this.getActivityAndCoupon()
@ -650,8 +657,13 @@ export default {
}, },
// //
getGoodsNum(newVal, oldVal) { getGoodsNum(newVal, oldVal) {
//
console.log('商品总金额发生变化', newVal); 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: { components: {
@ -687,7 +699,7 @@ export default {
this.goodsList.forEach(item => { this.goodsList.forEach(item => {
total += item.retailPrice * item.num 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")){ if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId") && this.chooseVipUser.hasOwnProperty("id")){
// //
let oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2) let oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2)
let orderAmount = this.oilGunClearing.amount+this.getGoodsNum
// //
let dataObj = { let dataObj = {
userId: this.chooseVipUser.id, userId: this.chooseVipUser.id,
oilId: this.oilGunClearing.oilNameId, oilId: this.oilGunClearing.oilNameId,
oilPrice:this.oilGunClearing.oilPrice, oilPrice:this.oilGunClearing.oilPrice,
oilAmount: this.oilGunClearing.amount, oilAmount: this.oilGunClearing.amount,
orderAmount: orderAmount, orderAmount: this.orderAmount,
oilLiter: oilLiter oilLiter: oilLiter
} }
getActivityAndCoupon(dataObj).then(res => { getActivityAndCoupon(dataObj).then(res => {

View File

@ -65,7 +65,7 @@ export default {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
// alert('submit!') // alert('submit!')
this.$emit('fatherMethod', this.ruleForm.amount) this.$emit('fatherMethod', this.ruleForm.amount.toFixed(2))
} else { } else {
console.log('error submit!!') console.log('error submit!!')
return false return false