浏览代码

客户统计

gongdecai 3 年之前
父节点
当前提交
72120034bd

+ 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;
     }

+ 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)

+ 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;

+ 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;
      /* 状态 */