Commit 0a9997d3 by 张新旗

代码永远在路上

parent 0a2b2609
...@@ -7,6 +7,8 @@ import com.soss.common.core.page.TableDataInfo; ...@@ -7,6 +7,8 @@ import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType; import com.soss.common.enums.BusinessType;
import com.soss.common.utils.poi.ExcelUtil; import com.soss.common.utils.poi.ExcelUtil;
import com.soss.system.domain.Customer; import com.soss.system.domain.Customer;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.service.ICustomerService; import com.soss.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -33,25 +35,14 @@ public class CustomerController extends BaseController ...@@ -33,25 +35,14 @@ public class CustomerController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:customer:list')") @PreAuthorize("@ss.hasPermi('system:customer:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(Customer customer) public TableDataInfo list(CustomerQueryVo customerQueryVo)
{ {
startPage(); startPage();
List<Customer> list = customerService.selectCustomerList(customer); List<CustomerResultVo> list = customerService.selectCustomerList(customerQueryVo);
return getDataTable(list); return getDataTable(list);
} }
/**
* 导出用户信息列表
*/
@PreAuthorize("@ss.hasPermi('system:customer:export')")
@Log(title = "用户信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Customer customer)
{
List<Customer> list = customerService.selectCustomerList(customer);
ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
util.exportExcel(response, list, "用户信息数据");
}
/** /**
* 获取用户信息详细信息 * 获取用户信息详细信息
......
package com.soss.system.domain.vo.customer;
import lombok.Getter;
import lombok.Setter;
import javax.xml.crypto.Data;
import java.io.Serializable;
@Getter
@Setter
public class CustomerQueryVo implements Serializable {
private String userInfo;
private Data createAtStart;
private Data createAtEnd;
//1 有购买 2无购买 3有复购
private String buyRecords;
}
package com.soss.system.domain.vo.customer;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Getter
@Setter
public class CustomerResultVo implements Serializable {
private String userName;
private String phoneNumber;
private String orderCount;
private BigDecimal amount;
private String cancelCount;
private BigDecimal cancelAmount;
private String refundCount;
private BigDecimal refundAmount;
private Date lastOrderDate;
private Date createDate;
private String source;
}
...@@ -2,6 +2,8 @@ package com.soss.system.mapper; ...@@ -2,6 +2,8 @@ package com.soss.system.mapper;
import java.util.List; import java.util.List;
import com.soss.system.domain.Customer; import com.soss.system.domain.Customer;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
/** /**
* 用户信息Mapper接口 * 用户信息Mapper接口
...@@ -58,4 +60,6 @@ public interface CustomerMapper ...@@ -58,4 +60,6 @@ public interface CustomerMapper
* @return 结果 * @return 结果
*/ */
public int deleteCustomerByIds(Long[] ids); public int deleteCustomerByIds(Long[] ids);
List<CustomerResultVo> selectCustomerByQuery(CustomerQueryVo customer);
} }
...@@ -2,6 +2,8 @@ package com.soss.system.service; ...@@ -2,6 +2,8 @@ package com.soss.system.service;
import java.util.List; import java.util.List;
import com.soss.system.domain.Customer; import com.soss.system.domain.Customer;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
/** /**
* 用户信息Service接口 * 用户信息Service接口
...@@ -25,7 +27,7 @@ public interface ICustomerService ...@@ -25,7 +27,7 @@ public interface ICustomerService
* @param customer 用户信息 * @param customer 用户信息
* @return 用户信息集合 * @return 用户信息集合
*/ */
public List<Customer> selectCustomerList(Customer customer); public List<CustomerResultVo> selectCustomerList(CustomerQueryVo customer);
/** /**
* 新增用户信息 * 新增用户信息
......
...@@ -2,6 +2,8 @@ package com.soss.system.service.impl; ...@@ -2,6 +2,8 @@ package com.soss.system.service.impl;
import java.util.List; import java.util.List;
import com.soss.common.utils.DateUtils; import com.soss.common.utils.DateUtils;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.soss.system.mapper.CustomerMapper; import com.soss.system.mapper.CustomerMapper;
...@@ -39,9 +41,11 @@ public class CustomerServiceImpl implements ICustomerService ...@@ -39,9 +41,11 @@ public class CustomerServiceImpl implements ICustomerService
* @return 用户信息 * @return 用户信息
*/ */
@Override @Override
public List<Customer> selectCustomerList(Customer customer) public List<CustomerResultVo> selectCustomerList(CustomerQueryVo customer)
{ {
return customerMapper.selectCustomerList(customer);
List<CustomerResultVo> customerResultVos = customerMapper.selectCustomerByQuery(customer);
return customerResultVos;
} }
/** /**
......
...@@ -73,4 +73,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -73,4 +73,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="selectCustomerByQuery" resultType="com.soss.system.domain.vo.customer.CustomerResultVo">
select * from (select
c.user_name as userName,
c.phone as phoneNumber,
(select count(*) from `order` o where o.user_id = c.id) as orderCount,
(select sum(o.amount) from `order` o where o.user_id = c.id) as amount,
(select count(*) from `order` o where o.user_id = c.id and o.state in ('8','9','10','11')) as cancelCount,
(select sum(o.amount) from `order` o where o.user_id = c.id and o.state in ('8','9','10','11')) as cancelAmount,
(select count(*) from `order` o where o.user_id = c.id and o.state in ('12','14','15')) as refundCount,
(select sum(o.amount) from `order` o where o.user_id = c.id and o.state in ('12','14','15')) as refundAmount,
(select o.created_at from `order` o where o.user_id = c.id order by o.created_at desc limit 1) as lastOrderDate,
c.create_time as createDate,
c.soucre
from
customer c ) a
<where>
<if test="userInfo != null and userInfo != ''">
and ((a.user_name like concat('%', #{userInfo}, '%')) or (a.phone like concat('%', #{userInfo}, '%') ))
</if>
<if test="buyRecords != null and buyRecords != ''">
and
<if test="buyRecords == '1'">
a.orderCount >0
</if>
<if test="buyRecords == '2'">
a.orderCount =0
</if>
<if test="buyRecords == '3'">
a.orderCount >1
</if>
</if>
<if test="createAtStart !='' and createAtStart!=null">
and createDate &gt;=#{createAtStart}
</if>
<if test="createAtEnd !='' and createAtEnd!=null">
and createDate &lt;=#{createAtEnd}
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -145,7 +145,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -145,7 +145,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user_role ur on u.user_id = ur.user_id left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id left join sys_role r on r.role_id = ur.role_id
where u.del_flag='0' where u.del_flag='0'
<if test="userInfo != null and userInfo != ''">
and ((u.user_name like concat('%', #{userInfo}, '%')) or (u.phonenumber like concat('%', #{userInfo}, '%') )) and ((u.user_name like concat('%', #{userInfo}, '%')) or (u.phonenumber like concat('%', #{userInfo}, '%') ))
</if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND u.status =#{status} AND u.status =#{status}
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment