This commit is contained in:
cun-nan 2024-10-12 17:29:35 +08:00
parent 2e641eb0b3
commit 48f29f4873
6 changed files with 112 additions and 27 deletions

View File

@ -465,27 +465,27 @@
</div>
</div>
</el-form-item>
<el-form-item label="适用商品" prop="productLimit">
<div class="d-s" style="cursor: pointer">
<div class="d-s" @click="ruleForm.productLimit = 1">
<img src="../../../assets/images/wx.png" v-if="ruleForm.productLimit != 1" style="width: 20px;height: 20px;">
<img src="../../../assets/images/xz.png" v-if="ruleForm.productLimit == 1" style="width: 20px;height: 20px;">
<div>不限</div>
</div>
<div class="d-s" @click="ruleForm.productLimit = 2">
<img src="../../../assets/images/wx.png" v-if="ruleForm.productLimit != 2" style="width: 20px;height: 20px;">
<img src="../../../assets/images/xz.png" v-if="ruleForm.productLimit == 2" style="width: 20px;height: 20px;">
<div>自定义</div>
<el-select v-if="ruleForm.productLimit == 2" v-model="ruleForm.productIds" placeholder="请选择商品名称(可多选)" style="margin-left: 10px">
<el-option
v-for="item in goodsList"
:key="item.id+''"
:label="item.name"
:value="item.id+''"></el-option>
</el-select>
</div>
</div>
</el-form-item>
<!-- <el-form-item label="适用商品" prop="productLimit">-->
<!-- <div class="d-s" style="cursor: pointer">-->
<!-- <div class="d-s" @click="ruleForm.productLimit = 1">-->
<!-- <img src="../../../assets/images/wx.png" v-if="ruleForm.productLimit != 1" style="width: 20px;height: 20px;">-->
<!-- <img src="../../../assets/images/xz.png" v-if="ruleForm.productLimit == 1" style="width: 20px;height: 20px;">-->
<!-- <div>不限</div>-->
<!-- </div>-->
<!-- <div class="d-s" @click="ruleForm.productLimit = 2">-->
<!-- <img src="../../../assets/images/wx.png" v-if="ruleForm.productLimit != 2" style="width: 20px;height: 20px;">-->
<!-- <img src="../../../assets/images/xz.png" v-if="ruleForm.productLimit == 2" style="width: 20px;height: 20px;">-->
<!-- <div>自定义</div>-->
<!-- <el-select v-if="ruleForm.productLimit == 2" v-model="ruleForm.productIds" placeholder="请选择商品名称(可多选)" style="margin-left: 10px">-->
<!-- <el-option-->
<!-- v-for="item in goodsList"-->
<!-- :key="item.id+''"-->
<!-- :label="item.name"-->
<!-- :value="item.id+''"></el-option>-->
<!-- </el-select>-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-form-item>-->
<el-form-item>

View File

@ -3,6 +3,8 @@ package com.fuint.business.marketingActivity.cardValueRule.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.marketingActivity.cardValueRule.entity.CardValueRule;
import java.util.List;
/**
* 储值卡规则(CardValueRule)表服务接口
*
@ -10,6 +12,11 @@ import com.fuint.business.marketingActivity.cardValueRule.entity.CardValueRule;
* @since 2024-09-08 18:19:04
*/
public interface CardValueRuleService extends IService<CardValueRule> {
/**
* 根据店铺id查询储值卡规则的油品id列表
* @param storeId
* @return
*/
List<String> getOilIds(Integer storeId);
}

View File

@ -1,11 +1,19 @@
package com.fuint.business.marketingActivity.cardValueRule.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.marketingActivity.cardValueRule.mapper.CardValueRuleMapper;
import com.fuint.business.marketingActivity.cardValueRule.entity.CardValueRule;
import com.fuint.business.marketingActivity.cardValueRule.service.CardValueRuleService;
import com.fuint.common.util.TokenUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 储值卡规则(CardValueRule)表服务实现类
*
@ -15,5 +23,17 @@ import org.springframework.stereotype.Service;
@Service("cardValueRuleService")
public class CardValueRuleServiceImpl extends ServiceImpl<CardValueRuleMapper, CardValueRule> implements CardValueRuleService {
@Override
public List<String> getOilIds(Integer storeId) {
List<String> list = new ArrayList<String>();
LambdaQueryWrapper<CardValueRule> queryWrapper =new LambdaQueryWrapper<CardValueRule>();
queryWrapper.eq(CardValueRule::getStoreId, TokenUtil.getNowAccountInfo().getStoreId())
.eq(CardValueRule::getType,"0").last("limit 1");
CardValueRule one = baseMapper.selectOne(queryWrapper);
if (ObjectUtil.isNotEmpty(one) && ObjectUtil.isNotEmpty(one.getOilNumber())){
list = Arrays.asList(one.getOilNumber().split(","));
}
return list;
}
}

View File

@ -41,6 +41,7 @@ import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord;
import com.fuint.business.marketingActivity.cardValue.mapper.CardValueRecordMapper;
import com.fuint.business.marketingActivity.cardValueChildrens.entity.CardValudChildrens;
import com.fuint.business.marketingActivity.cardValueChildrens.service.CardValudChildrensService;
import com.fuint.business.marketingActivity.cardValueRule.service.CardValueRuleService;
import com.fuint.business.marketingActivity.favorableRecords.entity.FavorableRecords;
import com.fuint.business.marketingActivity.favorableRecords.service.FavorableRecordsService;
import com.fuint.business.member.mapper.LJStaffMapper;
@ -71,10 +72,7 @@ import com.fuint.business.userManager.entity.ChainStoreConfig;
import com.fuint.business.userManager.entity.LJUser;
import com.fuint.business.userManager.entity.LJUserGrade;
import com.fuint.business.userManager.entity.UserBalance;
import com.fuint.business.userManager.service.ChainStoreConfigService;
import com.fuint.business.userManager.service.LJUserGradeService;
import com.fuint.business.userManager.service.LJUserService;
import com.fuint.business.userManager.service.UserBalanceService;
import com.fuint.business.userManager.service.*;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.StringUtils;
@ -196,6 +194,10 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
@Autowired
@Lazy
private PayCenterService payCenterService;
@Autowired
private IMtUserFuelService userFuelService;
@Autowired
private CardValueRuleService cardValueRuleService;
@Override
public IPage<OilOrder> selectOilOrderList(Page page, OilOrder order) {
@ -490,6 +492,43 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
return orders;
}
// 查看会员储值卡余额是否足够付款
if (payType.equals("card_value")){
if (ObjectUtil.isEmpty(userId)){
orders.put("error", "请先选择会员信息");
return orders;
}
UserBalance userBalance = userBalanceService.selectUserBalance(userId, nowAccountInfo.getChainStoreId());
if (userBalance.getCardBalance()<oilActualPay){
orders.put("error", "余额不足,请分开支付");
return orders;
}
List<String> oilIds = cardValueRuleService.getOilIds(storeId);
boolean flag = false;
for (String oilId : oilIds) {
if (oilId.equals(JSONObject.parseObject(oilOrder).get("oils").toString())){
flag = true;
}
}
if (!flag) {
orders.put("error", "此油品不支持储值卡支付");
return orders;
}
}
// 查看会员囤油卡余额是否足够付款
if (payType.equals("fule_card")){
if (ObjectUtil.isEmpty(userId)){
orders.put("error", "请先选择会员信息");
return orders;
}
Double fuelAmount = userFuelService.selectByUserIdAndOilId(userId, Integer.valueOf(JSONObject.parseObject(oilOrder).get("oils").toString()), storeId);
if (fuelAmount<oilActualPay){
orders.put("error", "余额不足,请分开支付");
return orders;
}
}
// 添加商品订单信息
if (!goodsOrder.equals("[]")) {
LJOrder ljOrder = new LJOrder();

View File

@ -12,5 +12,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @since 2024-09-24
*/
public interface IMtUserFuelService extends IService<MtUserFuel> {
/**
* 根据用户id和油号id查询油量信息
* @param userId
* @param oilId
* @return
*/
Double selectByUserIdAndOilId(Integer userId, Integer oilId, Integer storeId);
}

View File

@ -1,5 +1,7 @@
package com.fuint.business.userManager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fuint.business.userManager.entity.MtUserFuel;
import com.fuint.business.userManager.mapper.MtUserFuelMapper;
import com.fuint.business.userManager.service.IMtUserFuelService;
@ -17,4 +19,15 @@ import org.springframework.stereotype.Service;
@Service
public class MtUserFuelServiceImpl extends ServiceImpl<MtUserFuelMapper, MtUserFuel> implements IMtUserFuelService {
@Override
public Double selectByUserIdAndOilId(Integer userId, Integer oilId, Integer storeId) {
Double fuelAmount = 0.0;;
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("mt_user_id", userId);
queryWrapper.eq("oil_name", oilId);
queryWrapper.eq("store_id", storeId);
MtUserFuel mtUserFuel = baseMapper.selectOne(queryWrapper);
if (ObjectUtil.isNotEmpty(mtUserFuel) && ObjectUtil.isNotEmpty(mtUserFuel.getFuelAmount())) fuelAmount = mtUserFuel.getFuelAmount();
return fuelAmount;
}
}