diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java index 3bd24967d..ac9616b1a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java @@ -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 { - + /** + * 查会员在某店铺当前时间可用的所有优惠券 + * @author vinjor-M + * @date 17:41 2024/9/22 + * @param storeId 店铺Id + * @param userId 用户Id + * @param nowDate 结算时间 + * @return java.util.List + **/ + List selectAllList(@Param("storeId") Integer storeId,@Param("userId") Integer userId,@Param("nowDate") String nowDate); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml new file mode 100644 index 000000000..76a791502 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java index db3bbbfba..b6a668174 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java @@ -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 { */ 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 + **/ + List selectAllList(Integer storeId, Integer userId, Date nowDate); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java index eb6bf9a9e..ab88e7bcc 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java @@ -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 implements CardCouponUserService { @Autowired private CardCouponService cardCouponService; + @Autowired + private CardCouponUserMapper cardCouponUserMapper; /** * 判断用户是否还能领取该优惠卷 * @param couponId 优惠卷id @@ -56,5 +59,20 @@ public class CardCouponUserServiceImpl extends ServiceImpl + * @author vinjor-M + * @date 17:39 2024/9/22 + **/ + @Override + public List selectAllList(Integer storeId, Integer userId, Date nowDate) { + return cardCouponUserMapper.selectAllList(storeId,userId, DateUtil.formatDate(nowDate)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/vo/CardCouponVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/vo/CardCouponVO.java new file mode 100644 index 000000000..9ba7ea2ef --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/vo/CardCouponVO.java @@ -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; +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/controller/PayCenterController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/controller/PayCenterController.java index bdf88210b..0cc05afb0 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/controller/PayCenterController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/controller/PayCenterController.java @@ -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 map,HttpServletRequest request) throws Exception { - logger.info("收银台获取可用优惠券和可以参加的优惠活动参数:{}", map); - return getSuccessResult("查询成功",payCenterService.getActivityAndCoupon(map)); + @PostMapping("/getActivity") + public ResponseObject getActivity(@RequestBody Map 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 map,HttpServletRequest request) throws Exception { + logger.info("收银台获取可用优惠券参数:{}", map); + return getSuccessResult("查询成功",payCenterService.getCoupon(map)); } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/PayCenterService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/PayCenterService.java index 7cc892811..dba3d8ab9 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/PayCenterService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/PayCenterService.java @@ -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 map); + Object getActivity(Map map); + /** + * 收银台获取可以使用的优惠券 + * @author vinjor-M + * @date 14:24 2024/9/19 + * @param map 请求参数 + * @return java.lang.Object + **/ + Object getCoupon(Map map); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java index ffa6644be..359a7f41f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java @@ -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 map) { - JSONObject rtnObj = new JSONObject(); - //可参加的营销活动 - List activityVOList = new ArrayList<>(); - //可用的优惠券 - List couponVOList = new ArrayList<>(); + public Object getActivity(Map 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 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 + * @date 14:24 2024/9/19 **/ - public List getCouponList(Integer userId,Integer storeId,Double oilAmount,Double orderAmount,Date nowDate){ + @Override + public Object getCoupon(Map 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 couponVOList = cardCouponUserService.selectAllList(storeId, userId, nowDate); + /*2.进行初步过滤,这里只过滤优惠券硬性的限制*/ + List filteredList = couponVOList.stream() + // + .filter(rule->rule.getGradeId().equals(gradeId)) List rtnList = new ArrayList<>(); return rtnList; } diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue b/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue index b51786e38..3d739a365 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue @@ -55,11 +55,11 @@
-
油品:¥0.00
+
油品:¥{{ oilGunClearing.amount || 0.00 }}
|
-
商品:¥0.00
+
商品:¥{{ getGoodsNum }}
|
-
合计:¥0.00
+
合计:¥{{ orderAmount }}
@@ -545,6 +545,8 @@ export default { ruleIndex: 0, tabIndex: 0, newMember: false, + //订单总金额 + orderAmount:0.0, ScanCodePayment: false, cashPayment: false, ruleForm: { @@ -577,6 +579,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() @@ -584,8 +591,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: { @@ -622,7 +634,7 @@ export default { this.goodsList.forEach(item => { total += item.retailPrice * item.num }) - return total + return total.toFixed(2) }, //总数量 @@ -647,14 +659,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 => { diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/newHomeComponents/refuelingAmount.vue b/fuintCashierWeb/src/views/cashier/NewComponents/newHomeComponents/refuelingAmount.vue index 8238d9891..6242010e5 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/newHomeComponents/refuelingAmount.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/newHomeComponents/refuelingAmount.vue @@ -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