Compare commits

...

3 Commits

Author SHA1 Message Date
Yifei Kuang 94277bce22 保险金额归属给平台,不应展示给客户 2024-11-03 21:24:55 +08:00
kuang.yife 1a18fbb03b fix bug 2024-10-28 16:45:10 +08:00
kuang.yife b57f751831 fix bug 2024-10-23 17:00:48 +08:00
9 changed files with 81 additions and 16 deletions

View File

@ -542,17 +542,20 @@ public class OrderController extends BaseController {
orderMaster.setRemark(appOrderRequest.getRemark()); orderMaster.setRemark(appOrderRequest.getRemark());
orderMaster.setExpectTimeStart(DateUtils.parseDate(appOrderRequest.getExpectTimeStart(), com.ghy.common.utils.DateUtils.YYYY_MM_DD_HH_MM_SS)); orderMaster.setExpectTimeStart(DateUtils.parseDate(appOrderRequest.getExpectTimeStart(), com.ghy.common.utils.DateUtils.YYYY_MM_DD_HH_MM_SS));
orderMaster.setExpectTimeEnd(DateUtils.parseDate(appOrderRequest.getExpectTimeEnd(), com.ghy.common.utils.DateUtils.YYYY_MM_DD_HH_MM_SS)); orderMaster.setExpectTimeEnd(DateUtils.parseDate(appOrderRequest.getExpectTimeEnd(), com.ghy.common.utils.DateUtils.YYYY_MM_DD_HH_MM_SS));
orderMaster.setInsuranceId(appOrderRequest.getInsuranceId());
// TODO 优惠金额不知道咋算 暂时先给0 // TODO 优惠金额不知道咋算 暂时先给0
BigDecimal discountMoney = BigDecimal.ZERO; BigDecimal discountMoney = BigDecimal.ZERO;
BigDecimal payMoney = totalPay.subtract(discountMoney); BigDecimal payMoney = totalPay.subtract(discountMoney);
BigDecimal insuranceMoney = BigDecimal.ZERO;
// 保险金额 // 保险金额
if(appOrderRequest.getInsuranceId() != null){ if(appOrderRequest.getInsuranceId() != null){
InsuranceManager manager = insuranceManagerService.selectInsuranceManagerById(appOrderRequest.getInsuranceId()); InsuranceManager manager = insuranceManagerService.selectInsuranceManagerById(appOrderRequest.getInsuranceId());
if(manager != null){ if(manager != null){
payMoney = payMoney.add(manager.getInsuranceAmount()); payMoney = payMoney.add(manager.getInsuranceAmount());
insuranceMoney = insuranceMoney.add(manager.getInsuranceAmount());
orderMaster.setInsuranceId(manager.getId()); orderMaster.setInsuranceId(manager.getId());
} }
} }
@ -573,7 +576,7 @@ public class OrderController extends BaseController {
// createFinancialDetail(goodsList.get(0).getDeptGoodsCategoryId(), deptId, customer, payMoney, financialMaster); // createFinancialDetail(goodsList.get(0).getDeptGoodsCategoryId(), deptId, customer, payMoney, financialMaster);
//生成财务子单 //生成财务子单
createFinancialDetail(appGoodsList, deptId, customer, payMoney, financialMaster); createFinancialDetail(appGoodsList, deptId, customer, payMoney, financialMaster, insuranceMoney);
// 生成商品订单 // 生成商品订单
Map<Long, GoodsStandard> goodsMap = goodsList.stream().filter(Objects::nonNull) Map<Long, GoodsStandard> goodsMap = goodsList.stream().filter(Objects::nonNull)
@ -604,7 +607,8 @@ public class OrderController extends BaseController {
return AjaxResult.success(orderMaster); return AjaxResult.success(orderMaster);
} }
private void createFinancialDetail(List<AppGoodsRequest> appGoodsList, Long deptId, Customer customer, BigDecimal serverMoney, FinancialMaster financialMaster) { private void createFinancialDetail(List<AppGoodsRequest> appGoodsList, Long deptId, Customer customer,
BigDecimal serverMoney, FinancialMaster financialMaster, BigDecimal insuranceMoney) {
// 平台 // 平台
BigDecimal deptMoney = BigDecimal.ZERO; BigDecimal deptMoney = BigDecimal.ZERO;
// 一级分销 // 一级分销
@ -637,6 +641,9 @@ public class OrderController extends BaseController {
.add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getRetainRate())))); .add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getRetainRate()))));
} }
} }
// 平台扣除保险 --
deptMoney = deptMoney.add(insuranceMoney);
// 平台扣点记录 // 平台扣点记录
FinancialDetail deptDetail = new FinancialDetail(deptId, financialDetailService.createCode(), FinancialDetail deptDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
financialMaster.getId(), financialMaster.getCode(), deptMoney, FinancialDetailType.PLATFORM_FEE.getCode(), null); financialMaster.getId(), financialMaster.getCode(), deptMoney, FinancialDetailType.PLATFORM_FEE.getCode(), null);

View File

@ -704,6 +704,13 @@ public class OrderDetailController extends BaseController {
orderListResponse.setDrawCashStatus(detail.getDrawCashStatus()); orderListResponse.setDrawCashStatus(detail.getDrawCashStatus());
orderListResponse.setArrivalTime(detail.getArrivalTime()); orderListResponse.setArrivalTime(detail.getArrivalTime());
orderListResponse.setConsultMode(orderMaster.getConsultMode()); orderListResponse.setConsultMode(orderMaster.getConsultMode());
orderListResponse.setInsuranceId(orderMaster.getInsuranceId());
if(orderMaster.getInsuranceId() != null){
InsuranceManager manager = insuranceManagerService.selectInsuranceManagerById(orderMaster.getInsuranceId());
if(manager != null){
orderListResponse.setInsuranceManager(manager);
}
}
orderListResponses.add(orderListResponse); orderListResponses.add(orderListResponse);
}); });
return voDataTable(orderListResponses, list); return voDataTable(orderListResponses, list);

View File

@ -1372,6 +1372,7 @@ public class OrderMasterController extends BaseController {
*/ */
@PostMapping("/editOrderMaster") @PostMapping("/editOrderMaster")
@ResponseBody @ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult editOrderMaster(@RequestBody OrderMaster orderMaster) { public AjaxResult editOrderMaster(@RequestBody OrderMaster orderMaster) {
try { try {
int result = orderMasterService.updateOrderMaster(orderMaster); int result = orderMasterService.updateOrderMaster(orderMaster);
@ -1390,7 +1391,7 @@ public class OrderMasterController extends BaseController {
return AjaxResult.success(""); return AjaxResult.success("");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return AjaxResult.error(""); return AjaxResult.error(e.getMessage());
} }
} }

View File

@ -2,7 +2,7 @@ package com.ghy.web.service;
public interface InsuranceService { public interface InsuranceService {
public void orderInsurance(String orderCode); public void orderInsurance(String orderCode) throws Exception;

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.ghy.common.utils.security.Md5Utils; import com.ghy.common.utils.security.Md5Utils;
import com.ghy.customer.domain.CustomerAddress; import com.ghy.customer.domain.CustomerAddress;
import com.ghy.customer.service.CustomerAddressService; import com.ghy.customer.service.CustomerAddressService;
@ -38,7 +39,7 @@ public class InsuranceServiceImpl implements InsuranceService {
private IWorkerCertificationService workerCertificationService; private IWorkerCertificationService workerCertificationService;
@Override @Override
public void orderInsurance(String orderCode) { public void orderInsurance(String orderCode) throws Exception{
InsuranceOrderReq req = new InsuranceOrderReq(); InsuranceOrderReq req = new InsuranceOrderReq();
OrderMaster master = orderMasterService.selectByCode(orderCode); OrderMaster master = orderMasterService.selectByCode(orderCode);
req.setOrderNumber(master.getCode()); req.setOrderNumber(master.getCode());
@ -57,5 +58,8 @@ public class InsuranceServiceImpl implements InsuranceService {
log.info("调用保险请求url:{},内容:{}", baseUrl+"/platInterface/order", JSONUtil.toJsonStr(req)); log.info("调用保险请求url:{},内容:{}", baseUrl+"/platInterface/order", JSONUtil.toJsonStr(req));
String result = HttpUtil.post(baseUrl+"/platInterface/order", JSONUtil.toJsonStr(req)); String result = HttpUtil.post(baseUrl+"/platInterface/order", JSONUtil.toJsonStr(req));
log.info("调用保险返回内容:{}", result); log.info("调用保险返回内容:{}", result);
if(!"1".equals(JSONObject.parseObject(result).getString("code"))){
throw new Exception(JSONObject.parseObject(result).getString("msg"));
}
} }
} }

View File

@ -293,6 +293,8 @@ public class ShiroConfig
filterChainDefinitionMap.put("/order/operate/app/**", "anon"); filterChainDefinitionMap.put("/order/operate/app/**", "anon");
filterChainDefinitionMap.put("/warn/record/app/**", "anon"); filterChainDefinitionMap.put("/warn/record/app/**", "anon");
filterChainDefinitionMap.put("/customer/selection/app/**", "anon"); filterChainDefinitionMap.put("/customer/selection/app/**", "anon");
filterChainDefinitionMap.put("/insurance/user/app/**", "anon");
filterChainDefinitionMap.put("/insurance/user/**", "anon");
filterChainDefinitionMap.put("/jim/**", "anon"); filterChainDefinitionMap.put("/jim/**", "anon");
filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon"); filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon");
// 对静态资源设置匿名访问 // 对静态资源设置匿名访问

View File

@ -1,11 +1,18 @@
package com.ghy.goods.service.impl; package com.ghy.goods.service.impl;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.ghy.common.utils.DateUtils; import com.ghy.common.utils.DateUtils;
import com.ghy.goods.domain.DeptCategoryInsuranceRelation;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.IDeptCategoryInsuranceRelationService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -14,6 +21,8 @@ import com.ghy.goods.domain.CategoryInsuranceRelation;
import com.ghy.goods.service.ICategoryInsuranceRelationService; import com.ghy.goods.service.ICategoryInsuranceRelationService;
import com.ghy.common.core.text.Convert; import com.ghy.common.core.text.Convert;
import javax.annotation.Resource;
/** /**
* 总类目保险关联关系Service业务层处理 * 总类目保险关联关系Service业务层处理
* *
@ -26,6 +35,12 @@ public class CategoryInsuranceRelationServiceImpl implements ICategoryInsuranceR
@Autowired @Autowired
private CategoryInsuranceRelationMapper categoryInsuranceRelationMapper; private CategoryInsuranceRelationMapper categoryInsuranceRelationMapper;
@Resource
private IDeptCategoryInsuranceRelationService deptCategoryInsuranceRelationService;
@Resource
private DeptGoodsCategoryService deptGoodsCategoryService;
/** /**
* 查询总类目保险关联关系 * 查询总类目保险关联关系
* *
@ -105,20 +120,46 @@ public class CategoryInsuranceRelationServiceImpl implements ICategoryInsuranceR
CategoryInsuranceRelation param = new CategoryInsuranceRelation(); CategoryInsuranceRelation param = new CategoryInsuranceRelation();
param.setGoodsCategoryId(categoryId); param.setGoodsCategoryId(categoryId);
List<CategoryInsuranceRelation> oldRecord = categoryInsuranceRelationMapper.selectCategoryInsuranceRelationList(param); List<CategoryInsuranceRelation> oldRecord = categoryInsuranceRelationMapper.selectCategoryInsuranceRelationList(param);
Map<Long, CategoryInsuranceRelation> insuranceRelationMap = oldRecord.stream().collect(Collectors.toMap(CategoryInsuranceRelation::getInsuranceId, Function.identity(), (x1, x2)->x1));
// 已存在的id
List<Long> oldIds = oldRecord.stream().map(CategoryInsuranceRelation::getInsuranceId).collect(Collectors.toList());
// 新的
List<Long> newIds = new ArrayList<>();
if(StringUtils.isNotEmpty(insuranceIds)){
for (String id : insuranceIds.split(",")) {
newIds.add(Long.valueOf(id));
}
}
// 删除旧的
List<Long> delOlds = oldIds.stream().filter(x->!newIds.contains(x)).collect(Collectors.toList());
// 增加新的
List<Long> addNews = newIds.stream().filter(x->!oldIds.contains(x)).collect(Collectors.toList());
// 删除历史记录 // 删除历史记录
if(CollectionUtil.isNotEmpty(oldRecord)){ if(CollectionUtil.isNotEmpty(delOlds)){
String [] arr = new String[oldRecord.size()]; String [] arr = new String[delOlds.size()];
for (int index = 0; index < oldRecord.size(); index ++){ for (int index = 0; index < delOlds.size(); index ++){
arr[index] = oldRecord.get(index).getId().toString(); arr[index] = insuranceRelationMap.get(delOlds.get(index)).getId().toString();
// 删除关联的平台类目的
// 查找类目
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.selectOneByGoodsCategoryId(categoryId);
if(deptGoodsCategory != null){
DeptCategoryInsuranceRelation deptCategoryInsuranceRelation = new DeptCategoryInsuranceRelation();
deptCategoryInsuranceRelation.setDeptCategoryId(deptGoodsCategory.getDeptGoodsCategoryId());
deptCategoryInsuranceRelation.setInsuranceId(delOlds.get(index));
List<DeptCategoryInsuranceRelation> delList = deptCategoryInsuranceRelationService.selectDeptCategoryInsuranceRelationList(deptCategoryInsuranceRelation);
delList.forEach(model->{
deptCategoryInsuranceRelationService.deleteDeptCategoryInsuranceRelationById(model.getId());
});
}
} }
categoryInsuranceRelationMapper.deleteCategoryInsuranceRelationByIds(arr); categoryInsuranceRelationMapper.deleteCategoryInsuranceRelationByIds(arr);
} }
// 增加新记录 // 增加新记录
if(StringUtils.isNotEmpty(insuranceIds)){ if(CollectionUtil.isNotEmpty(addNews)){
String [] insuranceStr = insuranceIds.split(","); for (Long id : addNews) {
for (String str : insuranceStr) {
CategoryInsuranceRelation model = new CategoryInsuranceRelation(); CategoryInsuranceRelation model = new CategoryInsuranceRelation();
model.setInsuranceId(Long.valueOf(str)); model.setInsuranceId(id);
model.setGoodsCategoryId(categoryId); model.setGoodsCategoryId(categoryId);
categoryInsuranceRelationMapper.insertCategoryInsuranceRelation(model); categoryInsuranceRelationMapper.insertCategoryInsuranceRelation(model);
} }

View File

@ -190,6 +190,9 @@
<if test="goodsCategoryName != null and goodsCategoryName != ''"> <if test="goodsCategoryName != null and goodsCategoryName != ''">
AND gc.goods_category_name LIKE concat('%', #{goodsCategoryName}, '%') AND gc.goods_category_name LIKE concat('%', #{goodsCategoryName}, '%')
</if> </if>
<if test="goodsCategoryId != null">
AND gc.goods_category_id = #{goodsCategoryId}
</if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND gc.status = #{status} AND gc.status = #{status}
</if> </if>
@ -213,7 +216,7 @@
<select id="selectOneByGoodsCategoryId" resultMap="DeptGoodsCategoryResult"> <select id="selectOneByGoodsCategoryId" resultMap="DeptGoodsCategoryResult">
<include refid="selectJoin"/> <include refid="selectJoin"/>
WHERE gc.goods_category_id = #{goodsCategoryId} LIMIT 1 WHERE gc.goods_category_id = #{goodsCategoryId} and dept_id = 101 LIMIT 1
</select> </select>
<select id="selectByDeptId" resultMap="DeptGoodsCategoryResult"> <select id="selectByDeptId" resultMap="DeptGoodsCategoryResult">

View File

@ -429,7 +429,7 @@
<if test="orderMode != null">order_mode,</if> <if test="orderMode != null">order_mode,</if>
<if test="payMode != null">pay_mode,</if> <if test="payMode != null">pay_mode,</if>
<if test="consultMode != null">consult_mode,</if> <if test="consultMode != null">consult_mode,</if>
<if test="insurance_id != null">insurance_id,</if> <if test="insuranceId != null">insurance_id,</if>
<if test="orderStatus != null">order_status,</if> <if test="orderStatus != null">order_status,</if>
<if test="payType != null">pay_type,</if> <if test="payType != null">pay_type,</if>
<if test="payStatus != null">pay_status,</if> <if test="payStatus != null">pay_status,</if>
@ -453,7 +453,7 @@
<if test="orderMode != null">#{orderMode},</if> <if test="orderMode != null">#{orderMode},</if>
<if test="payMode != null">#{payMode},</if> <if test="payMode != null">#{payMode},</if>
<if test="consultMode != null">#{consultMode},</if> <if test="consultMode != null">#{consultMode},</if>
<if test="insurance_id != null">#{consultMode},</if> <if test="insuranceId != null">#{insuranceId},</if>
<if test="orderStatus != null">#{orderStatus},</if> <if test="orderStatus != null">#{orderStatus},</if>
<if test="payType != null">#{payType},</if> <if test="payType != null">#{payType},</if>
<if test="payStatus != null">#{payStatus},</if> <if test="payStatus != null">#{payStatus},</if>