分销团队列表查询接口补充查询内容;师傅端师傅团队问题修复

This commit is contained in:
donqi 2022-08-16 23:00:46 +08:00
parent 5c2c31fb7b
commit 0d6a5a43e7
14 changed files with 294 additions and 7 deletions

View File

@ -1,18 +1,30 @@
package com.ghy.web.controller.customer; 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.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.page.TableDataInfo; import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.utils.ExceptionUtil; import com.ghy.common.utils.ExceptionUtil;
import com.ghy.customer.domain.Customer; import com.ghy.customer.domain.Customer;
import com.ghy.customer.service.CustomerService; 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.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*; 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.List;
import java.util.stream.Collectors;
/** /**
* @author clunt * @author clunt
@ -27,6 +39,12 @@ public class CustomerController extends BaseController {
@Autowired @Autowired
private CustomerService customerService; private CustomerService customerService;
@Autowired
private FinancialMasterService financialMasterService;
@Autowired
private OrderMasterService orderMasterService;
@RequiresPermissions("customer:customer:view") @RequiresPermissions("customer:customer:view")
@GetMapping() @GetMapping()
public String customer() public String customer()
@ -48,9 +66,88 @@ public class CustomerController extends BaseController {
@ResponseBody @ResponseBody
public TableDataInfo appList(@RequestBody Customer customer) public TableDataInfo appList(@RequestBody Customer customer)
{ {
List<CustomerPlaceMember> response = new ArrayList<CustomerPlaceMember>();
startPage(); startPage();
List<Customer> list = customerService.getCustomerList(customer); List<Customer> list = customerService.getCustomerList(customer);
return getDataTable(list); for (Customer curCustomer: list) {
// 本月第一天
LocalDate firstDayCurMonth = LocalDate.now().withDayOfMonth(1);
List<AnalyseItem> analyseItems = new ArrayList<AnalyseItem>();
// 客户数
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<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);
List<FinancialMaster> 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<OrderMaster> ordersCurMonth2 = orderMasterService.selectOrderMasterList(orderParams2);
List<Long> 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<FinancialMaster> 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") @RequiresPermissions("customer:customer:resetPwd")

View File

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

View File

@ -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<AnalyseItem> analyseItems;
}

View File

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

View File

@ -1,6 +1,7 @@
package com.ghy.common.core.domain; package com.ghy.common.core.domain;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -38,6 +39,14 @@ public class BaseEntity implements Serializable
/** 请求参数 */ /** 请求参数 */
private Map<String, Object> params; private Map<String, Object> params;
private LocalDateTime updateTimeStart;
private LocalDateTime updateTimeEnd;
private LocalDateTime createTimeStart;
private LocalDateTime createTimeEnd;
public String getSearchValue() public String getSearchValue()
{ {
return searchValue; return searchValue;
@ -111,4 +120,36 @@ public class BaseEntity implements Serializable
{ {
this.params = params; 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;
}
} }

View File

@ -17,6 +17,12 @@ public interface CustomerMapper {
*/ */
List<Customer> getCustomerList(Customer customer); List<Customer> getCustomerList(Customer customer);
/**
* @param customer 消费者筛选条件
* @return 符合结果消费者计数
*/
Long countCustomer(Customer customer);
/** /**
* @param customerId 消费者id * @param customerId 消费者id
* @return 消费者信息 * @return 消费者信息

View File

@ -23,6 +23,12 @@ public interface CustomerService {
*/ */
List<Customer> getCustomerList(Customer customer); List<Customer> getCustomerList(Customer customer);
/**
* @param customer 消费者筛选条件
* @return 符合结果消费者计数
*/
Long countCustomer(Customer customer);
/** /**
* @param customerId 消费者id * @param customerId 消费者id
* @return 消费者信息 * @return 消费者信息

View File

@ -33,6 +33,11 @@ public class CustomerServiceImpl implements CustomerService {
return customerMapper.getCustomerList(customer); return customerMapper.getCustomerList(customer);
} }
@Override
public Long countCustomer(Customer customer) {
return customerMapper.countCustomer(customer);
}
@Override @Override
public Customer selectByOpenId(Customer customer) { public Customer selectByOpenId(Customer customer) {
List<Customer> list = customerMapper.getCustomerList(customer); List<Customer> list = customerMapper.getCustomerList(customer);

View File

@ -27,6 +27,11 @@
FROM customer FROM customer
</sql> </sql>
<sql id="selectCount">
SELECT COUNT(*)
FROM customer
</sql>
<select id="getCustomerList" resultMap="CustomerResult"> <select id="getCustomerList" resultMap="CustomerResult">
<include refid="selectCustomer" /> <include refid="selectCustomer" />
<where> <where>
@ -39,6 +44,21 @@
</where> </where>
</select> </select>
<select id="countCustomer" resultType="long">
<include refid="selectCount" />
<where>
<if test="openId != null and openId != ''">
AND open_id = #{openId}
</if>
<if test="customerPlace != null and customerPlace != ''">
AND customer_place = #{customerPlace}
</if>
<if test="updateTimeStart != null">
AND update_time &lt;= #{updateTimeStart}
</if>
</where>
</select>
<delete id="deleteByIds"> <delete id="deleteByIds">
DELETE FROM customer WHERE customer_id IN DELETE FROM customer WHERE customer_id IN
<foreach collection="array" item="customerIds" open="(" separator="," close=")"> <foreach collection="array" item="customerIds" open="(" separator="," close=")">

View File

@ -113,6 +113,12 @@
<if test="exceptOrderStatus != null"> <if test="exceptOrderStatus != null">
AND om.order_status != #{exceptOrderStatus} AND om.order_status != #{exceptOrderStatus}
</if> </if>
<if test="createTimeStart != null">
AND om.create_time &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null">
AND om.create_time &lt; #{createTimeEnd}
</if>
</where> </where>
order by om.create_time order by om.create_time
<trim suffixOverrides=","> <trim suffixOverrides=",">

View File

@ -7,6 +7,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author clunt * @author clunt
@ -54,6 +55,8 @@ public class FinancialMaster extends BaseEntity {
@Excel(name = "Adapay的唯一支付ID", cellType = Excel.ColumnType.STRING) @Excel(name = "Adapay的唯一支付ID", cellType = Excel.ColumnType.STRING)
private String paymentId; private String paymentId;
private List<Long> ids;
public FinancialMaster() { public FinancialMaster() {
} }

View File

@ -36,6 +36,12 @@
<if test="orderMasterId != null and orderMasterId != 0"> <if test="orderMasterId != null and orderMasterId != 0">
AND order_master_id = #{orderMasterId} AND order_master_id = #{orderMasterId}
</if> </if>
<if test="ids != null and ids != ''">
AND order_master_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="orderMasterCode != null and orderMasterCode != ''"> <if test="orderMasterCode != null and orderMasterCode != ''">
AND order_master_code LIKE concat('%', #{orderMasterCode}, '%') AND order_master_code LIKE concat('%', #{orderMasterCode}, '%')
</if> </if>

View File

@ -31,4 +31,8 @@ public class WorkerTeam extends BaseEntity {
private String workerLogoUrl; private String workerLogoUrl;
private Integer workerStatus;
private Boolean hasRegistered;
} }

View File

@ -10,6 +10,7 @@
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="workerLogoUrl" column="worker_logo_url"/> <result property="workerLogoUrl" column="worker_logo_url"/>
<result property="phone" column="phone"/> <result property="phone" column="phone"/>
<result property="workerStatus" column="worker_status"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
@ -37,17 +38,26 @@
</insert> </insert>
<sql id="selectWorkerTeam"> <sql id="selectWorkerTeam">
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 FROM worker_team wt
left join worker w on wt.worker_id = w.worker_id left join worker w on wt.worker_id = w.worker_id
</sql> </sql>
<select id="getWorkerTeamList" resultMap="WorkerTeamResult"> <select id="getWorkerTeamList" parameterType="com.ghy.worker.domain.WorkerTeam" resultMap="WorkerTeamResult">
<include refid="selectWorkerTeam"/> <include refid="selectWorkerTeam"/>
<where> <where>
<if test="leaderId != null and leaderId != ''"> <if test="leaderId != null and leaderId != ''">
AND wt.leader_id = #{leaderId} AND wt.leader_id = #{leaderId}
</if> </if>
<if test="workerId != null">
AND wt.worker_id = #{workerId}
</if>
<if test="workerStatus != null">
AND w.status = #{workerStatus}
</if>
<if test="hasRegistered != null and hasRegistered != ''">
AND w.phone IS NOT NULL
</if>
</where> </where>
</select> </select>