下单获取保险信息

This commit is contained in:
kuang.yife 2024-10-12 10:42:07 +08:00
parent 1b712a705d
commit 3e96984d64
6 changed files with 100 additions and 1 deletions

View File

@ -47,6 +47,10 @@ public class GoodsController extends BaseController {
private GoodsStandardService goodsStandardService; private GoodsStandardService goodsStandardService;
@Resource @Resource
private ISysAreaService sysAreaService; private ISysAreaService sysAreaService;
@Resource
private IInsuranceManagerService insuranceManagerService;
@Resource
private IDeptCategoryInsuranceRelationService deptCategoryInsuranceRelationService;
@RequiresPermissions("goods:goods:view") @RequiresPermissions("goods:goods:view")
@GetMapping() @GetMapping()
@ -322,7 +326,24 @@ public class GoodsController extends BaseController {
goodsStandard.setFinalPrice(finalPrice); goodsStandard.setFinalPrice(finalPrice);
}); });
result.setGoodsStandardList(goodsStandards); result.setGoodsStandardList(goodsStandards);
// 所有保险信息
List<InsuranceManager> insuranceManagers = insuranceManagerService.selectInsuranceManagerList(new InsuranceManager());
// 查询本类目保险信息
DeptCategoryInsuranceRelation param = new DeptCategoryInsuranceRelation();
param.setType("01");
param.setDeptCategoryId(goodsStandards.get(0).getDeptGoodsCategoryId());
List<DeptCategoryInsuranceRelation> deptCategoryInsuranceRelations = deptCategoryInsuranceRelationService.selectDeptCategoryInsuranceRelationList(param);
if(CollectionUtils.isNotEmpty(deptCategoryInsuranceRelations)){
Map<Long, List<DeptCategoryInsuranceRelation>> insuranceMap = deptCategoryInsuranceRelations.stream().collect(Collectors.groupingBy(DeptCategoryInsuranceRelation::getInsuranceId));
// 目标保险
List<InsuranceManager> goal = new ArrayList<>();
insuranceManagers.forEach(model->{
if(insuranceMap.containsKey(model.getId())){
goal.add(model);
}
});
result.setInsuranceManagers(goal);
}
return AjaxResult.success(result); return AjaxResult.success(result);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -38,6 +38,9 @@ public class GoodsDeptCategoryController extends BaseController {
@Resource @Resource
DeptGoodsCategoryService deptGoodsCategoryService; DeptGoodsCategoryService deptGoodsCategoryService;
@Resource
private GoodsCategoryService goodsCategoryService;
@Resource @Resource
ICategoryInsuranceRelationService categoryInsuranceRelationService; ICategoryInsuranceRelationService categoryInsuranceRelationService;
@ -157,6 +160,20 @@ public class GoodsDeptCategoryController extends BaseController {
CategoryInsuranceRelation relation = new CategoryInsuranceRelation(); CategoryInsuranceRelation relation = new CategoryInsuranceRelation();
relation.setGoodsCategoryId(deptGoodsCategory.getGoodsCategoryId()); relation.setGoodsCategoryId(deptGoodsCategory.getGoodsCategoryId());
List<CategoryInsuranceRelation> relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(relation); List<CategoryInsuranceRelation> relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(relation);
// 当第四级没有的时候往上找三级
if(CollectionUtil.isEmpty(relations)){
GoodsCategory model = goodsCategoryService.selectById(deptGoodsCategory.getGoodsCategoryId());
CategoryInsuranceRelation parentRelation = new CategoryInsuranceRelation();
parentRelation.setGoodsCategoryId(model.getParentCategoryId());
relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(parentRelation);
// 当第三级没有的时候往上找二级
if(CollectionUtil.isEmpty(relations)){
GoodsCategory parentModel = goodsCategoryService.selectById(model.getParentCategoryId());
CategoryInsuranceRelation topRelation = new CategoryInsuranceRelation();
topRelation.setGoodsCategoryId(parentModel.getParentCategoryId());
relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(topRelation);
}
}
// pc保险设置 // pc保险设置
List<InsuranceManager> pcInsuranceList = new ArrayList<>(); List<InsuranceManager> pcInsuranceList = new ArrayList<>();
// 商城保险设置 // 商城保险设置

View File

@ -108,6 +108,9 @@ public class OrderController extends BaseController {
@Resource @Resource
private GoodsCategoryService goodsCategoryService; private GoodsCategoryService goodsCategoryService;
@Resource
private IInsuranceManagerService insuranceManagerService;
@GetMapping("/imgs") @GetMapping("/imgs")
public String orderImgs(Long orderId, ModelMap mmap){ public String orderImgs(Long orderId, ModelMap mmap){
@ -546,6 +549,14 @@ public class OrderController extends BaseController {
BigDecimal discountMoney = BigDecimal.ZERO; BigDecimal discountMoney = BigDecimal.ZERO;
BigDecimal payMoney = totalPay.subtract(discountMoney); BigDecimal payMoney = totalPay.subtract(discountMoney);
// 保险金额
if(appOrderRequest.getInsuranceId() != null){
InsuranceManager manager = insuranceManagerService.selectInsuranceManagerById(appOrderRequest.getInsuranceId());
if(manager != null){
payMoney = payMoney.add(manager.getInsuranceAmount());
}
}
// 当实付金额payType<=0时 使payType=BigDecimal.ZERO // 当实付金额payType<=0时 使payType=BigDecimal.ZERO
payMoney = BigDecimal.ZERO.max(payMoney); payMoney = BigDecimal.ZERO.max(payMoney);

View File

@ -89,4 +89,7 @@ public class Goods extends BaseEntity {
private List<String> lbUrl; private List<String> lbUrl;
private String keyword; private String keyword;
private List<InsuranceManager> insuranceManagers;
} }

View File

@ -2,6 +2,8 @@ package com.ghy.goods.service.impl;
import java.util.List; import java.util.List;
import com.ghy.common.utils.DateUtils; import com.ghy.common.utils.DateUtils;
import com.ghy.common.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ghy.goods.mapper.DeptCategoryInsuranceRelationMapper; import com.ghy.goods.mapper.DeptCategoryInsuranceRelationMapper;
@ -97,6 +99,50 @@ public class DeptCategoryInsuranceRelationServiceImpl implements IDeptCategoryIn
@Override @Override
public void updateDeptCategoryInsuranceRelation(String pcInsuranceIds, String shopInsuranceIds, Long deptGoodsCategoryId) { public void updateDeptCategoryInsuranceRelation(String pcInsuranceIds, String shopInsuranceIds, Long deptGoodsCategoryId) {
// pc --
if(StringUtils.isNotEmpty(pcInsuranceIds)){
// 删除旧的
DeptCategoryInsuranceRelation pcRelationParam = new DeptCategoryInsuranceRelation();
pcRelationParam.setDeptCategoryId(deptGoodsCategoryId);
pcRelationParam.setType("02");
List<DeptCategoryInsuranceRelation> pcRelationOld = deptCategoryInsuranceRelationMapper.selectDeptCategoryInsuranceRelationList(pcRelationParam);
if(CollectionUtils.isNotEmpty(pcRelationOld)){
pcRelationOld.forEach(model->{
deptCategoryInsuranceRelationMapper.deleteDeptCategoryInsuranceRelationById(model.getId());
});
}
// 增加新的
for (String id : pcInsuranceIds.split(",")) {
DeptCategoryInsuranceRelation pcRelation = new DeptCategoryInsuranceRelation();
pcRelation.setDeptCategoryId(deptGoodsCategoryId);
pcRelation.setType("02");
pcRelation.setInsuranceId(Long.valueOf(id));
deptCategoryInsuranceRelationMapper.insertDeptCategoryInsuranceRelation(pcRelation);
}
}
// 商城 --
if(StringUtils.isNotEmpty(shopInsuranceIds)){
// 删除旧的
DeptCategoryInsuranceRelation pcRelationParam = new DeptCategoryInsuranceRelation();
pcRelationParam.setDeptCategoryId(deptGoodsCategoryId);
pcRelationParam.setType("01");
List<DeptCategoryInsuranceRelation> pcRelationOld = deptCategoryInsuranceRelationMapper.selectDeptCategoryInsuranceRelationList(pcRelationParam);
if(CollectionUtils.isNotEmpty(pcRelationOld)){
pcRelationOld.forEach(model->{
deptCategoryInsuranceRelationMapper.deleteDeptCategoryInsuranceRelationById(model.getId());
});
}
// 增加新的
for (String id : shopInsuranceIds.split(",")) {
DeptCategoryInsuranceRelation pcRelation = new DeptCategoryInsuranceRelation();
pcRelation.setDeptCategoryId(deptGoodsCategoryId);
pcRelation.setType("01");
pcRelation.setInsuranceId(Long.valueOf(id));
deptCategoryInsuranceRelationMapper.insertDeptCategoryInsuranceRelation(pcRelation);
}
}
} }
} }

View File

@ -44,4 +44,5 @@ public class AppOrderRequest {
private Long goodsId; private Long goodsId;
private Long insuranceId;
} }