liujie
2023-10-15 1707d15796d7dc78812f19b9c34868c8cb38a714
src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java
@@ -2,6 +2,7 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.util.ToolUtil;
@@ -27,6 +28,7 @@
import java.math.RoundingMode;
import java.net.FileNameMap;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@@ -321,7 +323,7 @@
        TUser tUser = itUserService.selectById(userId);
        List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId()));
        ArrayList<PriceInfo> priceInfos = new ArrayList<>();
        if(tUser.getGroupId()!=null){
        if(false){
            TGroup tGroup = groupService.selectById(tUser.getGroupId());
            User user = service.selectById(tGroup.getSalesId());
@@ -358,8 +360,8 @@
        }else {
            for (TPrice price : prices) {
                PriceInfo priceInfo = new PriceInfo();
                priceInfo.setCarrierCost(price.getPrice());
                priceInfo.setCustomerCost(price.getPrice());
                priceInfo.setCarrierCost(price.getCarPrice());
                priceInfo.setCustomerCost(price.getCarPrice());
                priceInfo.setName(price.getType());
                priceInfo.setSalesProfit(new BigDecimal(0));
                priceInfo.setMargin(new BigDecimal(0));
@@ -680,7 +682,6 @@
        return new ErrorTip(500,"ERROR");
    }
    @ApiOperation(value = "订单详情-提货单",notes="订单详情-提货单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
@@ -733,8 +734,6 @@
    }
    @ApiOperation(value = "平台给用户报价/平台给卡车公司价格",notes="平台给用户报价/平台给卡车公司价格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
@@ -753,36 +752,39 @@
        map.put("pickUpDate",tOrder.getShipmentDate());
        map.put("returnDate",tOrder.getOrderOkTime());
        List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", orderId));
        prices.forEach(e->e.setPrice(e.getCarPrice()));
        if(type==1){
            map.put("price",prices);
        }else{
            map.put("price",prices);
            // 找出订单用户 --> 获取销售--> 获取提成 --> 计算应给卡车公司金额
            Integer userId = tOrder.getUserId();
            TUser tUser = itUserService.selectById(userId);
            if(tUser.getGroupId()==null){
                map.put("price",prices);
            }else {
                TGroup tGroup = groupService.selectById(tUser.getGroupId());
                User user = service.selectById(tGroup.getSalesId());
                List<TUserFeeSetting> tUserFeeSettings = feeSettingService.selectList(new EntityWrapper<TUserFeeSetting>().eq("user_id", user.getId()));
                for (TPrice price : prices) {
                    for (TUserFeeSetting tUserFeeSetting : tUserFeeSettings) {
                        if(price.getType().equals(tUserFeeSetting.getName())){
                            if(tUserFeeSetting.getFee()!=null && tUserFeeSetting.getFee()!=0) {
                                double v = ((double) tUserFeeSetting.getFee()) / 100;
                                BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v));
                                BigDecimal subtract = price.getPrice().subtract(multiply);
                                price.setPrice(subtract);
                            }else {
                                price.setPrice(price.getPrice());
                            }
                            break;
                        }
                    }
                }
                map.put("price",prices);
            }
//            Integer userId = tOrder.getUserId();
//            TUser tUser = itUserService.selectById(userId);
//            if(tUser.getGroupId()==null){
//                map.put("price",prices);
//            }else {
//                prices.for
//                TGroup tGroup = groupService.selectById(tUser.getGroupId());
//                User user = service.selectById(tGroup.getSalesId());
//                List<TUserFeeSetting> tUserFeeSettings = feeSettingService.selectList(new EntityWrapper<TUserFeeSetting>().eq("user_id", user.getId()));
//
//                for (TPrice price : prices) {
//                    for (TUserFeeSetting tUserFeeSetting : tUserFeeSettings) {
//                        if(price.getType().equals(tUserFeeSetting.getName())){
//                            if(tUserFeeSetting.getFee()!=null && tUserFeeSetting.getFee()!=0) {
//                                double v = ((double) tUserFeeSetting.getFee()) / 100;
//                                BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v));
//                                BigDecimal subtract = price.getPrice().subtract(multiply);
//                                price.setPrice(subtract);
//                            }else {
//                                price.setPrice(price.getPrice());
//                            }
//                            break;
//                        }
//                    }
//                }
//                map.put("price",prices);
//            }
        }
        return new SuccessTip(map);
    }