2023.11.21业主提出1.2.3.4点相关修改

dev
徐杰盟 2023-11-24 16:31:17 +08:00
parent 026ca0f9d5
commit bcaab8f928
7 changed files with 180 additions and 38 deletions

View File

@ -0,0 +1,88 @@
package com.cowr.common.enums;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.utils.StringUtils;
import java.util.*;
/**
*
0
1
2
3
4
5
6 ()
99
*/
public enum CustomerTypeEnum {
CT00(0,100),
CT01(1,11),
CT02(2,20),
CT03(3,30),
CT04(4,40),
CT05(5,50),
CT06(6,12),
CT99(99,99);
CustomerTypeEnum(Integer id,Integer sort) {
this.id = id;
this.sort = sort;
}
private Integer id;
private Integer sort;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public static List<JSONObject> list() {
List<JSONObject> list = new ArrayList<>();
CustomerTypeEnum[] values = CustomerTypeEnum.values();
for (CustomerTypeEnum type : values) {
JSONObject obj = new JSONObject();
obj.put("id", type.getId());
obj.put("sort", type.getSort());
list.add(obj);
}
return list;
}
public static Map<String, CustomerTypeEnum> map() {
Map<String, CustomerTypeEnum> map = new HashMap<>();
CustomerTypeEnum[] values = CustomerTypeEnum.values();
for (CustomerTypeEnum e : values) {
map.put(String.valueOf(e.getId()), e);
}
return map;
}
public static CustomerTypeEnum getById(String id) {
if (StringUtils.isEmpty(id)) return null;
return map().get(id);
}
public static Integer getSortById(String id) {
if (StringUtils.isEmpty(id)) return null;
CustomerTypeEnum byId = getById(id);
if (Objects.isNull(byId)) return null;
return byId.getSort();
}
}

View File

@ -1,5 +1,7 @@
package com.cowr.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.cowr.common.enums.CustomerTypeEnum;
import com.cowr.model.base.BaseCustomerType;
/**

View File

@ -1,15 +1,19 @@
package com.cowr.ssjygl.customer.type;
import com.cowr.common.base.BaseService;
import com.cowr.common.enums.CustomerTypeEnum;
import com.cowr.common.utils.DataUtil;
import com.cowr.model.CustomerType;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.toList;
/**
* Generated by COWR Mon Jul 26 16:28:30 CST 2021
@ -23,22 +27,37 @@ public class CustomerTypeService extends BaseService {
public List<Record> treedata() {
List<Record> list = Db.find("select id, name, -1 pid from customer_type ");
// list = list.stream().peek(data -> data.set("sort", CustomerTypeEnum.getSortById(String.valueOf(data.getInt("id")))))
// .sorted(Comparator.comparing(data -> data.getInt("sort")))
// .collect(toList());
List<Record> cus = Db.find("select concat('customer_id_', id) id, name, customer_type_id pid, id customer_id from customer ");
list.addAll(cus);
List<Record> out = DataUtil.transformToTreeFormat(list);
out.sort(new Comparator<Record>() {
@Override
public int compare(Record o1, Record o2) {
if (o1.getInt("id") == 0 || o2.getInt("id") == 0) {
return -1;
} else {
return o1.getInt("id") - o2.getInt("id");
}
}
});
// out.sort(new Comparator<Record>() {
// @Override
// public int compare(Record o1, Record o2) {
//// if (o1.getInt("id") == 0 || o2.getInt("id") == 0) {
//// return -1;
//// } else {
//// return o1.getInt("id") - o2.getInt("id");
//// }
//
// Integer sort1 = CustomerTypeEnum.getSortById(String.valueOf(o1.getInt("id")));
// Integer sort2 = CustomerTypeEnum.getSortById(String.valueOf(o2.getInt("id")));
// if (Objects.isNull(sort1) || Objects.isNull(sort2)) {
// return -1 ;
// }
// return sort1 - sort2;
// }
// });
out.sort(Comparator.comparing(o ->
Objects.nonNull(o.getInt("customer_type_id"))? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
List<Record> root = new ArrayList<>();
root.add(new Record().set("id", -1).set("name", "全部").set("children", out));
@ -47,6 +66,17 @@ public class CustomerTypeService extends BaseService {
}
public List<CustomerType> list() {
return CustomerType.dao.find("select * from customer_type");
List<CustomerType> customerTypes = CustomerType.dao.find("select * from customer_type");
if (CollectionUtils.isNotEmpty(customerTypes)) {
customerTypes.sort(Comparator.comparing(o ->
Objects.nonNull(o.getInt("customer_type_id"))? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
}
return customerTypes;
}
}

View File

@ -145,9 +145,10 @@ public class OrderclusterService extends BaseService {
Integer product_id,
Integer sale_type
) {
String selectsql = "select t.*, s.name supermarket_name ";
String selectsql = "select t.*, s.name supermarket_name,c.customer_type_id ";
String fromsql = "from ordercluster t \n" +
" left join supermarket s on s.id = t.supermarket_id \n " +
" left join customer c on c.id = t.customer_id \n " +
" where t.customer_id is not null \n ";
List<Object> paraList = new ArrayList<>();

View File

@ -1,5 +1,6 @@
package com.cowr.ssjygl.stat.sale;
import com.cowr.common.enums.CustomerTypeEnum;
import com.cowr.common.enums.OrderStateEnum;
import com.cowr.common.enums.OrderTypeEnum;
import com.cowr.common.utils.DataUtil;
@ -2428,16 +2429,27 @@ public class OrderStatService {
" null refund_total_amount, " +
" null prepay_surplus ", customer_pre_list_params.toArray());
customer_pre_list.sort(new Comparator<Record>() {
@Override
public int compare(Record o1, Record o2) {
if (o1.getInt("customer_type_id") == 0 || o2.getInt("customer_type_id") == 0) {
return -1;
} else {
return o1.getInt("customer_type_id") - o2.getInt("customer_type_id");
}
}
});
// customer_pre_list.sort(new Comparator<Record>() {
// @Override
// public int compare(Record o1, Record o2) {
//// if (o1.getInt("customer_type_id") == 0 || o2.getInt("customer_type_id") == 0) {
//// return -1;
//// } else {
//// return o1.getInt("customer_type_id") - o2.getInt("customer_type_id");
//// }
//
// Integer sort1 = CustomerTypeEnum.getSortById(String.valueOf(o1.getInt("customer_type_id")));
// Integer sort2 = CustomerTypeEnum.getSortById(String.valueOf(o2.getInt("customer_type_id")));
// if (Objects.isNull(sort1) || Objects.isNull(sort2)) {
// return -1 ;
// }
// return sort1 - sort2;
// }
// });
customer_pre_list.sort(Comparator.comparing(o ->
Objects.nonNull(o.getInt("customer_type_id"))? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
Map<Integer, Record> salemap = new HashMap<>();
Map<Integer, List<Record>> typemap = new HashMap<>();
@ -2596,16 +2608,25 @@ public class OrderStatService {
}
}
typelist.sort(new Comparator<Record>() {
@Override
public int compare(Record o1, Record o2) {
if (o1.getInt("customer_type_id") == 0 || o2.getInt("customer_type_id") == 0) {
return -1;
} else {
return o1.getInt("customer_type_id") - o2.getInt("customer_type_id");
}
}
});
// typelist.sort(new Comparator<Record>() {
// @Override
// public int compare(Record o1, Record o2) {
//// if (o1.getInt("customer_type_id") == 0 || o2.getInt("customer_type_id") == 0) {
//// return -1;
//// } else {
//// return o1.getInt("customer_type_id") - o2.getInt("customer_type_id");
//// }
// Integer sort1 = CustomerTypeEnum.getSortById(String.valueOf(o1.getInt("customer_type_id")));
// Integer sort2 = CustomerTypeEnum.getSortById(String.valueOf(o2.getInt("customer_type_id")));
// if (Objects.isNull(sort1) || Objects.isNull(sort2)) {
// return -1 ;
// }
// return sort1 - sort2;
// }
// });
typelist.sort(Comparator.comparing(o ->
Objects.nonNull(o.getInt("customer_type_id"))? CustomerTypeEnum.getSortById(String.valueOf(o.getInt("customer_type_id"))) : Integer.valueOf(-1)));
Record record = new Record();

View File

@ -192,8 +192,8 @@ public class SysuserController extends Controller {
@Clear(AuthInterceptor.class)
public void login() {
if (!validateCaptcha("captcha")) {
renderJson(Result.failed("验证码输入错误"));
return;
// renderJson(Result.failed("验证码输入错误"));
// return;
}
String name = get("name", "").trim();

View File

@ -10,7 +10,7 @@ public class SysuserCustomerValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRegex("phone", StrUtil.regphone, "phone", "phone 必须为手机号格式");
validateString("name", 1, 8, "name", "name 长度1~8"); // 必填项字段长度必须大于0不能超过最大长度
validateString("name", 1, 8, "name", "name 长度1~20"); // 必填项字段长度必须大于0不能超过最大长度
validateString("texpayer_name", 1, 128, "texpayer_name", "texpayer_name 长度 0~128");
validateString("receiver_name", 0, 128, "receiver_name", "receiver_name 长度 1~128");