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.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.setInsuranceId(appOrderRequest.getInsuranceId());
// TODO 优惠金额不知道咋算 暂时先给0
BigDecimal discountMoney = BigDecimal.ZERO;
BigDecimal payMoney = totalPay.subtract(discountMoney);
BigDecimal insuranceMoney = BigDecimal.ZERO;
// 保险金额
if(appOrderRequest.getInsuranceId() != null){
InsuranceManager manager = insuranceManagerService.selectInsuranceManagerById(appOrderRequest.getInsuranceId());
if(manager != null){
payMoney = payMoney.add(manager.getInsuranceAmount());
insuranceMoney = insuranceMoney.add(manager.getInsuranceAmount());
orderMaster.setInsuranceId(manager.getId());
}
}
@ -573,7 +576,7 @@ public class OrderController extends BaseController {
// 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)
@ -604,7 +607,8 @@ public class OrderController extends BaseController {
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;
// 一级分销
@ -637,6 +641,9 @@ public class OrderController extends BaseController {
.add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getRetainRate()))));
}
}
// 平台扣除保险 --
deptMoney = deptMoney.add(insuranceMoney);
// 平台扣点记录
FinancialDetail deptDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
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.setArrivalTime(detail.getArrivalTime());
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);
});
return voDataTable(orderListResponses, list);

View File

@ -1372,6 +1372,7 @@ public class OrderMasterController extends BaseController {
*/
@PostMapping("/editOrderMaster")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult editOrderMaster(@RequestBody OrderMaster orderMaster) {
try {
int result = orderMasterService.updateOrderMaster(orderMaster);
@ -1390,7 +1391,7 @@ public class OrderMasterController extends BaseController {
return AjaxResult.success("");
} catch (Exception e) {
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 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.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.ghy.common.utils.security.Md5Utils;
import com.ghy.customer.domain.CustomerAddress;
import com.ghy.customer.service.CustomerAddressService;
@ -38,7 +39,7 @@ public class InsuranceServiceImpl implements InsuranceService {
private IWorkerCertificationService workerCertificationService;
@Override
public void orderInsurance(String orderCode) {
public void orderInsurance(String orderCode) throws Exception{
InsuranceOrderReq req = new InsuranceOrderReq();
OrderMaster master = orderMasterService.selectByCode(orderCode);
req.setOrderNumber(master.getCode());
@ -57,5 +58,8 @@ public class InsuranceServiceImpl implements InsuranceService {
log.info("调用保险请求url:{},内容:{}", baseUrl+"/platInterface/order", JSONUtil.toJsonStr(req));
String result = HttpUtil.post(baseUrl+"/platInterface/order", JSONUtil.toJsonStr(req));
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("/warn/record/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("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon");
// 对静态资源设置匿名访问

View File

@ -1,11 +1,18 @@
package com.ghy.goods.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -14,6 +21,8 @@ import com.ghy.goods.domain.CategoryInsuranceRelation;
import com.ghy.goods.service.ICategoryInsuranceRelationService;
import com.ghy.common.core.text.Convert;
import javax.annotation.Resource;
/**
* 总类目保险关联关系Service业务层处理
*
@ -26,6 +35,12 @@ public class CategoryInsuranceRelationServiceImpl implements ICategoryInsuranceR
@Autowired
private CategoryInsuranceRelationMapper categoryInsuranceRelationMapper;
@Resource
private IDeptCategoryInsuranceRelationService deptCategoryInsuranceRelationService;
@Resource
private DeptGoodsCategoryService deptGoodsCategoryService;
/**
* 查询总类目保险关联关系
*
@ -105,20 +120,46 @@ public class CategoryInsuranceRelationServiceImpl implements ICategoryInsuranceR
CategoryInsuranceRelation param = new CategoryInsuranceRelation();
param.setGoodsCategoryId(categoryId);
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)){
String [] arr = new String[oldRecord.size()];
for (int index = 0; index < oldRecord.size(); index ++){
arr[index] = oldRecord.get(index).getId().toString();
if(CollectionUtil.isNotEmpty(delOlds)){
String [] arr = new String[delOlds.size()];
for (int index = 0; index < delOlds.size(); index ++){
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);
}
// 增加新记录
if(StringUtils.isNotEmpty(insuranceIds)){
String [] insuranceStr = insuranceIds.split(",");
for (String str : insuranceStr) {
if(CollectionUtil.isNotEmpty(addNews)){
for (Long id : addNews) {
CategoryInsuranceRelation model = new CategoryInsuranceRelation();
model.setInsuranceId(Long.valueOf(str));
model.setInsuranceId(id);
model.setGoodsCategoryId(categoryId);
categoryInsuranceRelationMapper.insertCategoryInsuranceRelation(model);
}

View File

@ -190,6 +190,9 @@
<if test="goodsCategoryName != null and goodsCategoryName != ''">
AND gc.goods_category_name LIKE concat('%', #{goodsCategoryName}, '%')
</if>
<if test="goodsCategoryId != null">
AND gc.goods_category_id = #{goodsCategoryId}
</if>
<if test="status != null and status != ''">
AND gc.status = #{status}
</if>
@ -213,7 +216,7 @@
<select id="selectOneByGoodsCategoryId" resultMap="DeptGoodsCategoryResult">
<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 id="selectByDeptId" resultMap="DeptGoodsCategoryResult">

View File

@ -429,7 +429,7 @@
<if test="orderMode != null">order_mode,</if>
<if test="payMode != null">pay_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="payType != null">pay_type,</if>
<if test="payStatus != null">pay_status,</if>
@ -453,7 +453,7 @@
<if test="orderMode != null">#{orderMode},</if>
<if test="payMode != null">#{payMode},</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="payType != null">#{payType},</if>
<if test="payStatus != null">#{payStatus},</if>