2021-09-17优化调整-2
parent
4be1bc4fd2
commit
c06ee3fbcc
|
|
@ -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");
|
||||
|
||||
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" +
|
||||
" select t.customer_id from customer_supermarket_product t\n" +
|
||||
" group by t.customer_id\n" +
|
||||
|
|
@ -95,11 +95,9 @@ public class CustomerSupermarketProductService extends BaseService {
|
|||
if (customer_id != null) {
|
||||
fromsql += " and c.id = ? \n";
|
||||
paraList.add(customer_id);
|
||||
}
|
||||
|
||||
if (StrKit.notBlank(customer_name)) {
|
||||
fromsql += " and c.name like ? \n";
|
||||
paraList.add("%" + customer_name.trim() + "%");
|
||||
} else if (customer_type_id != null) {
|
||||
fromsql += " and c.customer_type_id = ? \n";
|
||||
paraList.add(customer_type_id);
|
||||
}
|
||||
|
||||
String totalRowSql = "select count(*) " + fromsql;
|
||||
|
|
|
|||
|
|
@ -415,13 +415,14 @@ public class PrepayService {
|
|||
*
|
||||
* @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" +
|
||||
" 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" +
|
||||
" 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" +
|
||||
" left join customer c on t.customer_id = c.id \n" +
|
||||
" where t.isprepaid = 1 \n" +
|
||||
" and t.state = ? \n" +
|
||||
" and t.prepay_customer_id is not null\n" +
|
||||
|
|
@ -430,7 +431,7 @@ public class PrepayService {
|
|||
" ) a \n" +
|
||||
" left join transport p on p.order_sn = a.sn \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" +
|
||||
" left join customer c on c.id = t.customer_id \n" +
|
||||
" where t.state = 2 \n" +
|
||||
|
|
@ -438,7 +439,7 @@ public class PrepayService {
|
|||
" and t.verify_time <= ? \n" +
|
||||
" \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" +
|
||||
" left join customer c on c.id = t.customer_id \n" +
|
||||
" where t.state = 3 \n" + // 退费有三个状态
|
||||
|
|
@ -462,6 +463,13 @@ public class PrepayService {
|
|||
if (customer_id != null && customer_id > 0) {
|
||||
sql += " and b.customer_id = ? \n";
|
||||
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";
|
||||
|
|
@ -469,7 +477,7 @@ public class PrepayService {
|
|||
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);
|
||||
String cname = "";
|
||||
|
||||
|
|
@ -477,7 +485,7 @@ public class PrepayService {
|
|||
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>() {
|
||||
public int compare(Record o1, Record o2) {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class CustomerSupermarketProductController extends Controller {
|
|||
public void findAllSupermarket() {
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
Integer customer_id = getInt("customer_id");
|
||||
String customer_name = get("customer_name");
|
||||
renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_name)));
|
||||
Integer customer_type_id = getInt("customer_type_id");
|
||||
renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_type_id)));
|
||||
}
|
||||
|
||||
public void getAllSupProduct(){
|
||||
|
|
|
|||
|
|
@ -43,13 +43,14 @@ public class PrepayController extends BaseController {
|
|||
public void flow() {
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer customer_id = getInt("customer_id");
|
||||
Integer customer_type_id = getInt("customer_type_id");
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
|
||||
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 {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ public class CustomerSupermarketProductController extends Controller {
|
|||
public void findAllSupermarket() {
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
Integer customer_id = getInt("customer_id");
|
||||
String customer_name = get("customer_name");
|
||||
renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_name)));
|
||||
Integer customer_type_id = getInt("customer_type_id");
|
||||
renderJson(Result.object(CustomerSupermarketProductService.me.findAllSupermarket(pp, customer_id, customer_type_id)));
|
||||
}
|
||||
|
||||
public void getAllSupProduct(){
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class PrepayController extends BaseController {
|
|||
public void flow() {
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer customer_id = getInt("customer_id");
|
||||
Integer customer_type_id = getInt("customer_type_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
|
|
@ -83,9 +84,9 @@ public class PrepayController extends BaseController {
|
|||
String etm = get("etm");
|
||||
|
||||
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 {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue