调整客户访问地址限制
parent
35c6f9162d
commit
c4b6bfadf8
|
|
@ -3,8 +3,11 @@ package com.cowr.ssjygl.order.ordercluster;
|
|||
import com.cowr.common.Const;
|
||||
import com.cowr.common.base.BaseService;
|
||||
import com.cowr.common.enums.OrderStateEnum;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Ordercluster;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
|
|
@ -22,13 +25,26 @@ import java.util.Map;
|
|||
* Remarks: 订单相关 - 订单
|
||||
* PrimaryKey: id
|
||||
* <p>
|
||||
* ALTER TABLE `order_temp` ADD INDEX `order_sale_ordercluster_id`(`ordercluster_id`);
|
||||
* ALTER TABLE `order_temp` ADD INDEX `order_temp_ordercluster_id`(`ordercluster_id`);
|
||||
* ALTER TABLE `ordercluster` DROP COLUMN `over_weight`;
|
||||
*/
|
||||
public class OrderclusterService extends BaseService {
|
||||
public static final OrderclusterService me = new OrderclusterService();
|
||||
|
||||
public Result get(Integer id, Sysuser sysuser){
|
||||
Ordercluster ordercluster = Ordercluster.dao.findById(id);
|
||||
|
||||
if (ordercluster == null) {
|
||||
return Result.failed("未找到订单记录");
|
||||
} else if (sysuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()
|
||||
&& ordercluster.getCustomerId() != null
|
||||
&& sysuser.getEntityId() != null
|
||||
&& !sysuser.getEntityId().equals(ordercluster.getCustomerId())
|
||||
) {
|
||||
return Result.failed("登录用户和订单信息不匹配");
|
||||
}
|
||||
|
||||
return Result.success(ordercluster);
|
||||
}
|
||||
|
||||
public Page<Record> find(PageParam pp,
|
||||
Integer supermarket_id,
|
||||
Integer trans_co_id,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ package com.cowr.ssjygl.order.ordertemp;
|
|||
|
||||
import com.cowr.common.Const;
|
||||
import com.cowr.common.base.BaseService;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.OrderTemp;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
|
|
@ -22,6 +24,22 @@ import java.util.List;
|
|||
public class OrderTempService extends BaseService {
|
||||
public static final OrderTempService me = new OrderTempService();
|
||||
|
||||
public Result get(String sn, Sysuser sysuser) {
|
||||
Record record = get(sn);
|
||||
|
||||
if (record == null) {
|
||||
return Result.failed("未找到订单记录");
|
||||
} else if (sysuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()
|
||||
&& record.get("customer_id") != null
|
||||
&& sysuser.getEntityId() != null
|
||||
&& !sysuser.getEntityId().equals(record.getInt("customer_id"))
|
||||
) {
|
||||
return Result.failed("登录用户和订单信息不匹配");
|
||||
}
|
||||
|
||||
return Result.success(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 sn 查询单个订单信息
|
||||
*
|
||||
|
|
@ -29,7 +47,7 @@ public class OrderTempService extends BaseService {
|
|||
* @return
|
||||
*/
|
||||
public Record get(String sn) {
|
||||
return Db.findFirst("select t.*" +
|
||||
return Db.findFirst("select t.*" +
|
||||
", p.order_sn \n" +
|
||||
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
|
||||
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
|
||||
|
|
@ -53,7 +71,7 @@ public class OrderTempService extends BaseService {
|
|||
Integer product_id,
|
||||
Integer state
|
||||
) {
|
||||
String selectsql = "select t.* " +
|
||||
String selectsql = "select t.* " +
|
||||
", p.order_sn \n" +
|
||||
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
|
||||
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
|
||||
|
|
|
|||
|
|
@ -34,93 +34,6 @@ public class PrepayTruckService extends BaseService {
|
|||
};
|
||||
public static final PrepayTruckService me = new PrepayTruckService();
|
||||
|
||||
public Result save(PrepayTruck model, Sysuser sysuser) {
|
||||
try {
|
||||
String[] tls = model.getTruckLicense().split(",");
|
||||
List<Truck> list = Truck.dao.find("select t.license, t.trans_co_id from truck t where t.del = 0"); // 只返回需要的字段
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for(Truck t : list){
|
||||
map.put(t.getLicense(), t.getTransCoId());
|
||||
}
|
||||
|
||||
if(model.getValidDate() == null){
|
||||
model.setValidDate(new Date());
|
||||
}
|
||||
|
||||
model.setCreateUserId(sysuser.getId());
|
||||
|
||||
List<Record> pts = new ArrayList<>();
|
||||
model.remove("truck_license");
|
||||
|
||||
for(String truck_license: tls){
|
||||
Record record = DataUtil.cloneRecord(model.toRecord());
|
||||
record.set("truck_license", truck_license);
|
||||
record.set("trans_co_id", map.get(truck_license));
|
||||
|
||||
pts.add(record);
|
||||
}
|
||||
|
||||
if(pts.isEmpty()){
|
||||
return Result.failed("truck_license 参数错误");
|
||||
}
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() throws SQLException {
|
||||
int[] ret = Db.batchSave(PrepayTruck.tablename, pts, pts.size());
|
||||
|
||||
return ret.length == pts.size();
|
||||
}
|
||||
});
|
||||
|
||||
return ret ? Result.success() : Result.failed(false, "新增失败");
|
||||
} catch (Exception e) {
|
||||
if(e.getMessage().contains("prepay_truck_license_customer")){
|
||||
return Result.failed("同一辆车同一天只能分配给一个客户");
|
||||
}
|
||||
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.failed(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param model PrepayTruck
|
||||
* @return Result
|
||||
*/
|
||||
public Result delete(PrepayTruck model) {
|
||||
try {
|
||||
// 如果存在逻辑删除字段 del,则只做逻辑删除,不做物理删除
|
||||
if (model.hasDelKey()) {
|
||||
return logicDel(model);
|
||||
}
|
||||
|
||||
PrepayTruck old = model.findByPk();
|
||||
|
||||
if(old == null){
|
||||
return Result.failed(false, "按主键未找到对应记录");
|
||||
}else{
|
||||
Date oldtm = old.getValidDate();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
if(oldtm.before(c.getTime())){
|
||||
return Result.failed(false, "当前日期之前的记录不能解绑");
|
||||
}
|
||||
}
|
||||
|
||||
return Result.object(model.delete());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.failed(false, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Page<Record> find(PageParam pp, Integer customer_id, Integer supermarket_id, Integer trans_co_id, String truck_license, String valid_date) {
|
||||
String selectsql = "select t.id, t.customer_id, c.name customer_name, t.truck_license, " +
|
||||
" co.name trans_co_name, t.supermarket_id, s.name supermarket_name, t.valid_date, t.create_user_id, u.name create_user_name\n";
|
||||
|
|
|
|||
|
|
@ -1237,7 +1237,7 @@ public class OrderStatService {
|
|||
* @param isprepaid 是否预付费
|
||||
* @return
|
||||
*/
|
||||
public List<Record> statCustomer(String tm, String stm, String etm, Integer supermarket_id, boolean stat_product, Integer product_id, Integer isprepaid) {
|
||||
public List<Record> statCustomer(String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, boolean stat_product, Integer product_id, Integer isprepaid) {
|
||||
String sale_sql = " select t.customer_id, sum(t.weight) weight, sum(t.total_price) total_price, count(t.sn) orderCount ";
|
||||
String temp_sql = " select t.customer_id, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price, count(t.sn) orderCount ";
|
||||
|
||||
|
|
@ -1266,6 +1266,14 @@ public class OrderStatService {
|
|||
paraTemp.add(supermarket_id);
|
||||
}
|
||||
|
||||
if (customer_id != null) {
|
||||
sale_sql += " and t.customer_id = ? \n";
|
||||
paraSale.add(customer_id);
|
||||
|
||||
temp_sql += " and t.customer_id = ? \n";
|
||||
paraTemp.add(customer_id);
|
||||
}
|
||||
|
||||
if (tm == null) {
|
||||
if (!StrKit.notBlank(stm, etm)) {
|
||||
log.error("参数错误");
|
||||
|
|
@ -1287,14 +1295,13 @@ public class OrderStatService {
|
|||
paraTemp.add(tm + "%");
|
||||
}
|
||||
|
||||
if (isprepaid != null) {
|
||||
sale_sql += " and t.isprepaid = ? \n";
|
||||
paraSale.add(isprepaid);
|
||||
|
||||
temp_sql += " and t.isprepaid = ? \n";
|
||||
paraTemp.add(isprepaid);
|
||||
}
|
||||
if (isprepaid != null) {
|
||||
sale_sql += " and t.isprepaid = ? \n";
|
||||
paraSale.add(isprepaid);
|
||||
|
||||
temp_sql += " and t.isprepaid = ? \n";
|
||||
paraTemp.add(isprepaid);
|
||||
}
|
||||
|
||||
if (stat_product) {
|
||||
if (product_id != null) {
|
||||
|
|
@ -1306,7 +1313,7 @@ public class OrderStatService {
|
|||
}
|
||||
sale_sql += " group by t.customer_id, t.product_id \n";
|
||||
temp_sql += " group by t.customer_id, t.product_id \n";
|
||||
}else {
|
||||
} else {
|
||||
sale_sql += " group by t.customer_id \n";
|
||||
temp_sql += " group by t.customer_id \n";
|
||||
}
|
||||
|
|
@ -1335,11 +1342,11 @@ public class OrderStatService {
|
|||
return list;
|
||||
}
|
||||
|
||||
public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, boolean stat_product, Integer product_id, Integer isprepaid) {
|
||||
public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, boolean stat_product, Integer product_id, Integer isprepaid) {
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet(name);
|
||||
|
||||
List<Record> list = statCustomer(tm, stm, etm, supermarket_id, stat_product, product_id, isprepaid);
|
||||
List<Record> list = statCustomer(tm, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
|
||||
int datalen = list.size();
|
||||
int end_col = stat_product ? 6 : 5; // 数据共有几列
|
||||
|
|
@ -1381,9 +1388,9 @@ public class OrderStatService {
|
|||
row.createCell(a++).setCellValue("备注");
|
||||
// 表头 end
|
||||
|
||||
double sum_weight = 0.0;
|
||||
double sum_price = 0.0;
|
||||
int sum_cnt = 0;
|
||||
double sum_weight = 0.0;
|
||||
double sum_price = 0.0;
|
||||
int sum_cnt = 0;
|
||||
|
||||
for (int i = 0; i < datalen; i++) {
|
||||
Record order = list.get(i);
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ import com.cowr.local.ssjygl.truck.TruckController;
|
|||
import com.cowr.model.Supermarket;
|
||||
import com.cowr.ssjygl.CacheData;
|
||||
import com.cowr.ssjygl.cctv.CctvController;
|
||||
import com.cowr.ssjygl.prepay.PrepayController;
|
||||
import com.cowr.local.ssjygl.prepay.PrepayController;
|
||||
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
||||
import com.cowr.ssjygl.stat.sale.OrderStatController;
|
||||
import com.cowr.local.ssjygl.stat.sale.OrderStatController;
|
||||
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
|
||||
import com.cowr.local.ssjygl.system.sysuser.SysuserController;
|
||||
import com.cowr.ssjygl.transportcompany.TransportCompanyService;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.cowr.ssjygl.prepay;
|
||||
package com.cowr.local.ssjygl.prepay;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.validator.CustomerIdValidator;
|
||||
import com.cowr.common.validator.StartAndEndTimeValidator;
|
||||
import com.cowr.common.view.ExcelRender;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.ssjygl.prepay.PrepayService;
|
||||
import com.cowr.ssjygl.prepay.prepaydetail.PrepayDetailService;
|
||||
import com.jfinal.aop.Before;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
|
@ -14,6 +14,7 @@ public class PrepayController extends BaseController {
|
|||
public void find() {
|
||||
String name = get("name");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.cowr.ssjygl.stat.sale;
|
||||
package com.cowr.local.ssjygl.stat.sale;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.validator.DayValidator;
|
||||
|
|
@ -6,7 +6,7 @@ import com.cowr.common.validator.MonthValidator;
|
|||
import com.cowr.common.validator.StartAndEndintervalValidator;
|
||||
import com.cowr.common.view.ExcelRender;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.ssjygl.supermarket.SupermarketIdValidator;
|
||||
import com.cowr.ssjygl.stat.sale.OrderStatService;
|
||||
import com.jfinal.aop.Before;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
|
|
@ -199,8 +199,8 @@ public class OrderStatController extends BaseController {
|
|||
|
||||
@Before(StartAndEndintervalValidator.class)
|
||||
public void statRangeTrans() {
|
||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
|
|
@ -210,7 +210,7 @@ public class OrderStatController extends BaseController {
|
|||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statTrans(null, stm, etm, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statTransExport("超市时段销售汇总表",null, stm, etm, supermarket_id, stat_product, product_id, isprepaid);
|
||||
Workbook wb = OrderStatService.me.statTransExport("超市时段销售汇总表", null, stm, etm, supermarket_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(stm + "_" + etm + "_超市" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
|
@ -224,14 +224,15 @@ public class OrderStatController extends BaseController {
|
|||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市日销售汇总表", tm, null, null, supermarket_id, stat_product, product_id, isprepaid);
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市日销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(tm + "_超市日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
|
@ -244,32 +245,34 @@ public class OrderStatController extends BaseController {
|
|||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市月销售汇总表", tm, null, null, supermarket_id, stat_product, product_id, isprepaid);
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市月销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(tm + "_超市月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
@Before(StartAndEndintervalValidator.class)
|
||||
public void statRangeCustomer() {
|
||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市时段销售汇总表",null, stm, etm, supermarket_id, stat_product, product_id, isprepaid);
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市时段销售汇总表", null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(stm + "_" + etm + "_超市" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.cowr.service.ssjygl.main;
|
||||
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||
|
|
@ -9,12 +10,39 @@ import com.jfinal.core.Controller;
|
|||
import com.jfinal.log.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AuthInterceptor implements Interceptor {
|
||||
private static Log log = Log.getLog(AuthInterceptor.class);
|
||||
private String ENV;
|
||||
|
||||
private static Map<Integer, List<String>> userTypeUrlMap;
|
||||
|
||||
static {
|
||||
userTypeUrlMap = new HashMap<>();
|
||||
userTypeUrlMap.put(UserTypeEnum.CUSTOMER.getTypeid(), new ArrayList<String>() {{
|
||||
add("/order/ordercluster/find");
|
||||
add("/order/ordercluster/get");
|
||||
add("/order/ordercluster/findChildren");
|
||||
|
||||
add("/order/temp/find");
|
||||
add("/order/temp/get");
|
||||
|
||||
add("/stat/sale/statDayCustomer");
|
||||
add("/stat/sale/daydetail");
|
||||
|
||||
add("/prepay/find");
|
||||
add("/prepay/consumption");
|
||||
add("/prepay/flow");
|
||||
add("/prepay/prepaydetail");
|
||||
add("/prepaytruck/find");
|
||||
add("/prepaytruck/save");
|
||||
add("/prepaytruck/del");
|
||||
}});
|
||||
}
|
||||
|
||||
public AuthInterceptor(String ENV) {
|
||||
this.ENV = ENV;
|
||||
}
|
||||
|
|
@ -22,41 +50,48 @@ public class AuthInterceptor implements Interceptor {
|
|||
@Override
|
||||
public void intercept(Invocation inv) {
|
||||
try {
|
||||
if ("dev".equals(this.ENV)) {
|
||||
inv.invoke();
|
||||
} else {
|
||||
Controller c = inv.getController();
|
||||
String token = c.get("token");
|
||||
// if ("dev".equals(this.ENV)) {
|
||||
// inv.invoke();
|
||||
// } else {
|
||||
Controller c = inv.getController();
|
||||
String token = c.get("token");
|
||||
|
||||
//避免有提交文件的获取不到 token
|
||||
if (token == null) {
|
||||
try {
|
||||
c.getFile();
|
||||
} catch (Exception ignored) {
|
||||
//避免有提交文件的获取不到 token
|
||||
if (token == null) {
|
||||
try {
|
||||
c.getFile();
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (token == null) {
|
||||
c.renderJson(Result.noauth());
|
||||
return;
|
||||
}
|
||||
|
||||
Sysuser sysuser = SysuserSyncService.me.getSysuserByToken(token);
|
||||
|
||||
if (sysuser == null) {
|
||||
c.renderJson(Result.noauth());
|
||||
return;
|
||||
}
|
||||
|
||||
// 有有效的 token 了,还要验证当前的 token 可不可以访问当前的 url
|
||||
System.out.println("inv.getController().getRequest().getRequestURI():" + inv.getController().getRequest().getRequestURI());
|
||||
|
||||
inv.invoke();
|
||||
}
|
||||
|
||||
if (token == null) {
|
||||
c.renderJson(Result.noauth());
|
||||
return;
|
||||
}
|
||||
|
||||
Sysuser sysuser = SysuserSyncService.me.getSysuserByToken(token);
|
||||
|
||||
if (sysuser == null) {
|
||||
c.renderJson(Result.noauth());
|
||||
return;
|
||||
}
|
||||
|
||||
// 有有效的 token 了,还要验证当前的 token 可不可以访问当前的 url
|
||||
System.out.println("inv.getController().getRequest().getRequestURI():" + inv.getController().getRequest().getRequestURI());
|
||||
// 对客户账户的访问进行限制
|
||||
if (userTypeUrlMap.containsKey(sysuser.getType())
|
||||
&& !userTypeUrlMap.get(sysuser.getType()).contains(inv.getController().getRequest().getRequestURI())
|
||||
) {
|
||||
c.renderJson(Result.permissionDenied());
|
||||
return;
|
||||
}
|
||||
|
||||
inv.invoke();
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
inv.getController().renderJson(Result.failedstr("服务端异常: %s", e.getMessage() ));
|
||||
inv.getController().renderJson(Result.failedstr("服务端异常: %s", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ import com.cowr.ssjygl.CacheData;
|
|||
import com.cowr.common.Const;
|
||||
import com.cowr.common.plugin.QuartzPlugin;
|
||||
import com.cowr.ssjygl.cctv.CctvController;
|
||||
import com.cowr.ssjygl.prepay.PrepayController;
|
||||
import com.cowr.service.ssjygl.prepay.PrepayController;
|
||||
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
||||
import com.cowr.ssjygl.stat.sale.OrderStatController;
|
||||
import com.cowr.service.ssjygl.stat.sale.OrderStatController;
|
||||
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
|
||||
import com.cowr.ssjygl.transportcompany.TransportCompanyService;
|
||||
import com.cowr.ssjygl.transprice.TransPriceService;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.cowr.service.ssjygl.order.ordercluster;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.enums.RoleEnum;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Ordercluster;
|
||||
|
|
@ -18,7 +20,7 @@ public class OrderclusterController extends BaseController {
|
|||
* 新增 ordercluster 订单簇 - 集团客户订单
|
||||
*/
|
||||
@Before(OrderclusterValidator.class)
|
||||
public void save(){
|
||||
public void save() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
if (tokenuser == null) {
|
||||
|
|
@ -34,7 +36,7 @@ public class OrderclusterController extends BaseController {
|
|||
* 修改 ordercluster 订单簇 - 集团客户订单
|
||||
*/
|
||||
@Before(OrderclusterEditValidator.class)
|
||||
public void edit(){
|
||||
public void edit() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
if (tokenuser == null) {
|
||||
|
|
@ -49,17 +51,28 @@ public class OrderclusterController extends BaseController {
|
|||
/**
|
||||
* 分页查找 ordercluster 订单簇 - 集团客户订单
|
||||
*/
|
||||
public void find(){
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
String customer_name = get("customer_name");
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
Integer state = getInt("state");
|
||||
Integer product_id = getInt("product_id");
|
||||
public void find() {
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
String customer_name = get("customer_name");
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer state = getInt("state");
|
||||
Integer product_id = getInt("product_id");
|
||||
Integer trans_co_id = getInt("trans_co_id");
|
||||
renderJson(Result.object(OrderclusterService.me.find(pp, supermarket_id, trans_co_id, customer_id, customer_name, stm, etm, product_id, state)));
|
||||
renderJson(Result.object(OrderclusterService.me.find(pp, supermarket_id, trans_co_id, customer_id, customer_name, stm, etm, product_id, state)));
|
||||
}
|
||||
|
||||
public void findChildren() {
|
||||
|
|
@ -79,12 +92,19 @@ public class OrderclusterController extends BaseController {
|
|||
* 按主键查找单个对象 ordercluster 订单簇 - 集团客户订单
|
||||
*/
|
||||
@Before(OrderclusterPKValidator.class)
|
||||
public void get(){
|
||||
Ordercluster model = getModel(Ordercluster.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterService.me.findByPk(model));
|
||||
public void get() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
}
|
||||
|
||||
renderJson(OrderclusterService.me.get(getInt("id"), tokenuser));
|
||||
}
|
||||
|
||||
public void cancel(){
|
||||
public void cancel() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
if (tokenuser == null) {
|
||||
|
|
@ -97,7 +117,7 @@ public class OrderclusterController extends BaseController {
|
|||
renderJson(Result.object(OrderclusterSyncService.me.cancel(ordercluster_id, tokenuser)));
|
||||
}
|
||||
|
||||
public void complete(){
|
||||
public void complete() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
if (tokenuser == null) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.cowr.service.ssjygl.order.ordersale;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||
import com.cowr.ssjygl.order.ordersale.OrderSalePKValidator;
|
||||
import com.cowr.ssjygl.order.ordersale.OrderSaleService;
|
||||
import com.jfinal.aop.Before;
|
||||
|
|
@ -29,6 +32,17 @@ public class OrderSaleController extends BaseController {
|
|||
Integer trans_co_id = getInt("trans_co_id");
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
renderJson(Result.object(OrderSaleService.me.find(pp, sn, truck_license, supermarket_id, trans_co_id, customer_id, customer_name, stm, etm, isprepaid, product_id, state)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.cowr.service.ssjygl.order.ordertemp;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||
import com.cowr.ssjygl.order.ordertemp.OrderTempPKValidator;
|
||||
import com.cowr.ssjygl.order.ordertemp.OrderTempService;
|
||||
import com.jfinal.aop.Before;
|
||||
|
|
@ -10,7 +13,15 @@ import com.jfinal.aop.Before;
|
|||
public class OrderTempController extends BaseController {
|
||||
@Before(OrderTempPKValidator.class)
|
||||
public void get() {
|
||||
renderJson(Result.object(OrderTempService.me.get(get("sn"))));
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
}
|
||||
|
||||
renderJson(OrderTempService.me.get(get("sn"), tokenuser));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -28,6 +39,17 @@ public class OrderTempController extends BaseController {
|
|||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, customer_id, customer_name, stm, etm, isprepaid, product_id, state)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,121 @@
|
|||
package com.cowr.service.ssjygl.prepay;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.validator.StartAndEndTimeValidator;
|
||||
import com.cowr.common.view.ExcelRender;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||
import com.cowr.ssjygl.prepay.PrepayService;
|
||||
import com.cowr.ssjygl.prepay.prepaydetail.PrepayDetailService;
|
||||
import com.jfinal.aop.Before;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
public class PrepayController extends BaseController {
|
||||
public void find() {
|
||||
String name = get("name");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
Double start = getParaToDouble("start");
|
||||
Double end = getParaToDouble("end");
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, supermarket_id, stm, etm, start, end)));
|
||||
}
|
||||
|
||||
@Before(StartAndEndTimeValidator.class)
|
||||
public void consumption() {
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm)));
|
||||
} else {
|
||||
Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm);
|
||||
render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
@Before(StartAndEndTimeValidator.class)
|
||||
public void flow() {
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.success(PrepayService.me.flow(customer_id, stm, etm)));
|
||||
} else {
|
||||
Workbook wb = PrepayService.me.flowExport(customer_id, stm, etm);
|
||||
render(new ExcelRender("客户流水_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回 prepay_detail 预付费客户付费详情
|
||||
*/
|
||||
@Before(StartAndEndTimeValidator.class)
|
||||
public void prepaydetail() {
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(PrepayDetailService.me.list(customer_id, stm, etm)));
|
||||
} else {
|
||||
Workbook wb = PrepayDetailService.me.listExport(customer_id, stm, etm);
|
||||
render(new ExcelRender("付费详情_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.cowr.service.ssjygl.prepay.prepaytruck;
|
|||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.PrepayTruck;
|
||||
|
|
@ -42,15 +43,19 @@ public class PrepayTruckController extends BaseController {
|
|||
*/
|
||||
@Before(PrepayTruckValidator.class)
|
||||
public void save() {
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
String trucks = get("trucks");
|
||||
int customer_id = getInt("customer_id");
|
||||
int supermarket_id = getInt("supermarket_id");
|
||||
Date valid_date = getDate("valid_date");
|
||||
|
||||
|
|
@ -79,6 +84,17 @@ public class PrepayTruckController extends BaseController {
|
|||
@Before(DayValidator.class)
|
||||
public void find() {
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer trans_co_id = getInt("trans_co_id");
|
||||
String truck_license = getUpperCaseVal("truck_license");
|
||||
|
|
@ -110,6 +126,17 @@ public class PrepayTruckController extends BaseController {
|
|||
*/
|
||||
public void list() {
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer trans_co_id = getInt("trans_co_id");
|
||||
String truck_license = getUpperCaseVal("truck_license");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.cowr.service.ssjygl.prepay.prepaytruck;
|
|||
|
||||
import com.cowr.common.enums.Enums;
|
||||
import com.cowr.common.enums.OrderTypeEnum;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.utils.DateTimeUtil;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.*;
|
||||
|
|
@ -154,6 +155,12 @@ public class PrepayTruckSyncService extends BaseSyncService {
|
|||
return Result.failed("未找到记录");
|
||||
}
|
||||
|
||||
if (sysuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()
|
||||
&& !sysuser.getEntityId().equals(old.getCustomerId())
|
||||
) {
|
||||
return Result.failed("操作失败");
|
||||
}
|
||||
|
||||
String valid_date = DateTimeUtil.sdf.get().format(old.getValidDate());
|
||||
List<Ordercluster> undonlist = OrderclusterService.me.undonlist(old.getSupermarketId(), old.getCustomerId(), valid_date);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,337 @@
|
|||
package com.cowr.service.ssjygl.stat.sale;
|
||||
|
||||
import com.cowr.common.base.BaseController;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.validator.DayValidator;
|
||||
import com.cowr.common.validator.MonthValidator;
|
||||
import com.cowr.common.validator.StartAndEndintervalValidator;
|
||||
import com.cowr.common.view.ExcelRender;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||
import com.cowr.ssjygl.stat.sale.OrderStatService;
|
||||
import com.jfinal.aop.Before;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
public class OrderStatController extends BaseController {
|
||||
|
||||
/**
|
||||
* 日销售明细
|
||||
*/
|
||||
@Before(DayValidator.class)
|
||||
public void daydetail() {
|
||||
String tm = get("tm");
|
||||
String customer_name = get("customer_name");
|
||||
String truck_license = getUpperCaseVal("truck_license");
|
||||
String sn = get("sn");
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer trans_co_id = getInt("trans_co_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer type = getInt("type");
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
Integer product_id = getInt("product_id");
|
||||
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.daydetail(
|
||||
tm,
|
||||
supermarket_id,
|
||||
trans_co_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
type,
|
||||
truck_license,
|
||||
isprepaid,
|
||||
product_id,
|
||||
sn
|
||||
)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.daydetailExport(
|
||||
tm,
|
||||
supermarket_id,
|
||||
trans_co_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
type,
|
||||
truck_license,
|
||||
isprepaid,
|
||||
product_id,
|
||||
sn
|
||||
);
|
||||
render(new ExcelRender(tm + "_日销售明细_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售月统计,超市/客户的矩阵
|
||||
*/
|
||||
@Before(MonthValidator.class)
|
||||
public void monthgrid() {
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0);
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.monthgridExport(tm, supermarket_id, customer_id);
|
||||
render(new ExcelRender(tm + "_销售月汇总_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 销售日统计
|
||||
*/
|
||||
@Before(DayValidator.class)
|
||||
public void daystat() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0);
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.salestat(tm)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.daysalestatExport(tm);
|
||||
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售月统计
|
||||
*/
|
||||
@Before(MonthValidator.class)
|
||||
public void monthstat() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0);
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.salestat(tm)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.monthsalestatExport(tm);
|
||||
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售日统计
|
||||
*/
|
||||
@Before(DayValidator.class)
|
||||
public void daystatCustomer() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0);
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm);
|
||||
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售月统计
|
||||
*/
|
||||
@Before(MonthValidator.class)
|
||||
public void monthstatCustomer() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0);
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm);
|
||||
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售月逐日统计
|
||||
*/
|
||||
@Before(MonthValidator.class)
|
||||
public void mdstat() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0);
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.mdstat(tm)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.mdstatExport(tm);
|
||||
render(new ExcelRender(tm + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日销售汇总
|
||||
*/
|
||||
@Before(DayValidator.class)
|
||||
public void statDayTrans() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statTrans(tm, null, null, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statTransExport("超市日销售汇总表", tm, null, null, supermarket_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(tm + "_超市日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 月销售统计
|
||||
*/
|
||||
@Before(MonthValidator.class)
|
||||
public void statMonthTrans() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statTrans(tm, null, null, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statTransExport("超市月销售汇总表", tm, null, null, supermarket_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(tm + "_超市月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
@Before(StartAndEndintervalValidator.class)
|
||||
public void statRangeTrans() {
|
||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statTrans(null, stm, etm, supermarket_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statTransExport("超市时段销售汇总表",null, stm, etm, supermarket_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(stm + "_" + etm + "_超市" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日销售汇总,按客户
|
||||
*/
|
||||
@Before(DayValidator.class)
|
||||
public void statDayCustomer() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市日销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(tm + "_超市日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 月销售统计
|
||||
*/
|
||||
@Before(MonthValidator.class)
|
||||
public void statMonthCustomer() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市月销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(tm + "_超市月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
||||
@Before(StartAndEndintervalValidator.class)
|
||||
public void statRangeCustomer() {
|
||||
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
Integer customer_id = getInt("customer_id");
|
||||
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
// 是客户账户
|
||||
if (tokenuser == null) {
|
||||
renderJson(Result.noauth());
|
||||
return;
|
||||
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
customer_id = tokenuser.getEntityId();
|
||||
}
|
||||
|
||||
Integer product_id = getInt("product_id");
|
||||
boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer isprepaid = getInt("isprepaid");
|
||||
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.statCustomerExport("超市时段销售汇总表",null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid);
|
||||
render(new ExcelRender(stm + "_" + etm + "_超市" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,13 +34,13 @@ import java.util.regex.Pattern;
|
|||
* PrimaryKey: id
|
||||
*/
|
||||
public class SysuserSyncService extends BaseSyncService {
|
||||
private static Log log = Log.getLog(SysuserSyncService.class);
|
||||
private static final String pwdkey = "sysuser";
|
||||
public static final String tablename = "sysuser";
|
||||
public static final SysuserSyncService me = new SysuserSyncService();
|
||||
private static final Pattern rolepattern = Pattern.compile("[0-2]{3}");
|
||||
// private static int expireAt = 24 * 60 * 60; // 超时时间,单位秒
|
||||
private static int expireAt = 24 * 60 * 60; // 超时时间,单位秒
|
||||
private static Log log = Log.getLog(SysuserSyncService.class);
|
||||
private static final String pwdkey = "sysuser";
|
||||
public static final String tablename = "sysuser";
|
||||
public static final SysuserSyncService me = new SysuserSyncService();
|
||||
private static final Pattern rolepattern = Pattern.compile("[0-2]{3}");
|
||||
private static int expireAt = 24 * 60 * 60; // 超时时间,单位秒
|
||||
private static int customerExpireAt = 30 * 60; // 超时时间,单位秒,客户账户 token 有效时间
|
||||
|
||||
public String redisbasekey() {
|
||||
return Config.dbprop.get("redis.basekey") + Const.REDIS_SEPARATE + tablename + Const.REDIS_SEPARATE;
|
||||
|
|
@ -246,13 +246,13 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
model.setPassword(getPwdMD5(model.getPhone(), Const.DEFAULT_PASSWORD));
|
||||
model.remove("id"); // 避免前端传 id
|
||||
|
||||
boolean ret =Db.tx(new IAtom() {
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() throws SQLException {
|
||||
try {
|
||||
return model.save() && SyncTaskService.me.save(new SyncTask().addSaveData(model))
|
||||
&& ModifyLogService.me.save(model, null, Enums.DataOpType.SAVE.getId(), tokenuser);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -314,14 +314,14 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
}
|
||||
|
||||
// TODO: 修改手机号码,必须重置密码
|
||||
if(model.getPhone() != null && !model.getPhone().equals(chkobj.getPhone())){
|
||||
if (model.getPhone() != null && !model.getPhone().equals(chkobj.getPhone())) {
|
||||
chkobj.setPassword(getPwdMD5(model.getPhone(), Const.DEFAULT_PASSWORD));
|
||||
}
|
||||
|
||||
model.remove("password"); // 更新用户信息,不更新密码
|
||||
|
||||
for(String key : model._getAttrNames()){
|
||||
if(model.get(key) != null){
|
||||
for (String key : model._getAttrNames()) {
|
||||
if (model.get(key) != null) {
|
||||
chkobj.set(key, model.get(key));
|
||||
}
|
||||
}
|
||||
|
|
@ -371,7 +371,7 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
}
|
||||
|
||||
Sysuser sysuser = Sysuser.dao.findById(model.get("id"));
|
||||
Sysuser old = sysuser.clone();
|
||||
Sysuser old = sysuser.clone();
|
||||
|
||||
sysuser.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_VALID); // 逻辑删除字段统一用 del
|
||||
|
||||
|
|
@ -562,7 +562,11 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
out.set("tm", System.currentTimeMillis());
|
||||
out.set("user", sysuser);
|
||||
|
||||
Redis.use().setex(tokenrediskey(token), expireAt, sysuser);
|
||||
if (sysuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
Redis.use().setex(tokenrediskey(token), customerExpireAt, sysuser);
|
||||
}else{
|
||||
Redis.use().setex(tokenrediskey(token), expireAt, sysuser);
|
||||
}
|
||||
|
||||
return Result.success(new AuthResult(token, sysuser));
|
||||
} catch (Exception e) {
|
||||
|
|
@ -581,7 +585,11 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
Sysuser sysuser = Redis.use().get(tokenrediskey(token));
|
||||
|
||||
if (sysuser != null) {
|
||||
Redis.use().setex(tokenrediskey(token), expireAt, sysuser); // 刷新token
|
||||
if (sysuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
Redis.use().setex(tokenrediskey(token), customerExpireAt, sysuser); // 刷新token
|
||||
} else {
|
||||
Redis.use().setex(tokenrediskey(token), expireAt, sysuser); // 刷新token
|
||||
}
|
||||
}
|
||||
|
||||
return sysuser;
|
||||
|
|
@ -683,28 +691,28 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
return Db.find("select * " + sqlbuf.toString(), paraList.toArray());
|
||||
}
|
||||
|
||||
public Result register(Sysuser sysuser, Customer customer, CustomerReceiver receiver){
|
||||
if(sysuser.checkDuplicate("phone")){
|
||||
public Result register(Sysuser sysuser, Customer customer, CustomerReceiver receiver) {
|
||||
if (sysuser.checkDuplicate("phone")) {
|
||||
return Result.failedstr("手机号 %s 已存在", sysuser.getPhone());
|
||||
}
|
||||
|
||||
customer.setName(customer.getTexpayerName());
|
||||
|
||||
if(customer.checkDuplicate("name")){
|
||||
if (customer.checkDuplicate("name")) {
|
||||
return Result.failed("用户已存在");
|
||||
}
|
||||
|
||||
if(customer.checkDuplicate("texpayer_name")){
|
||||
if (customer.checkDuplicate("texpayer_name")) {
|
||||
return Result.failed("用户已存在");
|
||||
}
|
||||
|
||||
// 开专票的,必填验证
|
||||
if(customer.getInvoiceType() == 2){
|
||||
if(customer.checkDuplicate("texpayer_num")){
|
||||
if (customer.getInvoiceType() == 2) {
|
||||
if (customer.checkDuplicate("texpayer_num")) {
|
||||
return Result.failed("用户已存在");
|
||||
}
|
||||
|
||||
if(customer.checkDuplicate("bank_account")){
|
||||
if (customer.checkDuplicate("bank_account")) {
|
||||
return Result.failed("用户已存在");
|
||||
}
|
||||
}
|
||||
|
|
@ -715,10 +723,10 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() {
|
||||
try{
|
||||
try {
|
||||
boolean ret = customer.save();
|
||||
|
||||
if(!ret){
|
||||
if (!ret) {
|
||||
log.debug("客户信息保存失败");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -730,7 +738,7 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
|
||||
ret = sysuser.save() && receiver.save();
|
||||
|
||||
if(!ret){
|
||||
if (!ret) {
|
||||
log.debug("用户或者收获信息保存失败");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -741,7 +749,7 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
synctask.addSaveData(receiver);
|
||||
|
||||
return SyncTaskService.me.save(synctask);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue