wuwenxiong 2021-12-30 10:23:29 +08:00
parent 50b6d73e34
commit 5ed374e959
14 changed files with 188 additions and 274 deletions

View File

@ -117,7 +117,7 @@ public class PoiDynamicMarge {
}
}
Cell cell = row.createCell(i, CellType.STRING);
if (value instanceof java.math.BigDecimal ) {
if (value instanceof java.math.BigDecimal) {
if ((new BigDecimal(0)).compareTo((BigDecimal)value) == 0) {
value = "0";
}

View File

@ -1,14 +0,0 @@
package com.cowr.model;
import com.cowr.model.base.BasePresellPug;
/**
* Generated by COWR Thu Dec 16 15:44:52 CST 2021
* TableName: presell_pug
* Remarks:
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class PresellPug extends BasePresellPug<PresellPug> {
public static final PresellPug dao = new PresellPug().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BasePresellPugDetail;
/**
* Generated by COWR Thu Dec 16 15:44:52 CST 2021
* TableName: presell_pug
* Remarks:
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class PresellPugDetail extends BasePresellPugDetail<PresellPugDetail> {
public static final PresellPugDetail dao = new PresellPugDetail().dao();
}

View File

@ -93,7 +93,7 @@ public class _MappingKit {
arp.addMapping("product_price_modify", "id", ProductPriceModify.class);
arp.addMapping("product_price_modify_log", "id", ProductPriceModifyLog.class);
arp.addMapping("presell_order", "id", PresellOrder.class);
arp.addMapping("presell_pug", "id", PresellPug.class);
arp.addMapping("presell_pug_detail", "id", PresellPugDetail.class);
}
}

View File

@ -11,9 +11,9 @@ import com.alibaba.fastjson.annotation.JSONField;
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public abstract class BasePresellPug<M extends BasePresellPug<M>> extends BaseModel<M> implements IBean {
public abstract class BasePresellPugDetail<M extends BasePresellPugDetail<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "presell_pug";
public static final String tablename = "presell_pug_detail";
@JSONField(serialize=false)
public String getTablename(){

View File

@ -1,9 +1,9 @@
package com.cowr.ssjygl.presellpug;
package com.cowr.ssjygl.presellpugdetail;
import com.cowr.common.Const;
import com.cowr.common.base.BaseService;
import com.cowr.common.view.PageParam;
import com.cowr.model.PresellPug;
import com.cowr.model.PresellPugDetail;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
@ -19,12 +19,12 @@ import java.util.List;
* Remarks:
* PrimaryKey: id
*/
public class PresellPugService extends BaseService {
public static final PresellPugService me = new PresellPugService();
public class PresellPugDetailService extends BaseService {
public static final PresellPugDetailService me = new PresellPugDetailService();
public Page<Record> find(PageParam pp, Integer customer_id, Integer supermarket_id, String name, String stm, String etm) {
String selectsql = "select t.*, c.name customer_name, s.name supermarket_name, d.name product_name, c.address, c.texpayer_name, c.texpayer_num, c.memo \n";
String fromsql = " from presell_pug t \n" +
String fromsql = " from presell_pug_detail t \n" +
" left join presell_order o on t.presell_order_id = o.id \n" +
" left join supermarket s on o.supermarket_id = s.id \n" +
" left join product d on o.supermarket_id = d.id \n" +
@ -60,7 +60,7 @@ public class PresellPugService extends BaseService {
String findSql = selectsql + fromsql;
// 前端传了排序字段,并且排序字段存在相关表中
if (StrKit.notBlank(pp.getSort_field()) && PresellPug.dao.hasColunm(pp.getSort_field())) {
if (StrKit.notBlank(pp.getSort_field()) && PresellPugDetail.dao.hasColunm(pp.getSort_field())) {
findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field();
if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) {
@ -75,19 +75,7 @@ public class PresellPugService extends BaseService {
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
}
public List<PresellPug> list() {
return PresellPug.dao.find("select * from presell_pug");
}
public BigDecimal countPugAmount(String uuid) {
BigDecimal ret = new BigDecimal(0);
if (StrKit.isBlank(uuid)) {
return ret;
}
BigDecimal rec = Db.queryBigDecimal(" select sum(amount) from presell_pug where presell_order_id = ?", uuid);
if (rec != null) {
return rec;
}
return ret;
public List<PresellPugDetail> list() {
return PresellPugDetail.dao.find("select * from presell_pug_detail");
}
}

View File

@ -1,8 +1,8 @@
package com.cowr.local.ssjygl.presellpug;
package com.cowr.local.ssjygl.presellpugdetail;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.ssjygl.presellpug.PresellPugService;
import com.cowr.ssjygl.presellpugdetail.PresellPugDetailService;
import com.jfinal.core.Controller;
/**
@ -11,7 +11,7 @@ import com.jfinal.core.Controller;
* Remarks:
* PrimaryKey: id
*/
public class PresellPugController extends Controller {
public class PresellPugDetailController extends Controller {
/**
* presell_pug
@ -23,13 +23,13 @@ public class PresellPugController extends Controller {
String stm = get("stm");
String etm = get("etm");
PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(PresellPugService.me.find(pp, customer_id, supermarket_id, name, stm, etm)));
renderJson(Result.object(PresellPugDetailService.me.find(pp, customer_id, supermarket_id, name, stm, etm)));
}
/**
* presell_pug
*/
public void list(){
renderJson(Result.object(PresellPugService.me.list()));
renderJson(Result.object(PresellPugDetailService.me.list()));
}
}

View File

@ -6,7 +6,7 @@ import com.cowr.common.enums.Enums;
import com.cowr.common.view.Result;
import com.cowr.model.*;
import com.cowr.service.ssjygl.base.BaseSyncService;
import com.cowr.service.ssjygl.presellpug.PresellPugService;
import com.cowr.service.ssjygl.presellpugdetail.PresellPugDetailService;
import com.cowr.service.ssjygl.synctask.SyncTaskService;
import com.cowr.ssjygl.modifylog.ModifyLogService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
@ -17,7 +17,6 @@ import com.jfinal.plugin.activerecord.IAtom;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -181,7 +180,7 @@ public class PresellOrderSyncService extends BaseSyncService {
}
// 如果预售单已经进行了配额则不能删除
List<PresellPug> list = PresellPugService.me.getByPresellOrderId(model.getId());
List<PresellPugDetail> list = PresellPugDetailService.me.getByPresellOrderId(model.getId());
if (list.size() > 0) {
return Result.failed(false, "预售单已配额");
}

View File

@ -1,73 +0,0 @@
package com.cowr.service.ssjygl.presellpug;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.model.PresellPug;
import com.cowr.ssjygl.presellpug.PresellPugService;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Dec 16 15:44:53 CST 2021
* TableName: presell_pug
* Remarks:
* PrimaryKey: id
*/
public class PresellPugController extends Controller {
/**
* presell_pug
*/
@Before(PresellPugValidator.class)
public void save(){
PresellPug model = getModel(PresellPug.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugService.me.save(model));
}
/**
* presell_pug
*/
@Before(PresellPugPKValidator.class)
public void del(){
PresellPug model = getModel(PresellPug.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugService.me.delete(model));
}
/**
* presell_pug
*/
@Before(PresellPugPKValidator.class)
public void restore(){
PresellPug model = getModel(PresellPug.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugService.me.restore(model));
}
/**
* presell_pug
*/
@Before(PresellPugValidator.class)
public void edit(){
PresellPug model = getModel(PresellPug.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugService.me.update(model));
}
/**
* presell_pug
*/
public void find(){
Integer customer_id = getInt("customer_id");
Integer supermarket_id = getInt("supermarket_id");
String name = get("name");
String stm = get("stm");
String etm = get("etm");
PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(PresellPugService.me.find(pp, customer_id, supermarket_id, name, stm, etm)));
}
/**
* presell_pug
*/
public void list(){
renderJson(Result.object(PresellPugService.me.list()));
}
}

View File

@ -1,147 +0,0 @@
package com.cowr.service.ssjygl.presellpug;
import com.cowr.common.Const;
import com.cowr.common.base.BaseService;
import com.cowr.common.enums.Enums;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.model.PresellOrder;
import com.cowr.model.PresellPug;
import com.cowr.model.Sysuser;
import com.cowr.ssjygl.modifylog.ModifyLogService;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IAtom;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* Generated by COWR Thu Dec 16 15:44:53 CST 2021
* TableName: presell_pug
* Remarks:
* PrimaryKey: id
*/
public class PresellPugService extends BaseService {
private static final Log log = Log.getLog(PresellPugService.class);
public static final PresellPugService me = new PresellPugService();
public Result save(PresellPug model, Sysuser sysuser) {
try {
String presellOrderId = model.getPresellOrderId();
PresellOrder order = PresellOrder.dao.findById(presellOrderId);
if (order == null) {
return Result.failed(false, "未找到对应的预售单");
}
BigDecimal amount = order.getPresellAmount();
model.setAmount(amount);
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try {
boolean ret = model.save();
if (ret) {
ret = ModifyLogService.me.save(model, null, Enums.DataOpType.SAVE.getId(), sysuser);
}
return ret;
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}
});
return ret ? Result.object(model) : Result.failed(false, "新增失败");
} catch (Exception e) {
log.error(e.getMessage(), e);
if (e.getMessage().contains("PRIMARY")) {
return Result.failed(false, "主键冲突");
} else {
return Result.failed(false, e.getMessage());
}
}
}
public Page<Record> find(PageParam pp, Integer customer_id, Integer supermarket_id, String name, String stm, String etm) {
String selectsql = "select t.*, c.name customer_name, s.name supermarket_name, d.name product_name, c.address, c.texpayer_name, c.texpayer_num, c.memo \n";
String fromsql = " from presell_pug t \n" +
" left join presell_order o on t.presell_order_id = o.id \n" +
" left join supermarket s on o.supermarket_id = s.id \n" +
" left join product d on o.supermarket_id = d.id \n" +
" where 1=1 \n";
List<Object> paraList = new ArrayList<>();
if (StrKit.notBlank(name)) {
fromsql += " and c.name like ? \n";
paraList.add("%" + name.trim() + "%");
}
if (supermarket_id != null) {
fromsql += " and s.id = ?";
paraList.add(supermarket_id);
}
if (customer_id != null) {
fromsql += " and c.id = ?";
paraList.add(customer_id);
}
if (StrKit.notBlank(stm)) {
fromsql += " and t.create_time >= ?";
paraList.add(stm);
}
if (StrKit.notBlank(etm)) {
fromsql += " and t.create_time <= ?";
paraList.add(etm);
}
String totalRowSql = "select count(*) " + fromsql;
String findSql = selectsql + fromsql;
// 前端传了排序字段,并且排序字段存在相关表中
if (StrKit.notBlank(pp.getSort_field()) && PresellPug.dao.hasColunm(pp.getSort_field())) {
findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field();
if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) {
findSql += " " + Const.ORDER_BY_ASC;
} else {
findSql += " " + Const.ORDER_BY_DESC;
}
} else {
findSql += " order by t.create_time desc";
}
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
}
public List<PresellPug> list() {
return PresellPug.dao.find("select * from presell_pug");
}
public BigDecimal countPugAmount(String uuid) {
BigDecimal ret = new BigDecimal(0);
if (StrKit.isBlank(uuid)) {
return ret;
}
BigDecimal rec = Db.queryBigDecimal(" select sum(amount) from presell_pug where presell_order_id = ?", uuid);
if (rec != null) {
return rec;
}
return ret;
}
public List<PresellPug> getByPresellOrderId(String id) {
List<PresellPug> ret = new ArrayList<>();
if (StrKit.isBlank(id)) {
return ret;
}
return PresellPug.dao.find("select * from presell_pug where presell_order_id = ?", id);
}
}

View File

@ -0,0 +1,73 @@
package com.cowr.service.ssjygl.presellpugdetail;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.model.PresellPugDetail;
import com.cowr.ssjygl.presellpugdetail.PresellPugDetailService;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Dec 16 15:44:53 CST 2021
* TableName: presell_pug
* Remarks:
* PrimaryKey: id
*/
public class PresellPugDetailController extends Controller {
/**
* presell_pug
*/
@Before(PresellPugDetailValidator.class)
public void save(){
PresellPugDetail model = getModel(PresellPugDetail.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugDetailService.me.save(model));
}
/**
* presell_pug
*/
@Before(PresellPugDetailPKValidator.class)
public void del(){
PresellPugDetail model = getModel(PresellPugDetail.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugDetailService.me.delete(model));
}
/**
* presell_pug
*/
@Before(PresellPugDetailPKValidator.class)
public void restore(){
PresellPugDetail model = getModel(PresellPugDetail.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugDetailService.me.restore(model));
}
/**
* presell_pug
*/
@Before(PresellPugDetailValidator.class)
public void edit(){
PresellPugDetail model = getModel(PresellPugDetail.class, "", true); // 忽略不在model中的字段
renderJson(PresellPugDetailService.me.update(model));
}
/**
* presell_pug
*/
public void find(){
Integer customer_id = getInt("customer_id");
Integer supermarket_id = getInt("supermarket_id");
String name = get("name");
String stm = get("stm");
String etm = get("etm");
PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(PresellPugDetailService.me.find(pp, customer_id, supermarket_id, name, stm, etm)));
}
/**
* presell_pug
*/
public void list(){
renderJson(Result.object(PresellPugDetailService.me.list()));
}
}

View File

@ -1,4 +1,4 @@
package com.cowr.service.ssjygl.presellpug;
package com.cowr.service.ssjygl.presellpugdetail;
import com.cowr.common.validator.CrudParamValidator;
@ -11,7 +11,7 @@ import com.jfinal.core.Controller;
* Remarks:
* PrimaryKey: id
*/
public class PresellPugPKValidator extends CrudParamValidator {
public class PresellPugDetailPKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("id", "id", "id 必填");

View File

@ -0,0 +1,74 @@
package com.cowr.service.ssjygl.presellpugdetail;
import com.cowr.common.base.BaseService;
import com.cowr.common.enums.Enums;
import com.cowr.common.view.Result;
import com.cowr.model.PresellOrder;
import com.cowr.model.PresellPugDetail;
import com.cowr.model.Sysuser;
import com.cowr.ssjygl.modifylog.ModifyLogService;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IAtom;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* Generated by COWR Thu Dec 16 15:44:53 CST 2021
* TableName: presell_pug
* Remarks:
* PrimaryKey: id
*/
public class PresellPugDetailService extends BaseService {
private static final Log log = Log.getLog(PresellPugDetailService.class);
public static final PresellPugDetailService me = new PresellPugDetailService();
public Result save(PresellPugDetail model, Sysuser sysuser) {
try {
String presellOrderId = model.getPresellOrderId();
PresellOrder order = PresellOrder.dao.findById(presellOrderId);
if (order == null) {
return Result.failed(false, "未找到对应的预售单");
}
BigDecimal amount = order.getPresellAmount();
model.setAmount(amount);
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try {
boolean ret = model.save();
if (ret) {
ret = ModifyLogService.me.save(model, null, Enums.DataOpType.SAVE.getId(), sysuser);
}
return ret;
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}
});
return ret ? Result.object(model) : Result.failed(false, "新增失败");
} catch (Exception e) {
log.error(e.getMessage(), e);
if (e.getMessage().contains("PRIMARY")) {
return Result.failed(false, "主键冲突");
} else {
return Result.failed(false, e.getMessage());
}
}
}
public List<PresellPugDetail> getByPresellOrderId(String id) {
List<PresellPugDetail> ret = new ArrayList<>();
if (StrKit.isBlank(id)) {
return ret;
}
return PresellPugDetail.dao.find("select * from presell_pug where presell_order_id = ?", id);
}
}

View File

@ -1,10 +1,9 @@
package com.cowr.service.ssjygl.presellpug;
package com.cowr.service.ssjygl.presellpugdetail;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.PresellPug;
import com.cowr.model.PresellPugDetail;
/**
* Generated by COWR Thu Dec 16 15:44:53 CST 2021
@ -12,7 +11,7 @@ import com.cowr.model.PresellPug;
* Remarks:
* PrimaryKey: id
*/
public class PresellPugValidator extends CrudParamValidator {
public class PresellPugDetailValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
@ -24,7 +23,8 @@ public class PresellPugValidator extends CrudParamValidator {
validateRequired("presell_order_id", "ipresell_order_id", "ipresell_order_id 必填");
validateString("presell_order_id", 1, 32, "presell_order_id", "presell_order_id 长度 1~32");
validateBigDecimal("amount", new java.math.BigDecimal(1), new java.math.BigDecimal(9.9999999999E10), "amount", "amount 范围 1~9.9999999999E10");
validateString("start_time", 1, 19, "start_time", "start_time 长度 1~19");
validateDate("start_time", "yyyy-MM-dd", false, "start_time", "start_time 格式 yyyy-MM-dd"); // 默认时间时间字符串格式,生成后根据情况调整
@ -36,7 +36,7 @@ public class PresellPugValidator extends CrudParamValidator {
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
// 如果确实是需要将主键外的字段置为 null可以在代码生成后删掉这段
if ("edit".equals(getActionMethodName())) {
validateUpdateModel(PresellPug.class, "", true); // 忽略不在model中的字段
validateUpdateModel(PresellPugDetail.class, "", true); // 忽略不在model中的字段
}
}