分销列表查询修改`

This commit is contained in:
donqi 2022-11-16 01:58:58 +08:00
parent 1c4c3f66f3
commit 7856cdb5fd
7 changed files with 50 additions and 10 deletions

View File

@ -5,6 +5,7 @@ import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.enums.PlaceStatus;
import com.ghy.common.enums.UserStatus;
import com.ghy.common.utils.ExceptionUtil;
import com.ghy.customer.domain.Customer;
import com.ghy.customer.service.CustomerService;
@ -71,6 +72,19 @@ public class CustomerController extends BaseController {
startPage();
List<Customer> list = customerService.getCustomerList(customer);
for (Customer curCustomer: list) {
List<Long> customerIds = new ArrayList<Long>(){{
add(curCustomer.getCustomerId());
}};
if (customer.getIsDistributor()) {
// 分销商需要查询所有下一级分销用户作为统计条件
Customer customerQry = new Customer();
customerQry.setCustomerPlace(curCustomer.getCustomerId());
customerQry.setStatus(Integer.valueOf(UserStatus.OK.getCode()));
List<Customer> nextLevelCustomers = customerService.getCustomerList(customerQry);
List<Long> nextLevelCustomerIds = nextLevelCustomers.stream().map(Customer::getCustomerId).collect(Collectors.toList());
customerIds.addAll(nextLevelCustomerIds);
}
// 本月第一天
LocalDate firstDayCurMonth = LocalDate.now().withDayOfMonth(1);
// 今天
@ -81,7 +95,7 @@ public class CustomerController extends BaseController {
List<AnalyseItem> analyseItems = new ArrayList<AnalyseItem>();
// 客户数
Customer customerParams = new Customer();
customerParams.setCustomerPlace(curCustomer.getCustomerId());
customerParams.setCustomerPlaces(customerIds);
AnalyseItem aItem1 = new AnalyseItem()
.setType(AnalyseItemEnum.CUSTOMER_NUM.getType())
.setTitle(AnalyseItemEnum.CUSTOMER_NUM.getTitle())
@ -113,14 +127,14 @@ public class CustomerController extends BaseController {
// 本月订单数及本月订单额
OrderMaster orderParams1 = new OrderMaster();
orderParams1.setCustomerId(curCustomer.getCustomerId());
orderParams1.setCustomerIds(customerIds);
orderParams1.setCreateTimeStart(firstDayCurMonth.atStartOfDay());
List<OrderMaster> ordersCurMonth1 = orderMasterService.selectOrderMasterList(orderParams1);
List<Long> orderIdsCurMonth1 = ordersCurMonth1.stream().map(OrderMaster::getId).collect(Collectors.toList());
BigDecimal totalMoneyCurMonth1 = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(orderIdsCurMonth1)) {
FinancialMaster financialParams1 = new FinancialMaster();
financialParams1.setIds(orderIdsCurMonth1);
financialParams1.setOrderMasterIds(orderIdsCurMonth1);
List<FinancialMaster> financialsCurMonth1 = financialMasterService.selectFinancialMasterList(financialParams1);
totalMoneyCurMonth1 = financialsCurMonth1.stream().map(FinancialMaster::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
}
@ -139,7 +153,7 @@ public class CustomerController extends BaseController {
// 上月订单数及上月订单额
OrderMaster orderParams2 = new OrderMaster();
orderParams2.setCustomerId(curCustomer.getCustomerId());
orderParams2.setCustomerIds(customerIds);
orderParams2.setCreateTimeStart(firstDayCurMonth.atStartOfDay().minusMonths(1));
orderParams2.setCreateTimeEnd(firstDayCurMonth.atStartOfDay());
List<OrderMaster> ordersCurMonth2 = orderMasterService.selectOrderMasterList(orderParams2);
@ -147,7 +161,7 @@ public class CustomerController extends BaseController {
BigDecimal totalMoneyCurMonth2 = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(orderIdsCurMonth2)) {
FinancialMaster financialParams2 = new FinancialMaster();
financialParams2.setIds(orderIdsCurMonth2);
financialParams2.setOrderMasterIds(orderIdsCurMonth2);
List<FinancialMaster> financialsCurMonth2 = financialMasterService.selectFinancialMasterList(financialParams2);
totalMoneyCurMonth2 = financialsCurMonth2.stream().map(FinancialMaster::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
}
@ -166,14 +180,14 @@ public class CustomerController extends BaseController {
// 当天订单数及当天订单额
OrderMaster orderParams3 = new OrderMaster();
orderParams3.setCustomerId(curCustomer.getCustomerId());
orderParams3.setCustomerIds(customerIds);
orderParams3.setCreateTimeStart(curDay.atStartOfDay());
List<OrderMaster> ordersCurDay = orderMasterService.selectOrderMasterList(orderParams3);
List<Long> orderIdsCurDay = ordersCurDay.stream().map(OrderMaster::getId).collect(Collectors.toList());
BigDecimal totalMoneyCurDay = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(orderIdsCurDay)) {
FinancialMaster financialParams3 = new FinancialMaster();
financialParams3.setIds(orderIdsCurDay);
financialParams3.setOrderMasterIds(orderIdsCurDay);
List<FinancialMaster> financialsCurDay = financialMasterService.selectFinancialMasterList(financialParams3);
totalMoneyCurDay = financialsCurDay.stream().map(FinancialMaster::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
}
@ -192,14 +206,14 @@ public class CustomerController extends BaseController {
// 7天订单数及7天订单额
OrderMaster orderParams4 = new OrderMaster();
orderParams4.setCustomerId(curCustomer.getCustomerId());
orderParams4.setCustomerIds(customerIds);
orderParams4.setCreateTimeStart(firstDayCurWeek.atStartOfDay());
List<OrderMaster> ordersCurWeek = orderMasterService.selectOrderMasterList(orderParams3);
List<Long> orderIdsCurWeek = ordersCurWeek.stream().map(OrderMaster::getId).collect(Collectors.toList());
BigDecimal totalMoneyCurWeek = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(orderIdsCurWeek)) {
FinancialMaster financialParams4 = new FinancialMaster();
financialParams4.setIds(orderIdsCurWeek);
financialParams4.setOrderMasterIds(orderIdsCurWeek);
List<FinancialMaster> financialsCurWeek = financialMasterService.selectFinancialMasterList(financialParams4);
totalMoneyCurWeek = financialsCurWeek.stream().map(FinancialMaster::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
}

View File

@ -47,4 +47,8 @@ public class Customer extends BaseEntity {
private Integer placeStatus;
// 是否为分销商
private Boolean isDistributor;
private List<Long> customerPlaces;
}

View File

@ -56,8 +56,14 @@
<if test="customerPlace != null and customerPlace != ''">
AND customer_place = #{customerPlace}
</if>
<if test="customerPlaces != null and customerPlaces.size > 0">
AND customer_place in
<foreach item="customerPlace" collection="customerPlaces" open="(" separator="," close=")">
#{customerPlace}
</foreach>
</if>
<if test="updateTimeStart != null">
AND update_time &lt;= #{updateTimeStart}
AND update_time &gt;= #{updateTimeStart}
</if>
</where>
</select>

View File

@ -89,4 +89,6 @@ public class OrderMaster extends BaseEntity {
private Boolean isMonitoredOrder;
private Integer allSelfAssigned;
private List<Long> customerIds;
}

View File

@ -89,6 +89,12 @@
<if test="customerId != null and customerId != 0">
AND om.customer_id = #{customerId}
</if>
<if test="customerIds != null and customerIds.size > 0">
AND om.customer_id in
<foreach item="customerId" collection="customerIds" open="(" separator="," close=")">
#{customerId}
</foreach>
</if>
<if test="orderType != null">
AND om.order_type = #{orderType}
</if>

View File

@ -68,6 +68,8 @@ public class FinancialMaster extends BaseEntity {
private List<FinancialDetail> details;
private List<Long> orderMasterIds;
public FinancialMaster() {
}

View File

@ -37,6 +37,12 @@
<if test="orderMasterId != null and orderMasterId != 0">
AND order_master_id = #{orderMasterId}
</if>
<if test="orderMasterIds != null and orderMasterIds.size > 0">
AND order_master_id IN
<foreach collection="orderMasterIds" item="orderMasterId" open="(" separator="," close=")">
#{orderMasterId}
</foreach>
</if>
<if test="ids != null and ids != ''">
AND order_master_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">