Quellcode durchsuchen

Merge branch 'master' of http://git.zthymaoyi.com/gongdc/uni_project

achao vor 3 Jahren
Ursprung
Commit
77066044b6

+ 19 - 4
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/sys/CollectionPaymentServiceImpl.java

@@ -11,9 +11,11 @@ import com.iotechn.unimall.core.exception.AdminServiceException;
 import com.iotechn.unimall.core.exception.ExceptionDefinition;
 import com.iotechn.unimall.core.exception.ServiceException;
 import com.iotechn.unimall.data.domain.CollectionPaymentDO;
+import com.iotechn.unimall.data.domain.CustomerInfoDO;
 import com.iotechn.unimall.data.dto.CollectionPaymentDTO;
 import com.iotechn.unimall.data.dto.CollectionPaymentTiDTO;
 import com.iotechn.unimall.data.mapper.CollectionPaymentMapper;
+import com.iotechn.unimall.data.mapper.CustomerInfoMapper;
 import com.iotechn.unimall.data.model.Page;
 import com.iotechn.unimall.data.util.ExcelUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -51,6 +53,8 @@ public class CollectionPaymentServiceImpl implements CollectionPaymentService {
 
     @Autowired
     private CollectionPaymentMapper collectionPaymentMapper;
+    @Autowired
+    private CustomerInfoMapper customerInfoMapper;
     @Value("C://file//crew/")
     private String localPath;
 
@@ -86,7 +90,7 @@ public class CollectionPaymentServiceImpl implements CollectionPaymentService {
             wrapper.and("DATE_FORMAT(receipt_payment_date,'%Y%m%d') <= DATE_FORMAT('" + selectDTO.getEndDate() + "','%Y%m%d')");
 
         }
-        wrapper.orderBy("receipt_payment_date",false);
+        wrapper.orderBy("receipt_payment_date", false);
 
         List<CollectionPaymentDO> list = collectionPaymentMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
 //        for (int i=0;i<list.size();i++){
@@ -107,6 +111,17 @@ public class CollectionPaymentServiceImpl implements CollectionPaymentService {
         insertDO.setStatus(0);
         insertDO.setPayNo(getlinkNo());
         if (collectionPaymentMapper.insert(insertDO) > 0) {
+            if ("1".equalsIgnoreCase(insertDO.getBusinessType())) {
+                // 客户已付联动
+                CustomerInfoDO customerInfoDO1 = new CustomerInfoDO();
+                customerInfoDO1.setCustomer(insertDO.getReceivingWithdrawingPeople());
+                CustomerInfoDO customerInfoDO = customerInfoMapper.selectOne(customerInfoDO1);
+                if (customerInfoDO != null) {
+                    customerInfoDO.setYiAmount(customerInfoDO.getYiAmount()+insertDO.getDeductionEuro());
+                }
+                customerInfoMapper.updateById(customerInfoDO);
+            }
+
             return insertDO;
         }
         throw new AdminServiceException(ExceptionDefinition.ADMIN_UNKNOWN_EXCEPTION);
@@ -156,7 +171,7 @@ public class CollectionPaymentServiceImpl implements CollectionPaymentService {
         CollectionPaymentDO updateDO = new CollectionPaymentDO();
         BeanUtils.copyProperties(editDTO, updateDO);
         updateDO.setGmtUpdate(now);
-        if("1".equals(editDTO.getFlag())){
+        if ("1".equals(editDTO.getFlag())) {
             updateDO.setStatus(1);
         }
 
@@ -219,8 +234,8 @@ public class CollectionPaymentServiceImpl implements CollectionPaymentService {
 
         CollectionPaymentDTO collectionPaymentDTO2 = new CollectionPaymentDTO();
         collectionPaymentDTO2.setType("jing");
-        collectionPaymentDTO2.setDeductionEurotj(shouMoneyo-fuMoneyo);
-        collectionPaymentDTO2.setDeductionRmbtj(shouMoneyrmb-fuMoneyrmb);
+        collectionPaymentDTO2.setDeductionEurotj(shouMoneyo - fuMoneyo);
+        collectionPaymentDTO2.setDeductionRmbtj(shouMoneyrmb - fuMoneyrmb);
         collectionPaymentDTOS.add(collectionPaymentDTO2);
         return collectionPaymentDTOS;
     }

+ 3 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/sys/CustomerBillingService.java

@@ -71,6 +71,9 @@ public interface CustomerBillingService {
             @HttpParam(name = "CustomerBillingDetailDTO", type = HttpParamType.COMMON, description = "CustomerBillingDetailDTO") CustomerBillingDetailDTO customerBillingDetailDTO,
             @HttpParam(name = "HttpServletResponse", type = HttpParamType.COMMON, description = "response") HttpServletResponse response) throws Exception;
 
+    @HttpMethod(description = "添加", permission = "customerBilling:customerbilling:createAll", permissionParentName = "其他", permissionName = "CustomerBilling")
+    public void createAll(
+            @HttpParam(name = "CustomerBillingInfoDTO", type = HttpParamType.COMMON, description = "CustomerBillingInfoDTO") List<CustomerBillingInfoDTO> customerBillingInfoDTOList) throws ServiceException;
 
 
 }

+ 77 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/sys/CustomerBillingServiceImpl.java

@@ -1,9 +1,12 @@
 package com.iotechn.unimall.admin.api.sys;
 
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.iotechn.unimall.core.exception.AdminServiceException;
 import com.iotechn.unimall.core.exception.ExceptionDefinition;
 import com.iotechn.unimall.core.exception.ServiceException;
+import com.iotechn.unimall.data.domain.CollectionPaymentDO;
 import com.iotechn.unimall.data.domain.CustomerBillingDetailDO;
 import com.iotechn.unimall.data.dto.CollectionPaymentDTO;
 import com.iotechn.unimall.data.dto.CollectionPaymentTiDTO;
@@ -27,8 +30,10 @@ import org.springframework.util.StringUtils;
 import tk.mybatis.mapper.util.StringUtil;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -56,6 +61,9 @@ public class CustomerBillingServiceImpl implements CustomerBillingService {
         if (!StringUtils.isEmpty(selectDTO.getPayNo())) {
             wrapper.like("pay_no", selectDTO.getPayNo());
         }
+        if (!StringUtils.isEmpty(selectDTO.getCustomer())) {
+            wrapper.eq("customer", selectDTO.getCustomer());
+        }
         if (!StringUtils.isEmpty(selectDTO.getBusinessType())) {
             wrapper.eq("business_type", selectDTO.getBusinessType());
         }
@@ -180,4 +188,73 @@ public class CustomerBillingServiceImpl implements CustomerBillingService {
     }
 
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void createAll(List<CustomerBillingInfoDTO> customerBillingInfoDTOList) throws ServiceException {
+        Date now = new Date();
+        customerBillingInfoDTOList = JSON.parseArray(JSONObject.toJSONString(customerBillingInfoDTOList), CustomerBillingInfoDTO.class);
+
+        if (!CollectionUtils.isEmpty(customerBillingInfoDTOList)) {
+            Map<String, List<CustomerBillingInfoDTO>> groupByCustomer = customerBillingInfoDTOList.stream().collect(Collectors.groupingBy(CustomerBillingInfoDTO::getCustomer));
+            for(String key :groupByCustomer.keySet()){
+                CustomerBillingInfoDO customerBillingInfoDO = new CustomerBillingInfoDO();
+                customerBillingInfoDO.setCustomer(key);
+                customerBillingInfoDO.setBusinessType("1");
+                customerBillingInfoDO.setStatus(1);
+                customerBillingInfoDO.setPayNo(getlinkNo());
+                customerBillingInfoDO.setGmtUpdate(now);
+                customerBillingInfoDO.setGmtCreate(now);
+                List<CustomerBillingInfoDTO> customerBillingInfoDTOS = groupByCustomer.get(key);
+                customerBillingInfoDO.setClosingDate(customerBillingInfoDTOS.get(0).getClosingDate());
+                Double amount = 0d;
+                if (customerBillingInfoMapper.insert(customerBillingInfoDO) > 0) {
+//                Double cost = 0d;
+                    for (int i = 0; i < customerBillingInfoDTOS.size(); i++) {
+                        CustomerBillingInfoDTO customerBillingInfoDTO = customerBillingInfoDTOS.get(i);
+                        CustomerBillingDetailDO customerBillingDetailDO = new CustomerBillingDetailDO();
+                        customerBillingDetailDO.setInfoId(customerBillingInfoDO.getId());
+                        customerBillingDetailDO.setCabinetNo(customerBillingInfoDTO.getCabinetNo());
+                        customerBillingDetailDO.setArrivalDate(customerBillingInfoDTO.getArrivalDate());
+                        customerBillingDetailDO.setSendComp(customerBillingInfoDTO.getSendComp());
+                        customerBillingDetailDO.setCarTeam(customerBillingInfoDTO.getCarTeam());
+                        customerBillingDetailDO.setProduct(customerBillingInfoDTO.getProduct());
+                        customerBillingDetailDO.setDeliveryPlace(customerBillingInfoDTO.getDeliveryPlace());
+                        customerBillingDetailDO.setClearanceFee(customerBillingInfoDTO.getClearanceFee());
+                        customerBillingDetailDO.setClearanceCost(customerBillingInfoDTO.getClearanceCost());
+                        customerBillingDetailDO.setTruck(customerBillingInfoDTO.getTruck());
+                        customerBillingDetailDO.setTruckCost(customerBillingInfoDTO.getTruckCost());
+                        customerBillingDetailDO.setOtherExpenses(customerBillingInfoDTO.getOtherExpenses());
+                        customerBillingDetailDO.setOtherCost(customerBillingInfoDTO.getOtherCost());
+                        customerBillingDetailDO.setPricePayable((customerBillingInfoDTO.getClearanceFee()!=null?customerBillingInfoDTO.getClearanceFee():0) + (customerBillingInfoDTO.getTruck()!=null?customerBillingInfoDTO.getTruck():0)  + (customerBillingInfoDTO.getOtherExpenses()!=null?customerBillingInfoDTO.getOtherExpenses():0));
+                        amount = amount + customerBillingDetailDO.getPricePayable();
+                        customerBillingDetailDO.setCost((customerBillingInfoDTO.getClearanceCost()!=null?customerBillingInfoDTO.getClearanceCost():0) + (customerBillingInfoDTO.getTruckCost()!=null?customerBillingInfoDTO.getTruckCost():0) + (customerBillingInfoDTO.getOtherCost()!=null?customerBillingInfoDTO.getOtherCost():0));
+//                    cost =cost+customerBillingDetailDO.getCost();
+                        customerBillingDetailDO.setGmtUpdate(now);
+                        customerBillingDetailDO.setGmtCreate(now);
+                        customerBillingDetailMapper.insert(customerBillingDetailDO);
+                    }
+                }
+                customerBillingInfoDO.setAmountIng(amount);
+                customerBillingInfoMapper.updateById(customerBillingInfoDO);
+            }
+        }
+    }
+
+
+    public String getlinkNo() {
+        String linkNo = "";
+        // 用字符数组的方式随机
+        String model = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+        char[] m = model.toCharArray();
+        for (int j = 0; j < 6; j++) {
+            char c = m[(int) (Math.random() * 36)];
+            // 保证六位随机数之间没有重复的
+            if (linkNo.contains(String.valueOf(c))) {
+                j--;
+                continue;
+            }
+            linkNo = linkNo + c;
+        }
+        return linkNo;
+    }
 }

+ 7 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/sys/CustomerInfoService.java

@@ -10,6 +10,8 @@ import com.iotechn.unimall.data.model.Page;
 import com.iotechn.unimall.data.domain.CustomerInfoDO;
 import com.iotechn.unimall.data.dto.CustomerInfoDTO;
 
+import java.util.List;
+
 /**
  * Generate Code By Unimall
  */
@@ -29,6 +31,11 @@ public interface CustomerInfoService {
             @HttpParam(name = "limit", type = HttpParamType.COMMON, description = "页码长度", valueDef = "20") Integer limit,
             @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;
 
+
+    @HttpMethod(description = "客户下拉查询", permission = "customerInfo:customerinfo:customerList", permissionParentName = "其他", permissionName = "CustomerInfo")
+    public List<CustomerInfoDO> customerList() throws ServiceException;
+
+
     @HttpMethod(description = "添加", permission = "customerInfo:customerinfo:create", permissionParentName = "其他", permissionName = "CustomerInfo")
     public CustomerInfoDO create(
             @HttpParam(name = "CustomerInfoDTO", type = HttpParamType.COMMON, description = "CustomerInfoDTO") CustomerInfoDTO insertDTO,

+ 36 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/sys/CustomerInfoServiceImpl.java

@@ -4,17 +4,23 @@ package com.iotechn.unimall.admin.api.sys;
 import com.iotechn.unimall.core.exception.AdminServiceException;
 import com.iotechn.unimall.core.exception.ExceptionDefinition;
 import com.iotechn.unimall.core.exception.ServiceException;
+import com.iotechn.unimall.data.domain.CustomerBillingInfoDO;
+import com.iotechn.unimall.data.mapper.CustomerBillingInfoMapper;
 import com.iotechn.unimall.data.model.Page;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.iotechn.unimall.data.domain.CustomerInfoDO;
 import com.iotechn.unimall.data.dto.CustomerInfoDTO;
 import com.iotechn.unimall.data.mapper.CustomerInfoMapper;
+import jodd.util.CollectionUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.apache.ibatis.session.RowBounds;
 import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -26,6 +32,8 @@ public class CustomerInfoServiceImpl implements CustomerInfoService {
 
     @Autowired
     private CustomerInfoMapper customerInfoMapper;
+    @Autowired
+    private CustomerBillingInfoMapper customerBillingInfoMapper;
 
     @Override
     public boolean delete(Long id,  Long adminId) throws ServiceException {
@@ -36,9 +44,37 @@ public class CustomerInfoServiceImpl implements CustomerInfoService {
     public Page<CustomerInfoDO> list(CustomerInfoDTO selectDTO, Integer page, Integer limit, Long adminId) throws ServiceException {
         Wrapper<CustomerInfoDO> wrapper = new EntityWrapper<CustomerInfoDO>();
         List<CustomerInfoDO> list = customerInfoMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
+        if(!CollectionUtils.isEmpty(list)){
+            for(CustomerInfoDO customerInfoDO : list){
+                // 查询客户账单
+                Wrapper<CustomerBillingInfoDO> wrapper1 = new EntityWrapper<CustomerBillingInfoDO>();
+                wrapper1.eq("customer",customerInfoDO.getCustomer());
+                List<CustomerBillingInfoDO> customerBillingInfoDOS = customerBillingInfoMapper.selectList(wrapper1);
+                double sum = 0d;
+                if(!CollectionUtils.isEmpty(customerBillingInfoDOS)){
+                    for(int i=0;i<customerBillingInfoDOS.size();i++){
+                        sum +=customerBillingInfoDOS.get(i).getAmountIng();
+                    }
+
+                }
+                customerInfoDO.setAmountPayable(sum);
+                customerInfoDO.setUnpaidAmount(customerInfoDO.getYiAmount()-sum);
+
+            }
+
+
+        }
         Integer count = customerInfoMapper.selectCount(wrapper);
         return new Page<CustomerInfoDO>(list, page, limit, count);
     }
+    @Override
+    public List<CustomerInfoDO> customerList() throws ServiceException {
+        Wrapper<CustomerInfoDO> wrapper = new EntityWrapper<CustomerInfoDO>();
+        wrapper.orderBy("gmt_create");
+        List<CustomerInfoDO> list = customerInfoMapper.selectList(wrapper);
+        Integer count = customerInfoMapper.selectCount(wrapper);
+        return list;
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)

+ 8 - 0
unimall-data/src/main/java/com/iotechn/unimall/data/domain/CustomerBillingDetailDO.java

@@ -3,6 +3,8 @@ package com.iotechn.unimall.data.domain;
 import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableName;
 import java.util.Date;
+
+import com.iotechn.unimall.core.framework.aspectj.lang.annotaion.Excel;
 import lombok.Data;
 
 /**
@@ -24,6 +26,12 @@ public class CustomerBillingDetailDO extends SuperDO {
      /* 到港日期 */
     @TableField("arrival_date")
     private String arrivalDate;
+    /* 发货公司 */
+    @TableField("send_comp")
+    private String sendComp;
+    /* 车队 */
+    @TableField("car_team")
+    private String carTeam;
      /* 送货地点 */
     @TableField("delivery_place")
     private String deliveryPlace;

+ 6 - 0
unimall-data/src/main/java/com/iotechn/unimall/data/domain/CustomerInfoDO.java

@@ -21,6 +21,12 @@ public class CustomerInfoDO extends SuperDO {
      /* 账户余额 */
     @TableField("unpaid_amount")
     private Double unpaidAmount;
+    /* 应付金额 */
+    @TableField(exist = false)
+    private Double amountPayable;
+    /* 已付金额 */
+    @TableField(exist = false)
+    private Double yiAmount;
      /* 备注 */
     @TableField("remarks")
     private String remarks;

+ 8 - 2
unimall-data/src/main/java/com/iotechn/unimall/data/dto/CustomerBillingDetailDTO.java

@@ -38,11 +38,17 @@ public class CustomerBillingDetailDTO extends SuperDTO {
      /* 到港日期 */
      @Excel(name = "到港日期")
     private String arrivalDate;
+    /* 发货公司 */
+    @Excel(name = "发货公司")
+    private String sendComp;
+    /* 车队 */
+    @Excel(name = "车队")
+    private String carTeam;
      /* 送货地点 */
-     @Excel(name = "送货地点")
+     @Excel(name = "目的地")
     private String deliveryPlace;
      /* 产品 */
-     @Excel(name = "产品")
+     @Excel(name = "品")
     private String product;
      /* 重量 */
      @Excel(name = "重量")

+ 27 - 2
unimall-data/src/main/java/com/iotechn/unimall/data/dto/CustomerBillingInfoDTO.java

@@ -32,7 +32,7 @@ public class CustomerBillingInfoDTO extends SuperDTO {
      @Excel(name = "单据类型")
     private String businessType;
      /* 结账日期 */
-     @Excel(name = "结账日期")
+     @Excel(name = "装车日期")
     private String closingDate;
     /*应付金额 */
     @Excel(name = "应付金额")
@@ -50,7 +50,7 @@ public class CustomerBillingInfoDTO extends SuperDTO {
      @Excel(name = "备注2")
     private String remark;
      /* 状态 */
-     @Excel(name = "状态",readConverterExp = "1=未付款,2=部分付款,2=已付款")
+     @Excel(name = "状态",readConverterExp = "1=未付款,2=部分付款,3=已付款")
     private Integer status;
      /* gmtCreate */
     private Date gmtCreate;
@@ -72,4 +72,29 @@ public class CustomerBillingInfoDTO extends SuperDTO {
     @JsonFormat(pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     private String endDate;
+
+    /* 柜号 */
+    private String cabinetNo;
+    /* 到港日期 */
+    private String arrivalDate;
+    /* 产品 */
+    private String product;
+    /* 发货公司 */
+    private String sendComp;
+    /* 车队 */
+    private String carTeam;
+    /* 送货地点 */
+    private String deliveryPlace;
+    /* 清关费 */
+    private Double clearanceFee;
+    /* 清关成本 */
+    private Double clearanceCost;
+    /* 卡车 */
+    private Double truck;
+    /* 卡车成本 */
+    private Double truckCost;
+    /* 其他费用 */
+    private Double otherExpenses;
+    /* 其他成本 */
+    private Double otherCost;
 }

+ 5 - 1
unimall-data/src/main/java/com/iotechn/unimall/data/dto/CustomerInfoDTO.java

@@ -15,8 +15,12 @@ public class CustomerInfoDTO extends SuperDTO {
     private Long id;
      /* 客户 */
     private String customer;
-     /* 账户余额 */
+    /* 应付金额 */
+    private Double amountPayable;
+     /* 已付金额 */
     private Double unpaidAmount;
+     /* 已付金额 */
+    private Double yiAmount;
      /* 备注 */
     private String remarks;
      /* 状态 */