1. 新增客户折扣管理模块

dev
徐杰盟 2023-12-21 16:56:51 +08:00
parent 0b5c08f80c
commit 85bb3de84b
17 changed files with 848 additions and 12 deletions

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseCustomerDiscount;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class CustomerDiscount extends BaseCustomerDiscount<CustomerDiscount> {
public static final CustomerDiscount dao = new CustomerDiscount().dao();
}

View File

@ -58,6 +58,7 @@ public class _MappingKit {
arp.addMapping("ossfile_log", "id", OssfileLog.class);
arp.addMapping("sms_log", "id", SmsLog.class);
arp.addMapping("order_end", "id", OrderEnd.class);
arp.addMapping(CustomerDiscount.tablename, "id", CustomerDiscount.class);
arp.addMapping("action_cmd_log", "id", ActionCmdLog.class);
arp.addMapping("modify_log", "id", ModifyLog.class);
arp.addMapping("sysuser", "id", Sysuser.class);

View File

@ -0,0 +1,244 @@
package com.cowr.model.base;
import com.cowr.common.base.BaseModel;
import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public abstract class BaseCustomerDiscount<M extends BaseCustomerDiscount<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "customer_discount";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: id
* type: INT(10)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id
*/
@JSONField(name="id")
public void setId(Integer id) {
set("id", id);
}
/**
* @return id
*/
@JSONField(name="id")
public Integer getId() {
return getInt("id");
}
/**
* name: customer_id
* type: INT(10)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param customerId id
*/
@JSONField(name="customer_id")
public void setCustomerId(Integer customerId) {
set("customer_id", customerId);
}
/**
* @return customer_id id
*/
@JSONField(name="customer_id")
public Integer getCustomerId() {
return getInt("customer_id");
}
/**
* name: discount
* type: DOUBLE(22)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param discount ,(%)
*/
@JSONField(name="discount")
public void setDiscount(Double discount) {
set("discount", discount);
}
/**
* @return discount ,(%)
*/
@JSONField(name="discount")
public Double getDiscount() {
return getDouble("discount");
}
/**
* name: stm
* type: DATETIME(19)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param stm
*/
@JSONField(name="stm")
public void setStm(java.util.Date stm) {
set("stm", stm);
}
/**
* @return stm
*/
@JSONField(name="stm")
public java.util.Date getStm() {
return get("stm");
}
/**
* name: etm
* type: DATETIME(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param etm
*/
@JSONField(name="etm")
public void setEtm(java.util.Date etm) {
set("etm", etm);
}
/**
* @return etm
*/
@JSONField(name="etm")
public java.util.Date getEtm() {
return get("etm");
}
/**
* name: create_time
* type: DATETIME(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: CURRENT_TIMESTAMP
* @param createTime
*/
@JSONField(name="create_time")
public void setCreateTime(java.util.Date createTime) {
set("create_time", createTime);
}
/**
* @return create_time
*/
@JSONField(name="create_time")
public java.util.Date getCreateTime() {
return get("create_time");
}
/**
* name: create_user
* type: INT(10)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param createUser
*/
@JSONField(name="create_user")
public void setCreateUser(Integer createUser) {
set("create_user", createUser);
}
/**
* @return create_user
*/
@JSONField(name="create_user")
public Integer getCreateUser() {
return getInt("create_user");
}
/**
* name: update_time
* type: DATETIME(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: CURRENT_TIMESTAMP
* @param updateTime
*/
@JSONField(name="update_time")
public void setUpdateTime(java.util.Date updateTime) {
set("update_time", updateTime);
}
/**
* @return update_time
*/
@JSONField(name="update_time")
public java.util.Date getUpdateTime() {
return get("update_time");
}
/**
* name: update_user
* type: INT(10)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param updateUser
*/
@JSONField(name="update_user")
public void setUpdateUser(Integer updateUser) {
set("update_user", updateUser);
}
/**
* @return update_user
*/
@JSONField(name="update_user")
public Integer getUpdateUser() {
return getInt("update_user");
}
/**
* name: del
* type: VARCHAR(2)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: 1
* @param del ,0: , 1.
*/
@JSONField(name="del")
public void setDel(String del) {
set("del", del);
}
/**
* @return del ,0: , 1.
*/
@JSONField(name="del")
public String getDel() {
return getStr("del");
}
}

View File

@ -0,0 +1,97 @@
//package com.cowr.ssjygl.customer.customerdiscount;
//
//import com.cowr.common.view.PageParam;
//import com.cowr.common.view.Result;
//import com.cowr.model.CustomerDiscount;
//import com.jfinal.aop.Before;
//import com.jfinal.core.Controller;
//
///**
// * Generated by COWR Wed Dec 20 14:05:09 CST 2023
// * TableName: customer_discount
// * Remarks: 客户相关 - 客户折扣
// * PrimaryKey: id
// */
//public class CustomerDiscountController extends Controller {
//
// /**
// * 按主键检查对象是否存在
// * 返回 code = 200
// * 存在时 data = true
// * 不存在 data = false
// */
// @Before(CustomerDiscountPKValidator.class)
// public void checkExistsByPk(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.checkExistsByPk(model));
// }
//
// /**
// * 新增 customer_discount 客户相关 - 客户折扣
// */
// @Before(CustomerDiscountValidator.class)
// public void save(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.save(model));
// }
//
// /**
// * 删除 customer_discount 客户相关 - 客户折扣
// */
// @Before(CustomerDiscountPKValidator.class)
// public void del(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.delete(model));
// }
//
// /**
// * 恢复 customer_discount 客户相关 - 客户折扣
// */
// @Before(CustomerDiscountPKValidator.class)
// public void restore(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.restore(model));
// }
//
// /**
// * 修改 customer_discount 客户相关 - 客户折扣
// */
// @Before(CustomerDiscountValidator.class)
// public void edit(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.update(model));
// }
//
// /**
// * 分页查找 customer_discount 客户相关 - 客户折扣
// */
// public void find(){
// PageParam pp = getBean(PageParam.class, "", true);
// renderJson(Result.object(CustomerDiscountService.me.find(pp)));
// }
//
// /**
// * 按主键查找单个对象 customer_discount 客户相关 - 客户折扣
// */
// @Before(CustomerDiscountPKValidator.class)
// public void findByPk(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.findByPk(model));
// }
//
// /**
// * 按主键查找单个对象 customer_discount 客户相关 - 客户折扣
// */
// @Before(CustomerDiscountPKValidator.class)
// public void get(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.findByPk(model));
// }
//
// /**
// * 返回所有 customer_discount 客户相关 - 客户折扣
// */
// public void list(){
// renderJson(Result.object(CustomerDiscountService.me.list()));
// }
//}

View File

@ -0,0 +1,25 @@
package com.cowr.ssjygl.customer.customerdiscount;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.CustomerDiscount;
import com.jfinal.core.Controller;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
public class CustomerDiscountPKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,87 @@
package com.cowr.ssjygl.customer.customerdiscount;
import com.cowr.common.Const;
import com.cowr.common.base.BaseService;
import com.cowr.common.view.PageParam;
import com.cowr.model.CustomerDiscount;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.util.ArrayList;
import java.util.List;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
public class CustomerDiscountService extends BaseService {
private static final Log log = Log.getLog(CustomerDiscountService.class);
public static final CustomerDiscountService me = new CustomerDiscountService();
public Page<Record> find(PageParam pp,String customerId,String customerName,String stm,String etm) {
String selectsql = "select t.*,cu.name create_name,uu.name update_name,c.name customer_name ";
String fromsql = "from customer_discount t" +
" left join customer c on t.customer_id = c .id" +
" left join sysuser cu on t.create_user = cu.id and t.create_user is not null" +
" left join sysuser uu on t.update_user = uu.id and t.update_user is not null" +
" where 1=1 " +
" and t.del = 1";
List<Object> paraList = new ArrayList<>();
if (customerId != null) {
fromsql += " and c.customer_name = ? \n";
paraList.add(customerId);
}
if (customerName != null) {
fromsql += " and c.name like ? \n";
paraList.add("%"+ customerName + "%");
}
if (StrKit.notBlank(stm)) {
fromsql += " and t.create_time >= ? \n";
paraList.add(stm);
}
if (StrKit.notBlank(etm)) {
fromsql += " and t.create_time <= ? \n";
paraList.add(etm);
}
String totalRowSql = "select count(*) " + fromsql;
String findSql = selectsql + fromsql;
// 前端传了排序字段,并且排序字段存在相关表中
if (StrKit.notBlank(pp.getSort_field()) && CustomerDiscount.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.id desc";
}
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
}
public List<CustomerDiscount> list() {
return CustomerDiscount.dao.find("select * from customer_discount");
}
public CustomerDiscount getDiscountByCustomerId(Integer customerId) {
return CustomerDiscount.dao.findFirst("select * from customer_discount where del = 1 and customer_id = ?", customerId);
}
public int updateDel() {
return Db.update("update customer_discount set del = 0 where etm < now();");
}
}

View File

@ -0,0 +1,65 @@
package com.cowr.ssjygl.customer.customerdiscount;
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.CustomerDiscount;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
public class CustomerDiscountValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
if (!"save".equals(getActionMethodName())) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
}
validateInteger("customer_id", 1, 2147483647, "customer_id", "customer_id 范围 1~2147483647");
validateDouble("discount", -1.0000000000000001E23, 1.0000000000000001E23, "discount", "discount 范围 -1.0000000000000001E23~1.0000000000000001E23");
validateString("stm", 0, 19, "stm", "stm 长度 0~19");
validateDate("stm", "yyyy-MM-dd HH:mm:ss", false, "stm", "stm 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
validateString("etm", 1, 19, "etm", "etm 长度 1~19");
validateDate("etm", "yyyy-MM-dd HH:mm:ss", false, "etm", "etm 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
validateString("create_time", 0, 19, "create_time", "create_time 长度 0~19");
validateInteger("create_user", -2147483647, 2147483647, "create_user", "create_user 范围 -2147483647~2147483647");
validateString("update_time", 0, 19, "update_time", "update_time 长度 0~19");
if (StrKit.notBlank(c.get("update_user"))) { // 可为空字段,当传入值时,才做验证
validateInteger("update_user", -2147483647, 2147483647, "update_user", "update_user 范围 -2147483647~2147483647");
}
validateString("del", 1, 2, "del", "del 长度 1~2");
// 使用 model 更新时model 不能只有主键有值
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
// 如果确实是需要将主键外的字段置为 null可以在代码生成后删掉这段
if ("edit".equals(getActionMethodName())) {
validateUpdateModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
}
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -23,7 +23,8 @@ public class Main {
// 此处填入需要生成model的表
// 仅保留本次处理需要的表,不需要的就
String[] tableArray = {
"order_end"
"customer_discount"
// "order_end"
// ,
// "driver",
// "product",

View File

@ -1,4 +1,8 @@
# mysql
jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=dev_ssjy_xsx
password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=dev_ssjy_xsx
#password=Ssjy_xs_890
jdbcUrl=jdbc:mysql://127.0.0.1:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=root
password=19999999

View File

@ -15,13 +15,14 @@ import com.cowr.local.ssjygl.order.orderseq.OrderSeqService;
import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.truck.truckweightlimit.TruckWeightLimitSyncService;
import com.cowr.model.*;
import com.cowr.ssjygl.customer.customerdiscount.CustomerDiscountService;
import com.cowr.ssjygl.invoice.log.InvoiceLogService;
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
import com.cowr.ssjygl.prepay.refunddetail.RefundDetailService;
import com.cowr.ssjygl.presellorder.PresellOrderService;
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
import com.cowr.ssjygl.ticket.log.TicketLogService;
import com.cowr.ssjygl.ticket.receive.TicketReceiveService;
import com.cowr.ssjygl.transprice.TransPriceService;
@ -33,6 +34,7 @@ import com.jfinal.plugin.activerecord.Record;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
public class OrderTempSyncService {
public static OrderTempSyncService me = new OrderTempSyncService();
@ -727,6 +729,11 @@ public class OrderTempSyncService {
return Result.failed("不是预付费客户");
}
// 根据客户消息判断是否需要打折
CustomerDiscount customerDiscount = CustomerDiscountService.me.getDiscountByCustomerId(customer.getId()); // 预付费结算
if (Objects.nonNull(customerDiscount) && Objects.nonNull(customerDiscount.getDiscount())){
net_weight = net_weight.multiply(BigDecimal.valueOf(customerDiscount.getDiscount()/100));
}
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
@ -867,6 +874,7 @@ public class OrderTempSyncService {
InvoiceReceive finalReceive = receive;
TicketReceive finalTicketReceive = ticketReceive;
BigDecimal finalNet_weight = net_weight;
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
@ -925,7 +933,7 @@ public class OrderTempSyncService {
stock = new Stock();
stock.setProductId(order.getProductId());
stock.setSupermarketId(order.getSupermarketId());
stock.setStockWeight(new BigDecimal(0).subtract(net_weight));
stock.setStockWeight(new BigDecimal(0).subtract(finalNet_weight));
ret = stock.save();
if (!ret) {
@ -933,7 +941,7 @@ public class OrderTempSyncService {
}
synctask.addSaveData(stock);
} else {
stock.setStockWeight(stock.getStockWeight().subtract(net_weight)); // 销售减库存
stock.setStockWeight(stock.getStockWeight().subtract(finalNet_weight)); // 销售减库存
ret = stock.update();
if (!ret) {
@ -1119,6 +1127,12 @@ public class OrderTempSyncService {
return Result.failed("不是预付费客户");
}
// 根据客户消息判断是否需要打折
CustomerDiscount customerDiscount = CustomerDiscountService.me.getDiscountByCustomerId(customer.getId()); // 预付费结算
if (Objects.nonNull(customerDiscount) && Objects.nonNull(customerDiscount.getDiscount())){
net_weight = net_weight.multiply(BigDecimal.valueOf(customerDiscount.getDiscount()/100));
}
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
@ -1260,6 +1274,7 @@ public class OrderTempSyncService {
InvoiceReceive finalReceive = receive;
TicketReceive finalTicketReceive = ticketReceive;
BigDecimal finalNet_weight = net_weight;
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
@ -1297,7 +1312,7 @@ public class OrderTempSyncService {
stock = new Stock();
stock.setProductId(order.getProductId());
stock.setSupermarketId(order.getSupermarketId());
stock.setStockWeight(new BigDecimal(0).subtract(net_weight));
stock.setStockWeight(new BigDecimal(0).subtract(finalNet_weight));
ret = stock.save();
if (!ret) {
@ -1305,7 +1320,7 @@ public class OrderTempSyncService {
}
synctask.addSaveData(stock);
} else {
stock.setStockWeight(stock.getStockWeight().subtract(net_weight)); // 销售减库存
stock.setStockWeight(stock.getStockWeight().subtract(finalNet_weight)); // 销售减库存
ret = stock.update();
if (!ret) {

View File

@ -0,0 +1,168 @@
package com.cowr.service.ssjygl.customer.customerdiscount;
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.CustomerDiscount;
import com.cowr.model.Sysuser;
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.ssjygl.customer.customerdiscount.CustomerDiscountService;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import java.util.Objects;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
public class CustomerDiscountController extends Controller {
/**
*
* code = 200
* data = true
* data = false
*/
@Before(CustomerDiscountPKValidator.class)
public void checkExistsByPk(){
CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
renderJson(CustomerDiscountService.me.checkExistsByPk(model));
}
/**
* customer_discount -
*/
@Before(CustomerDiscountValidator.class)
public void save(){
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (Objects.isNull(tokenuser)) {
renderJson(Result.noauth());
return;
}
if (!RoleEnum.PRESIDENT.getRoleid().equals(tokenuser.getRole())) {
renderJson(Result.permissionDenied("需要结算中心才能新增"));
return;
}
CustomerDiscount model = new CustomerDiscount(); // 忽略不在model中的字段
model.setCustomerId(getInt("customer_id"));
model.setDiscount(Double.valueOf(get("discount")));
model.setStm(getDate("stm"));
model.setEtm(getDate("etm"));
model.setCreateUser(tokenuser.getId());
if (Objects.nonNull(CustomerDiscountService.me.getDiscountByCustomerId(model.getCustomerId()))){
renderJson(Result.failed("当前用户已有折扣正在使用中"));
return;
}
renderJson(CustomerDiscountService.me.save(model));
}
/**
* customer_discount -
*/
@Before(CustomerDiscountPKValidator.class)
public void del(){
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (Objects.isNull(tokenuser)) {
renderJson(Result.noauth());
return;
}
if (!RoleEnum.PRESIDENT.getRoleid().equals(tokenuser.getRole())) {
renderJson(Result.permissionDenied("需要结算中心才能删除"));
return;
}
CustomerDiscount model = new CustomerDiscount(); // 忽略不在model中的字段
model.setId(getInt("id"));
model.setDel("0");
model.setUpdateUser(tokenuser.getId());
renderJson(CustomerDiscountService.me.update(model));
}
/**
* customer_discount -
*/
@Before(CustomerDiscountPKValidator.class)
public void restore(){
CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
renderJson(CustomerDiscountService.me.restore(model));
}
/**
* customer_discount -
*/
// @Before(CustomerDiscountValidator.class)
// public void edit(){
// CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
// renderJson(CustomerDiscountService.me.update(model));
// }
/**
* customer_discount -
*/
public void find(){
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (Objects.isNull(tokenuser)) {
renderJson(Result.noauth());
return;
}
if (!UserTypeEnum.LEAD.getTypeid().equals(tokenuser.getType())) {
renderJson(Result.permissionDenied("需要公司管理员才能查看"));
return;
}
PageParam pp = getBean(PageParam.class, "", true);
String customerId = get("customerId");
String customerName = get("customerName");
String stm = get("stm");
String etm = get("etm");
renderJson(Result.object(CustomerDiscountService.me.find(pp,customerId,customerName,stm,etm)));
}
/**
* customer_discount -
*/
@Before(CustomerDiscountPKValidator.class)
public void findByPk(){
CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
renderJson(CustomerDiscountService.me.findByPk(model));
}
/**
* customer_discount -
*/
@Before(CustomerDiscountPKValidator.class)
public void get(){
CustomerDiscount model = getModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
renderJson(CustomerDiscountService.me.findByPk(model));
}
/**
* customer_discount -
*/
public void list(){
renderJson(Result.object(CustomerDiscountService.me.list()));
}
/**
*
*/
public void updateDel(){
renderJson(Result.object(CustomerDiscountService.me.updateDel()));
}
}

View File

@ -0,0 +1,24 @@
package com.cowr.service.ssjygl.customer.customerdiscount;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
public class CustomerDiscountPKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,54 @@
package com.cowr.service.ssjygl.customer.customerdiscount;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.CustomerDiscount;
import com.jfinal.core.Controller;
/**
* Generated by COWR Wed Dec 20 14:05:09 CST 2023
* TableName: customer_discount
* Remarks: -
* PrimaryKey: id
*/
public class CustomerDiscountValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
if (!"save".equals(getActionMethodName())) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
}
validateInteger("customer_id", 1, 2147483647, "customer_id", "customer_id 范围 1~2147483647");
validateDouble("discount", 0, 1.0000000000000001E23, "discount", "discount 范围 -1.0000000000000001E23~1.0000000000000001E23");
validateString("stm", 0, 19, "stm", "stm 长度 0~19");
validateDate("stm", "yyyy-MM-dd HH:mm:ss", false, "stm", "stm 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
validateString("etm", 1, 19, "etm", "etm 长度 1~19");
validateDate("etm", "yyyy-MM-dd HH:mm:ss", false, "etm", "etm 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
// 使用 model 更新时model 不能只有主键有值
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
// 如果确实是需要将主键外的字段置为 null可以在代码生成后删掉这段
if ("edit".equals(getActionMethodName())) {
validateUpdateModel(CustomerDiscount.class, "", true); // 忽略不在model中的字段
validateString("del", 1, 2, "del", "del 长度 1~2");
}
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,31 @@
package com.cowr.service.ssjygl.jobs;
import com.cowr.ssjygl.customer.customerdiscount.CustomerDiscountService;
import com.jfinal.log.Log;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* Description:
* Created by XuSan on 2023/12/20.
*
*
* @author XuSan
* @version 1.0
*/
public class CustomerDiscountJob implements Job {
private static Log log = Log.getLog(CustomerDiscountJob.class);
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
int update = CustomerDiscountService.me.updateDel();
log.info("客户折扣配置更新条数: %s",update);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}

View File

@ -18,6 +18,7 @@ import com.cowr.service.ssjygl.customer.CustomerController;
import com.cowr.service.ssjygl.customer.contact.CustomerContactController;
import com.cowr.service.ssjygl.customer.contractsignedlog.CustomerContractSignedLogController;
import com.cowr.service.ssjygl.customer.contracttemplate.CustomerContractTemplateController;
import com.cowr.service.ssjygl.customer.customerdiscount.CustomerDiscountController;
import com.cowr.service.ssjygl.customer.pact.CustomerPactController;
import com.cowr.service.ssjygl.customer.receiver.CustomerReceiverController;
import com.cowr.service.ssjygl.customer.register.CustomerRegisterController;
@ -202,6 +203,7 @@ public class Config extends JFinalConfig {
me.add("/customer/type", CustomerTypeController.class);
me.add("/customer/contracttemplate", CustomerContractTemplateController.class);
me.add("/customer/contractsignedlog", CustomerContractSignedLogController.class);
me.add("/customer/discount", CustomerDiscountController.class);
// -- 预付费
me.add("/prepay", PrepayController.class);

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

@ -37,4 +37,8 @@ loadstat.enable=true
# ????
orderEnd.job=com.cowr.service.ssjygl.jobs.OrderEndJob
orderEnd.cron= 0 0 6 * * ?
orderEnd.enable=true
orderEnd.enable=true
CustomerDiscount.job=com.cowr.service.ssjygl.jobs.CustomerDiscountJob
CustomerDiscount.cron= 0 0 0/1 * * ?
CustomerDiscount.enable=true