diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java index 4a8c1534..3ebb5283 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java @@ -1,18 +1,30 @@ package com.ghy.web.controller.customer; +import com.ghy.common.adapay.model.AnalyseItemEnum; 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.utils.ExceptionUtil; import com.ghy.customer.domain.Customer; import com.ghy.customer.service.CustomerService; +import com.ghy.order.domain.OrderMaster; +import com.ghy.order.service.OrderMasterService; +import com.ghy.payment.domain.FinancialMaster; +import com.ghy.payment.service.FinancialMasterService; +import com.ghy.web.pojo.vo.AnalyseItem; +import com.ghy.web.pojo.vo.CustomerPlaceMember; +import org.apache.commons.collections.CollectionUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @author clunt @@ -27,6 +39,12 @@ public class CustomerController extends BaseController { @Autowired private CustomerService customerService; + @Autowired + private FinancialMasterService financialMasterService; + + @Autowired + private OrderMasterService orderMasterService; + @RequiresPermissions("customer:customer:view") @GetMapping() public String customer() @@ -48,9 +66,88 @@ public class CustomerController extends BaseController { @ResponseBody public TableDataInfo appList(@RequestBody Customer customer) { + List response = new ArrayList(); startPage(); List list = customerService.getCustomerList(customer); - return getDataTable(list); + for (Customer curCustomer: list) { + // 本月第一天 + LocalDate firstDayCurMonth = LocalDate.now().withDayOfMonth(1); + + List analyseItems = new ArrayList(); + // 客户数 + Customer customerParams = new Customer(); + customerParams.setCustomerPlace(curCustomer.getCustomerId()); + AnalyseItem aItem1 = new AnalyseItem() + .setTitle(AnalyseItemEnum.CUSTOMER_NUM.getTitle()) + .setUnit(AnalyseItemEnum.CUSTOMER_NUM.getUnit()) + .setValue(customerService.countCustomer(customerParams)); + analyseItems.add(aItem1); + // 本月绑定客户数 + customerParams.setUpdateTimeStart(firstDayCurMonth.atStartOfDay()); + AnalyseItem aItem2 = new AnalyseItem() + .setTitle(AnalyseItemEnum.CUSTOMER_NUM_CUR_MONTH.getTitle()) + .setUnit(AnalyseItemEnum.CUSTOMER_NUM_CUR_MONTH.getUnit()) + .setValue(customerService.countCustomer(customerParams)); + analyseItems.add(aItem2); + + // 本月订单数及本月订单额 + OrderMaster orderParams1 = new OrderMaster(); + orderParams1.setCustomerId(curCustomer.getCustomerId()); + orderParams1.setCreateTimeStart(firstDayCurMonth.atStartOfDay()); + List ordersCurMonth1 = orderMasterService.selectOrderMasterList(orderParams1); + List 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); + List financialsCurMonth1 = financialMasterService.selectFinancialMasterList(financialParams1); + totalMoneyCurMonth1 = financialsCurMonth1.stream().map(FinancialMaster::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + } + AnalyseItem aItem3 = new AnalyseItem() + .setTitle(AnalyseItemEnum.ORDER_NUM_CUR_MONTH.getTitle()) + .setUnit(AnalyseItemEnum.ORDER_NUM_CUR_MONTH.getUnit()) + .setValue(ordersCurMonth1 != null ? ordersCurMonth1.size() : 0); + AnalyseItem aItem4 = new AnalyseItem() + .setTitle(AnalyseItemEnum.ORDER_TRADE_VOLUME_CUR_MONTH.getTitle()) + .setUnit(AnalyseItemEnum.ORDER_TRADE_VOLUME_CUR_MONTH.getUnit()) + .setValue(totalMoneyCurMonth1); + analyseItems.add(aItem3); + analyseItems.add(aItem4); + + // 上月订单数及上月订单额 + OrderMaster orderParams2 = new OrderMaster(); + orderParams2.setCustomerId(curCustomer.getCustomerId()); + orderParams2.setCreateTimeStart(firstDayCurMonth.atStartOfDay().minusMonths(1)); + orderParams2.setCreateTimeEnd(firstDayCurMonth.atStartOfDay()); + List ordersCurMonth2 = orderMasterService.selectOrderMasterList(orderParams2); + List orderIdsCurMonth2 = ordersCurMonth2.stream().map(OrderMaster::getId).collect(Collectors.toList()); + BigDecimal totalMoneyCurMonth2 = new BigDecimal(0); + if (CollectionUtils.isNotEmpty(orderIdsCurMonth2)) { + FinancialMaster financialParams2 = new FinancialMaster(); + financialParams2.setIds(orderIdsCurMonth2); + List financialsCurMonth2 = financialMasterService.selectFinancialMasterList(financialParams2); + totalMoneyCurMonth2 = financialsCurMonth2.stream().map(FinancialMaster::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + } + AnalyseItem aItem5 = new AnalyseItem() + .setTitle(AnalyseItemEnum.ORDER_NUM_CUR_MONTH.getTitle()) + .setUnit(AnalyseItemEnum.ORDER_NUM_CUR_MONTH.getUnit()) + .setValue(ordersCurMonth2 != null ? ordersCurMonth2.size() : 0); + AnalyseItem aItem6 = new AnalyseItem() + .setTitle(AnalyseItemEnum.ORDER_TRADE_VOLUME_CUR_MONTH.getTitle()) + .setUnit(AnalyseItemEnum.ORDER_TRADE_VOLUME_CUR_MONTH.getUnit()) + .setValue(totalMoneyCurMonth2); + analyseItems.add(aItem5); + analyseItems.add(aItem6); + + CustomerPlaceMember customerPlaceMember = new CustomerPlaceMember(); + customerPlaceMember.setAnalyseItems(analyseItems); + customerPlaceMember.setCustomerId(curCustomer.getCustomerId()); + customerPlaceMember.setName(curCustomer.getName()); + customerPlaceMember.setPhone(curCustomer.getPhone()); + response.add(customerPlaceMember); + } + + return getDataTable(response); } @RequiresPermissions("customer:customer:resetPwd") diff --git a/ghy-admin/src/main/java/com/ghy/web/pojo/vo/AnalyseItem.java b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/AnalyseItem.java new file mode 100644 index 00000000..13cdbaa1 --- /dev/null +++ b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/AnalyseItem.java @@ -0,0 +1,38 @@ +package com.ghy.web.pojo.vo; + +/** + * @author ydq + * @date : 2022-08-15 17:33 + */ +public class AnalyseItem { + private String title; + private Object value; + private String unit; + + public String getTitle() { + return title; + } + + public AnalyseItem setTitle(String title) { + this.title = title; + return this; + } + + public Object getValue() { + return value; + } + + public AnalyseItem setValue(Object value) { + this.value = value; + return this; + } + + public String getUnit() { + return unit; + } + + public AnalyseItem setUnit(String unit) { + this.unit = unit; + return this; + } +} diff --git a/ghy-admin/src/main/java/com/ghy/web/pojo/vo/CustomerPlaceMember.java b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/CustomerPlaceMember.java new file mode 100644 index 00000000..e5037909 --- /dev/null +++ b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/CustomerPlaceMember.java @@ -0,0 +1,15 @@ +package com.ghy.web.pojo.vo; + +import com.ghy.customer.domain.Customer; +import lombok.Data; + +import java.util.List; + +/** + * @author ydq + * @date : 2022-08-16 21:38 + */ +@Data +public class CustomerPlaceMember extends Customer { + private List analyseItems; +} diff --git a/ghy-common/src/main/java/com/ghy/common/adapay/model/AnalyseItemEnum.java b/ghy-common/src/main/java/com/ghy/common/adapay/model/AnalyseItemEnum.java new file mode 100644 index 00000000..84dff07c --- /dev/null +++ b/ghy-common/src/main/java/com/ghy/common/adapay/model/AnalyseItemEnum.java @@ -0,0 +1,30 @@ +package com.ghy.common.adapay.model; + +/** + * @author ydq + * @date : 2022-08-15 16:37 + */ +public enum AnalyseItemEnum { + CUSTOMER_NUM("客户数", ""), + CUSTOMER_NUM_CUR_MONTH("本月绑定", ""), + ORDER_NUM_CUR_MONTH("本月订单数", "单"), + ORDER_TRADE_VOLUME_CUR_MONTH("本月订单额", "yuan"), + ORDER_NUM_LAST_MONTH("上月订单数", "单"), + ORDER_TRADE_VOLUME_LAST_MONTH("上月订单额", "yuan"); + + private String title; + private String unit; + + AnalyseItemEnum(String title, String unit) { + this.title = title; + this.unit = unit; + } + + public String getTitle() { + return title; + } + + public String getUnit() { + return unit; + } +} diff --git a/ghy-common/src/main/java/com/ghy/common/core/domain/BaseEntity.java b/ghy-common/src/main/java/com/ghy/common/core/domain/BaseEntity.java index f845d5fc..55049ed5 100644 --- a/ghy-common/src/main/java/com/ghy/common/core/domain/BaseEntity.java +++ b/ghy-common/src/main/java/com/ghy/common/core/domain/BaseEntity.java @@ -1,6 +1,7 @@ package com.ghy.common.core.domain; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -8,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; /** * Entity基类 - * + * * @author clunt */ public class BaseEntity implements Serializable @@ -38,6 +39,14 @@ public class BaseEntity implements Serializable /** 请求参数 */ private Map params; + private LocalDateTime updateTimeStart; + + private LocalDateTime updateTimeEnd; + + private LocalDateTime createTimeStart; + + private LocalDateTime createTimeEnd; + public String getSearchValue() { return searchValue; @@ -111,4 +120,36 @@ public class BaseEntity implements Serializable { this.params = params; } + + public LocalDateTime getUpdateTimeStart() { + return updateTimeStart; + } + + public void setUpdateTimeStart(LocalDateTime updateTimeStart) { + this.updateTimeStart = updateTimeStart; + } + + public LocalDateTime getUpdateTimeEnd() { + return updateTimeEnd; + } + + public void setUpdateTimeEnd(LocalDateTime updateTimeEnd) { + this.updateTimeEnd = updateTimeEnd; + } + + public LocalDateTime getCreateTimeStart() { + return createTimeStart; + } + + public void setCreateTimeStart(LocalDateTime createTimeStart) { + this.createTimeStart = createTimeStart; + } + + public LocalDateTime getCreateTimeEnd() { + return createTimeEnd; + } + + public void setCreateTimeEnd(LocalDateTime createTimeEnd) { + this.createTimeEnd = createTimeEnd; + } } diff --git a/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerMapper.java b/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerMapper.java index e626f248..80d12dfe 100644 --- a/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerMapper.java +++ b/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerMapper.java @@ -17,6 +17,12 @@ public interface CustomerMapper { */ List getCustomerList(Customer customer); + /** + * @param customer 消费者筛选条件 + * @return 符合结果消费者计数 + */ + Long countCustomer(Customer customer); + /** * @param customerId 消费者id * @return 消费者信息 @@ -55,4 +61,4 @@ public interface CustomerMapper { */ List getByCustomerIdList(@Param("customerIdList") List customerIdList); -} \ No newline at end of file +} diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/CustomerService.java b/ghy-custom/src/main/java/com/ghy/customer/service/CustomerService.java index 085d9d11..314d34be 100644 --- a/ghy-custom/src/main/java/com/ghy/customer/service/CustomerService.java +++ b/ghy-custom/src/main/java/com/ghy/customer/service/CustomerService.java @@ -23,6 +23,12 @@ public interface CustomerService { */ List getCustomerList(Customer customer); + /** + * @param customer 消费者筛选条件 + * @return 符合结果消费者计数 + */ + Long countCustomer(Customer customer); + /** * @param customerId 消费者id * @return 消费者信息 diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java index 9b00b54a..d14a9538 100644 --- a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java +++ b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerServiceImpl.java @@ -33,6 +33,11 @@ public class CustomerServiceImpl implements CustomerService { return customerMapper.getCustomerList(customer); } + @Override + public Long countCustomer(Customer customer) { + return customerMapper.countCustomer(customer); + } + @Override public Customer selectByOpenId(Customer customer) { List list = customerMapper.getCustomerList(customer); diff --git a/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml b/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml index be793c63..d5996ee8 100644 --- a/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml +++ b/ghy-custom/src/main/resources/mapper/customer/CustomerMapper.xml @@ -27,6 +27,11 @@ FROM customer + + SELECT COUNT(*) + FROM customer + + + + DELETE FROM customer WHERE customer_id IN diff --git a/ghy-order/src/main/resources/mapper/order/OrderMasterMapper.xml b/ghy-order/src/main/resources/mapper/order/OrderMasterMapper.xml index 19b173e8..be3c824c 100644 --- a/ghy-order/src/main/resources/mapper/order/OrderMasterMapper.xml +++ b/ghy-order/src/main/resources/mapper/order/OrderMasterMapper.xml @@ -113,6 +113,12 @@ AND om.order_status != #{exceptOrderStatus} + + AND om.create_time >= #{createTimeStart} + + + AND om.create_time < #{createTimeEnd} + order by om.create_time diff --git a/ghy-payment/src/main/java/com/ghy/payment/domain/FinancialMaster.java b/ghy-payment/src/main/java/com/ghy/payment/domain/FinancialMaster.java index 2d932cbf..a02d622a 100644 --- a/ghy-payment/src/main/java/com/ghy/payment/domain/FinancialMaster.java +++ b/ghy-payment/src/main/java/com/ghy/payment/domain/FinancialMaster.java @@ -7,6 +7,7 @@ import lombok.Data; import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** * @author clunt @@ -54,6 +55,8 @@ public class FinancialMaster extends BaseEntity { @Excel(name = "Adapay的唯一支付ID", cellType = Excel.ColumnType.STRING) private String paymentId; + private List ids; + public FinancialMaster() { } diff --git a/ghy-payment/src/main/resources/mapper/financial/FinancialMasterMapper.xml b/ghy-payment/src/main/resources/mapper/financial/FinancialMasterMapper.xml index 17a2715c..16e3ad21 100644 --- a/ghy-payment/src/main/resources/mapper/financial/FinancialMasterMapper.xml +++ b/ghy-payment/src/main/resources/mapper/financial/FinancialMasterMapper.xml @@ -36,6 +36,12 @@ AND order_master_id = #{orderMasterId} + + AND order_master_id IN + + #{id} + + AND order_master_code LIKE concat('%', #{orderMasterCode}, '%') @@ -92,7 +98,7 @@ AND order_master_code = #{orderMasterCode} - + @@ -133,4 +139,4 @@ ) - \ No newline at end of file + diff --git a/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerTeam.java b/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerTeam.java index f153611c..1c82ca6a 100644 --- a/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerTeam.java +++ b/ghy-worker/src/main/java/com/ghy/worker/domain/WorkerTeam.java @@ -31,4 +31,8 @@ public class WorkerTeam extends BaseEntity { private String workerLogoUrl; + private Integer workerStatus; + + private Boolean hasRegistered; + } diff --git a/ghy-worker/src/main/resources/mapper/worker/WorkerTeamMapper.xml b/ghy-worker/src/main/resources/mapper/worker/WorkerTeamMapper.xml index a8e393cf..31ab2471 100644 --- a/ghy-worker/src/main/resources/mapper/worker/WorkerTeamMapper.xml +++ b/ghy-worker/src/main/resources/mapper/worker/WorkerTeamMapper.xml @@ -10,6 +10,7 @@ + @@ -37,17 +38,26 @@ - SELECT wt.worker_team_id, wt.leader_id, wt.worker_name, wt.worker_id, w.phone, w.name, w.worker_logo_url + SELECT wt.worker_team_id, wt.leader_id, wt.worker_name, wt.worker_id, w.phone, w.name, w.worker_logo_url, w.status as worker_status FROM worker_team wt left join worker w on wt.worker_id = w.worker_id - AND wt.leader_id = #{leaderId} + + AND wt.worker_id = #{workerId} + + + AND w.status = #{workerStatus} + + + AND w.phone IS NOT NULL +