2021-09-17优化调整-2

dev
wuwenxiong 2021-09-17 16:55:50 +08:00
parent 4be1bc4fd2
commit c06ee3fbcc
6 changed files with 30 additions and 22 deletions

View File

@ -80,10 +80,10 @@ public class CustomerSupermarketProductService extends BaseService {
} }
} }
public Record findAllSupermarket(PageParam pp, Integer customer_id, String customer_name) { public Record findAllSupermarket(PageParam pp, Integer customer_id, Integer customer_type_id) {
List<Supermarket> cols = Supermarket.dao.find("select id, name, name2 from supermarket where del = 0"); List<Supermarket> cols = Supermarket.dao.find("select id, name, name2 from supermarket where del = 0");
String selectsql = " select a.customer_id, c.name customer_name "; String selectsql = " select a.customer_id, c.name customer_name, c.customer_type_id ";
String fromsql = " from (\n" + String fromsql = " from (\n" +
" select t.customer_id from customer_supermarket_product t\n" + " select t.customer_id from customer_supermarket_product t\n" +
" group by t.customer_id\n" + " group by t.customer_id\n" +
@ -95,11 +95,9 @@ public class CustomerSupermarketProductService extends BaseService {
if (customer_id != null) { if (customer_id != null) {
fromsql += " and c.id = ? \n"; fromsql += " and c.id = ? \n";
paraList.add(customer_id); paraList.add(customer_id);
} } else if (customer_type_id != null) {
fromsql += " and c.customer_type_id = ? \n";
if (StrKit.notBlank(customer_name)) { paraList.add(customer_type_id);
fromsql += " and c.name like ? \n";
paraList.add("%" + customer_name.trim() + "%");
} }
String totalRowSql = "select count(*) " + fromsql; String totalRowSql = "select count(*) " + fromsql;

View File

@ -415,13 +415,14 @@ public class PrepayService {
* *
* @return * @return
*/ */
public List<Record> flow(Integer customer_id, String stm, String etm) { public List<Record> flow(Integer customer_id, Integer customer_type_id, String stm, String etm) {
String sql = "select * from ( \n" + String sql = "select * from ( \n" +
" select a.sn id, a.create_time tm, 0 - a.total_price amount, '扣费' type, \n" + " select a.sn id, a.create_time tm, 0 - a.total_price amount, '扣费' type, \n" +
" case when a.paid > 0 then concat('补差额', a.paid) else '' end memo, a.customer_id, a.customer_name \n" + " case when a.paid > 0 then concat('补差额', a.paid) else '' end memo, a.customer_id, a.customer_name, a.customer_type_id \n" +
" from ( \n" + " from ( \n" +
" select t.sn, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time \n" + " select t.sn, t.total_price, t.paid, t.customer_id, t.customer_name, t.create_time, c.customer_type_id \n" +
" from order_temp t \n" + " from order_temp t \n" +
" left join customer c on t.customer_id = c.id \n" +
" where t.isprepaid = 1 \n" + " where t.isprepaid = 1 \n" +
" and t.state = ? \n" + " and t.state = ? \n" +
" and t.prepay_customer_id is not null\n" + " and t.prepay_customer_id is not null\n" +
@ -430,7 +431,7 @@ public class PrepayService {
" ) a \n" + " ) a \n" +
" left join transport p on p.order_sn = a.sn \n" + " left join transport p on p.order_sn = a.sn \n" +
" union \n" + " union \n" +
" select concat('prepay_detail_', t.id) id, t.verify_time tm, t.amount, '付费' type, '' memo, c.id customer_id, c.name customer_name \n" + " select concat('prepay_detail_', t.id) id, t.verify_time tm, t.amount, '付费' type, '' memo, c.id customer_id, c.name customer_name, c.customer_type_id \n" +
" from prepay_detail t \n" + " from prepay_detail t \n" +
" left join customer c on c.id = t.customer_id \n" + " left join customer c on c.id = t.customer_id \n" +
" where t.state = 2 \n" + " where t.state = 2 \n" +
@ -438,7 +439,7 @@ public class PrepayService {
" and t.verify_time <= ? \n" + " and t.verify_time <= ? \n" +
" \n" + " \n" +
" union \n" + " union \n" +
" select concat('refund_detail_', t.id) id, t.verify_time tm, 0 - t.amount amount, '退费' type, '' memo, c.id customer_id, c.name customer_name \n" + " select concat('refund_detail_', t.id) id, t.verify_time tm, 0 - t.amount amount, '退费' type, '' memo, c.id customer_id, c.name customer_name, c.customer_type_id \n" +
" from refund_detail t \n" + " from refund_detail t \n" +
" left join customer c on c.id = t.customer_id \n" + " left join customer c on c.id = t.customer_id \n" +
" where t.state = 3 \n" + // 退费有三个状态 " where t.state = 3 \n" + // 退费有三个状态
@ -462,6 +463,13 @@ public class PrepayService {
if (customer_id != null && customer_id > 0) { if (customer_id != null && customer_id > 0) {
sql += " and b.customer_id = ? \n"; sql += " and b.customer_id = ? \n";
paraList.add(customer_id); paraList.add(customer_id);
} else {
if (customer_type_id != null && customer_type_id >= 0 && customer_type_id != 99) {
sql += " and b.customer_type_id = ? \n";
paraList.add(customer_id);
} else if (customer_type_id != null && customer_type_id == 99) { // 散户
sql += " and b.customer_id is null \n";
}
} }
sql += " order by b.tm desc"; sql += " order by b.tm desc";
@ -469,7 +477,7 @@ public class PrepayService {
return Db.find(sql, paraList.toArray()); return Db.find(sql, paraList.toArray());
} }
public Workbook flowExport(Integer customer_id, String stm, String etm) { public Workbook flowExport(Integer customer_id, Integer customer_type_id, String stm, String etm) {
Customer customer = Customer.dao.findById(customer_id); Customer customer = Customer.dao.findById(customer_id);
String cname = ""; String cname = "";
@ -477,7 +485,7 @@ public class PrepayService {
cname = customer.getName(); cname = customer.getName();
} }
List<Record> list = flow(customer_id, stm, etm); List<Record> list = flow(customer_id, customer_type_id, stm, etm);
list.sort(new Comparator<Record>() { list.sort(new Comparator<Record>() {
public int compare(Record o1, Record o2) { public int compare(Record o1, Record o2) {

View File

@ -27,8 +27,8 @@ public class CustomerSupermarketProductController extends Controller {
public void findAllSupermarket() { public void findAllSupermarket() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
String customer_name = get("customer_name"); Integer customer_type_id = getInt("customer_type_id");
renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_name))); renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_type_id)));
} }
public void getAllSupProduct(){ public void getAllSupProduct(){

View File

@ -43,13 +43,14 @@ public class PrepayController extends BaseController {
public void flow() { public void flow() {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
String stm = get("stm"); String stm = get("stm");
String etm = get("etm"); String etm = get("etm");
if (export == 0) { if (export == 0) {
renderJson(Result.success(PrepayService.me.flow(customer_id, stm, etm))); renderJson(Result.success(PrepayService.me.flow(customer_id, customer_type_id, stm, etm)));
} else { } else {
Workbook wb = PrepayService.me.flowExport(customer_id, stm, etm); Workbook wb = PrepayService.me.flowExport(customer_id, customer_type_id, stm, etm);
render(new ExcelRender("客户流水_" + System.currentTimeMillis() + ".xlsx", wb)); render(new ExcelRender("客户流水_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }

View File

@ -61,8 +61,8 @@ public class CustomerSupermarketProductController extends Controller {
public void findAllSupermarket() { public void findAllSupermarket() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
String customer_name = get("customer_name"); Integer customer_type_id = getInt("customer_type_id");
renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_name))); renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_type_id)));
} }
public void getAllSupProduct(){ public void getAllSupProduct(){

View File

@ -68,6 +68,7 @@ public class PrepayController extends BaseController {
public void flow() { public void flow() {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
Integer customer_type_id = getInt("customer_type_id");
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -83,9 +84,9 @@ public class PrepayController extends BaseController {
String etm = get("etm"); String etm = get("etm");
if (export == 0) { if (export == 0) {
renderJson(Result.success(PrepayService.me.flow(customer_id, stm, etm))); renderJson(Result.success(PrepayService.me.flow(customer_id, customer_type_id, stm, etm)));
} else { } else {
Workbook wb = PrepayService.me.flowExport(customer_id, stm, etm); Workbook wb = PrepayService.me.flowExport(customer_id, customer_type_id, stm, etm);
render(new ExcelRender("客户流水_" + System.currentTimeMillis() + ".xlsx", wb)); render(new ExcelRender("客户流水_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }