下单获取保险信息
This commit is contained in:
parent
1b712a705d
commit
3e96984d64
|
|
@ -47,6 +47,10 @@ public class GoodsController extends BaseController {
|
|||
private GoodsStandardService goodsStandardService;
|
||||
@Resource
|
||||
private ISysAreaService sysAreaService;
|
||||
@Resource
|
||||
private IInsuranceManagerService insuranceManagerService;
|
||||
@Resource
|
||||
private IDeptCategoryInsuranceRelationService deptCategoryInsuranceRelationService;
|
||||
|
||||
@RequiresPermissions("goods:goods:view")
|
||||
@GetMapping()
|
||||
|
|
@ -322,7 +326,24 @@ public class GoodsController extends BaseController {
|
|||
goodsStandard.setFinalPrice(finalPrice);
|
||||
});
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ public class GoodsDeptCategoryController extends BaseController {
|
|||
@Resource
|
||||
DeptGoodsCategoryService deptGoodsCategoryService;
|
||||
|
||||
@Resource
|
||||
private GoodsCategoryService goodsCategoryService;
|
||||
|
||||
@Resource
|
||||
ICategoryInsuranceRelationService categoryInsuranceRelationService;
|
||||
|
||||
|
|
@ -157,6 +160,20 @@ public class GoodsDeptCategoryController extends BaseController {
|
|||
CategoryInsuranceRelation relation = new CategoryInsuranceRelation();
|
||||
relation.setGoodsCategoryId(deptGoodsCategory.getGoodsCategoryId());
|
||||
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保险设置
|
||||
List<InsuranceManager> pcInsuranceList = new ArrayList<>();
|
||||
// 商城保险设置
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ public class OrderController extends BaseController {
|
|||
@Resource
|
||||
private GoodsCategoryService goodsCategoryService;
|
||||
|
||||
@Resource
|
||||
private IInsuranceManagerService insuranceManagerService;
|
||||
|
||||
|
||||
@GetMapping("/imgs")
|
||||
public String orderImgs(Long orderId, ModelMap mmap){
|
||||
|
|
@ -546,6 +549,14 @@ public class OrderController extends BaseController {
|
|||
BigDecimal discountMoney = BigDecimal.ZERO;
|
||||
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
|
||||
payMoney = BigDecimal.ZERO.max(payMoney);
|
||||
|
||||
|
|
|
|||
|
|
@ -89,4 +89,7 @@ public class Goods extends BaseEntity {
|
|||
private List<String> lbUrl;
|
||||
|
||||
private String keyword;
|
||||
|
||||
|
||||
private List<InsuranceManager> insuranceManagers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ghy.goods.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
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.stereotype.Service;
|
||||
import com.ghy.goods.mapper.DeptCategoryInsuranceRelationMapper;
|
||||
|
|
@ -97,6 +99,50 @@ public class DeptCategoryInsuranceRelationServiceImpl implements IDeptCategoryIn
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,4 +44,5 @@ public class AppOrderRequest {
|
|||
|
||||
private Long goodsId;
|
||||
|
||||
private Long insuranceId;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue