更新10.11

This commit is contained in:
许允枞 2024-10-11 16:13:42 +08:00
parent 622df03a6e
commit fbd4e14f1b
4 changed files with 68 additions and 17 deletions

View File

@ -380,8 +380,8 @@ public class ActiveRecommendRecordsServiceImpl extends ServiceImpl<ActiveRecomme
}
//判断优惠券剩余数量是否足够 如果不够剩多少领多少
if ((cardCoupon.getTfTotal() - cardCoupon.getGiftCardTotal()) < giftCardTotal) {
giftCardTotal = cardCoupon.getTfTotal() - cardCoupon.getGiftCardTotal();
if ((cardCoupon.getTfTotal() - cardCoupon.getTfGetNum()) < giftCardTotal) {
giftCardTotal = cardCoupon.getTfTotal() - cardCoupon.getTfGetNum();
}
//将优惠券添加到用户优惠券表

View File

@ -227,8 +227,8 @@ public class CardCouponController extends BaseController {
* 用户领取优惠券
* @return
*/
@GetMapping("userGetCoupon")
public ResponseObject userGetCoupon(Integer couponId){
@PostMapping("userGetCoupon")
public ResponseObject userGetCoupon(@RequestBody Integer couponId){
return getSuccessResult(cardCouponService.userGetCoupon(couponId));
}

View File

@ -21,6 +21,8 @@ import com.fuint.business.petrolStationManagement.entity.OilName;
import com.fuint.business.petrolStationManagement.mapper.OilNameMapper;
import com.fuint.business.store.entity.MtStore;
import com.fuint.business.store.mapper.MtStoreMapper;
import com.fuint.business.userManager.entity.UserBalance;
import com.fuint.business.userManager.mapper.UserBalanceMapper;
import com.fuint.business.userManager.service.LJUserService;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
@ -46,6 +48,8 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
private CardCouponUserMapper cardCouponUserMapper;
@Autowired
private LJUserService userService;
@Autowired
private UserBalanceMapper userBalanceMapper;
@Override
public IPage<CardCoupon> pageVo(Page page, CardCoupon cardCoupon) {
return baseMapper.pageVo( page, cardCoupon);
@ -90,6 +94,10 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
List<CardCouponUniVo> cardCouponUniVos1 = baseMapper.selectByStoreIdCount(cardCouponUniVo1);
Map<Integer, Integer> cardCouponMap = cardCouponUniVos1.stream().collect(Collectors.toMap(CardCouponUniVo::getId, CardCouponUniVo::getCount));
//查询用户的会员等级
UserBalance userBalance = userBalanceMapper.selectOne(new LambdaQueryWrapper<UserBalance>()
.eq(UserBalance::getMtUserId, nowAccountInfo.getId()));
//存放最终可领取的优惠券id集合
List<Integer> ids = new ArrayList<>();
@ -99,6 +107,11 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
if (ObjectUtil.isNotEmpty(coupon.getTfGetNum())){
getNum = coupon.getTfGetNum();
}
//判断当前用户是否符合会员等级
String[] split = coupon.getMembershipLevel().split(",");
if (!Arrays.asList(split).contains(userBalance.getGradeId().toString())) {
continue;
}
//查询该优惠券是否已到达限制数量
if ((getNum < coupon.getTfTotal())) {
Integer count = 0;
@ -166,7 +179,7 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
}
//判断是否有库存
int count = cardCoupon.getTfTotal() - cardCoupon.getGiftCardTotal();
int count = cardCoupon.getTfTotal() - (cardCoupon.getTfGetNum() == null ? 0 : cardCoupon.getTfGetNum());
if (count == 0) {
return 0;
}
@ -174,8 +187,8 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
Integer getCount = cardCouponUserMapper.selectCount(new LambdaQueryWrapper<CardCouponUser>()
.eq(CardCouponUser::getMtUserId, nowAccountInfo.getId())
.eq(CardCouponUser::getCardCouponId, couponId));
if (getCount >= cardCoupon.getGetNumLimit()) {
return 1;
if (getCount >= (cardCoupon.getGetNumLimit() == null ? 0 : cardCoupon.getGetNumLimit())) {
return 3;
}
Integer validityDay = 0;
//优惠券的有效期
@ -206,6 +219,7 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
cardCouponUserMapper.insert(cardCouponUser);
//更新优惠券表
if (cardCoupon.getTfGetNum() == null) cardCoupon.setTfGetNum(0);
cardCoupon.setTfGetNum(cardCoupon.getTfGetNum() + 1);
return baseMapper.updateById(cardCoupon);
}

View File

@ -2,8 +2,9 @@
<view class="centenr">
<view class="Candywrapper">
<view class="bai-bs">
<view class="">
<image :src="couponInfo.backgroundImage" v-if="couponInfo.backgroundImage" style="width: 60px; height: 60px; "></image>
<view class="">
<image :src="couponInfo.backgroundImage" v-if="couponInfo.backgroundImage"
style="width: 60px; height: 60px; "></image>
<image src="../../static/logo.png" v-else style="width: 60px; height: 60px; "></image>
</view>
<view class="rr-box">
@ -15,7 +16,9 @@
<view class="red-size" v-if="couponInfo.type==3">折扣券</view>
<view class="red-size" v-if="couponInfo.type==4">油品立减券</view>
<view class="red-size" v-if="couponInfo.type==5">单品代金券</view>
<view class="red-size">剩余{{ couponInfo.tfGetNum ? (couponInfo.tfTotal - couponInfo.tfGetNum) : couponInfo.tfTotal}}</view>
<view class="red-size">
剩余{{ couponInfo.tfGetNum ? (couponInfo.tfTotal - couponInfo.tfGetNum) : couponInfo.tfTotal}}
</view>
</view>
</view>
</view>
@ -27,7 +30,9 @@
<view class="si_">2每日限领{{couponInfo.dayGetLimit || 0}}</view>
<view class="si_">核销说明</view>
<view class="si_" style="display: flex;" v-for="(item,index) in couponInfo.hxList" :key="index">
<view style="width: 6px;height: 6px;border-radius: 50%;margin-right: 5px;background-color: #FF9655;margin-top: 6px;"></view>
<view
style="width: 6px;height: 6px;border-radius: 50%;margin-right: 5px;background-color: #FF9655;margin-top: 6px;">
</view>
<view>{{item}}</view>
</view>
</view>
@ -47,7 +52,7 @@
</view>
<view class="bottom-box">
<view class="or-num">免费</view>
<view class="anniu">立即领取</view>
<view class="anniu" @click="getCardCoupon()">立即领取</view>
</view>
</view>
</template>
@ -92,7 +97,7 @@
longitude: lon,
name: this.store.name,
address: this.store.address,
success: function() {
console.log('success');
},
@ -109,7 +114,7 @@
type: 'gcj02', // 使
success: function(res) {
if (_this.longitude == "" && _this.latitude == "") {
_this.longitude = res.longitude;
_this.latitude = res.latitude
}
@ -123,14 +128,14 @@
"lat": _this.latitude,
"storeId": storeId,
"isLogin": _this.AppToken ? "0" : "1", // 0
},
}).then((response) => {
if (response.data.store) {
_this.distance = (Math.ceil(response.data.distance))
.toFixed(1)
_this.store = response.data.store
_this.lon = _this.store.longitude
_this.lat = _this.store.latitude
console.log(_this.store, 129);
@ -140,7 +145,7 @@
icon: "none"
})
}
}).catch(err => {})
},
fail: function(err) {
@ -148,6 +153,38 @@
}
});
},
//
getCardCoupon() {
request({
url: '/cardCoupon/userGetCoupon',
method: 'post',
data: this.couponInfo.id
}).then(res => {
if (res.code == 200) {
if (res.data == 2) {
uni.showToast({
title: "优惠券已下线",
icon: "none"
})
} else if (res.data == 0) {
uni.showToast({
title: "优惠券剩余不足",
icon: "none"
})
} else if (res.data == 3) {
uni.showToast({
title: "你已领取上限",
icon: "none"
})
} else {
uni.showToast({
title: "领取成功",
icon: "none"
})
}
}
})
},
getInfo() {
request({
url: '/cardCoupon/' + this.certificateId,