客户账户添加客户类型、客户名称筛选

dev
wuwenxiong 2021-08-31 13:53:56 +08:00
parent 29845ad96c
commit 6bbe80db09
4 changed files with 57 additions and 21 deletions

View File

@ -41,7 +41,9 @@ public class SysuserController extends Controller {
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的 Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
Integer type = getInt("type"); Integer type = getInt("type");
Integer entity_id = getInt("entity_id"); Integer entity_id = getInt("entity_id");
renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id))); Integer customer_type = getInt("customer_type");
String customer_name = get("customer_name");
renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id, customer_type, customer_name)));
} }
/** /**

View File

@ -295,7 +295,8 @@ public class SysuserSyncService extends BaseService {
return sysuser; return sysuser;
} }
public Page<Record> find(PageParam pp, String name, String phone, Integer del, Integer type, Integer entity_id) { public Page<Record> find(PageParam pp, String name, String phone, Integer del, Integer type, Integer entity_id, Integer customer_type, String customer_name) {
List<Object> paraList = new ArrayList<>();
StringBuilder sqlbuf = new StringBuilder(); StringBuilder sqlbuf = new StringBuilder();
sqlbuf.append(" from (\n"); sqlbuf.append(" from (\n");
sqlbuf.append("select \n"); sqlbuf.append("select \n");
@ -313,7 +314,31 @@ public class SysuserSyncService extends BaseService {
sqlbuf.append(" left join customer c on u.entity_id = c.id\n"); sqlbuf.append(" left join customer c on u.entity_id = c.id\n");
sqlbuf.append(") a\n"); sqlbuf.append(") a\n");
sqlbuf.append("where 1 = 1"); sqlbuf.append("where 1 = 1");
List<Object> paraList = new ArrayList<>();
if (type != null && type == UserTypeEnum.CUSTOMER.getTypeid()) {
sqlbuf.setLength(0);
sqlbuf.append(" from ( \n");
sqlbuf.append(" select \n");
sqlbuf.append(" u.id, u.phone, u.name, u.type, u.del, u.entity_id, c.name customer_name, c.texpayer_name, c.invoice_type, t.id customer_type, t.name customer_type_name \n");
sqlbuf.append(" from sysuser u \n");
sqlbuf.append(" left join customer c on u.entity_id = c.id\n");
sqlbuf.append(" left join customer_type t on c.customer_type_id = t.id\n");
sqlbuf.append(" union all\n");
sqlbuf.append(" select o.sn id, o.customer_phone phone, '零散客户' name, 3 type, 0 del, null entity_id, o.customer_name, o.customer_texpayer_name texpayer_name, o.invoice_type, 99 customer_type, '零散' customer_type_name \n");
sqlbuf.append(" from order_temp o \n");
sqlbuf.append(") a\n");
sqlbuf.append("where 1 = 1");
if (StrKit.notBlank(customer_name)) {
sqlbuf.append(" and a.customer_name like ? \n");
paraList.add("%" + customer_name.trim() + "%");
}
if (customer_type != null && customer_type >= 0) {
sqlbuf.append(" and a.customer_type = ? \n");
paraList.add(customer_type);
}
}
if (StrKit.notBlank(name)) { if (StrKit.notBlank(name)) {
sqlbuf.append(" and a.name like ? \n"); sqlbuf.append(" and a.name like ? \n");

View File

@ -153,8 +153,9 @@ public class SysuserController extends Controller {
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的 Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
Integer type = getInt("type"); Integer type = getInt("type");
Integer entity_id = getInt("entity_id"); Integer entity_id = getInt("entity_id");
Integer customer_type = getInt("customer_type");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id, customer_name))); renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id, customer_type, customer_name)));
} }
/** /**

View File

@ -817,7 +817,7 @@ public class SysuserSyncService extends BaseSyncService {
return sysuser; return sysuser;
} }
public Page<Record> find(PageParam pp, String name, String phone, Integer del, Integer type, Integer entity_id, String customer_name) { public Page<Record> find(PageParam pp, String name, String phone, Integer del, Integer type, Integer entity_id, Integer customer_type, String customer_name) {
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
StringBuilder sqlbuf = new StringBuilder(); StringBuilder sqlbuf = new StringBuilder();
@ -840,19 +840,27 @@ public class SysuserSyncService extends BaseSyncService {
if (type != null && type == UserTypeEnum.CUSTOMER.getTypeid()) { if (type != null && type == UserTypeEnum.CUSTOMER.getTypeid()) {
sqlbuf.setLength(0); sqlbuf.setLength(0);
sqlbuf.append(" from ( \n"); sqlbuf.append(" from ( \n");
sqlbuf.append(" select \n"); sqlbuf.append(" select \n");
sqlbuf.append(" u.id, u.phone, u.name, u.type, u.role, u.del, u.entity_id, c.name customer_name, c.texpayer_name, c.invoice_type \n"); sqlbuf.append(" u.id, u.phone, u.name, u.type, u.del, u.entity_id, c.name customer_name, c.texpayer_name, c.invoice_type, t.id customer_type, t.name customer_type_name \n");
sqlbuf.append(" from sysuser u \n"); sqlbuf.append(" from sysuser u \n");
sqlbuf.append(" left join customer c on u.entity_id = c.id\n"); sqlbuf.append(" left join customer c on u.entity_id = c.id\n");
sqlbuf.append(" left join customer_type t on c.customer_type_id = t.id\n");
sqlbuf.append(" union all\n");
sqlbuf.append(" select o.sn id, o.customer_phone phone, '零散客户' name, 3 type, 0 del, null entity_id, o.customer_name, o.customer_texpayer_name texpayer_name, o.invoice_type, 99 customer_type, '零散' customer_type_name \n");
sqlbuf.append(" from order_temp o \n");
sqlbuf.append(") a\n"); sqlbuf.append(") a\n");
sqlbuf.append("where 1 = 1"); sqlbuf.append("where 1 = 1");
if (StrKit.notBlank(customer_name)) { if (StrKit.notBlank(customer_name)) {
sqlbuf.append(" and a.customer_name like ? \n"); sqlbuf.append(" and a.customer_name like ? \n");
paraList.add("%" + customer_name.trim() + "%"); paraList.add("%" + customer_name.trim() + "%");
} }
if (customer_type != null && customer_type >= 0) {
sqlbuf.append(" and a.customer_type = ? \n");
paraList.add(customer_type);
}
} }
if (StrKit.notBlank(name)) { if (StrKit.notBlank(name)) {