dev
parent
7ed2bc5d22
commit
aa867f3191
|
|
@ -28,8 +28,8 @@ public class Const {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SMS_TEMP_MAP = new HashMap<>();
|
SMS_TEMP_MAP = new HashMap<>();
|
||||||
SMS_TEMP_MAP.put(TEMP_CODE_DAY_STAT, "${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${market_detail}。");
|
SMS_TEMP_MAP.put(TEMP_CODE_DAY_STAT, "${time}销售汇总:${supermarket_count}个砂站共销售${weight}吨黄砂,总价${total_price}元。各砂站详情如下:${supermarket_detail}元。");
|
||||||
SMS_TEMP_MAP.put(TEMP_CODE_CUSTOMER_DAY_STAT, "${time}销售汇总:${supermarket_count}个砂站共销售${weight}吨黄砂,总价${total_price}。各砂站详情如下:${market_detail}。");
|
SMS_TEMP_MAP.put(TEMP_CODE_CUSTOMER_DAY_STAT, "${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。");
|
||||||
SMS_TEMP_MAP.put(TEMP_CODE_PEIE, "已经在${supermarket_name}分配了${weight}吨配额,请在${date}安排车辆前去运输。");
|
SMS_TEMP_MAP.put(TEMP_CODE_PEIE, "已经在${supermarket_name}分配了${weight}吨配额,请在${date}安排车辆前去运输。");
|
||||||
SMS_TEMP_MAP.put(TEMP_CODE_DEPOSIT_SUCCESS, "${time}${customer_name}在浠水县长投环保有限公司的预存${amount}元,合计余额${surplus}元。");
|
SMS_TEMP_MAP.put(TEMP_CODE_DEPOSIT_SUCCESS, "${time}${customer_name}在浠水县长投环保有限公司的预存${amount}元,合计余额${surplus}元。");
|
||||||
SMS_TEMP_MAP.put(TEMP_CODE_DEPOSIT_FAIL, "${time}${customer_name}在浠水县长投环保有限公司预存的${amount}元审核未通过,若有疑问请及时联系浠水县长投环保结算中心。");
|
SMS_TEMP_MAP.put(TEMP_CODE_DEPOSIT_FAIL, "${time}${customer_name}在浠水县长投环保有限公司预存的${amount}元审核未通过,若有疑问请及时联系浠水县长投环保结算中心。");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.cowr.model;
|
||||||
|
|
||||||
|
import com.cowr.model.base.BaseSmsNoticeContact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Nov 06 17:13:45 CST 2020
|
||||||
|
* TableName: sms_notice_contact
|
||||||
|
* Remarks: 系统配置 - 通知短信发送人员
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class SmsNoticeContact extends BaseSmsNoticeContact<SmsNoticeContact> {
|
||||||
|
public static final SmsNoticeContact dao = new SmsNoticeContact().dao();
|
||||||
|
}
|
||||||
|
|
@ -51,6 +51,7 @@ public class _MappingKit {
|
||||||
arp.addMapping("prepay_customer", "id", PrepayCustomer.class);
|
arp.addMapping("prepay_customer", "id", PrepayCustomer.class);
|
||||||
arp.addMapping("prepay_truck", "id", PrepayTruck.class);
|
arp.addMapping("prepay_truck", "id", PrepayTruck.class);
|
||||||
arp.addMapping("sms_log", "id", SmsLog.class);
|
arp.addMapping("sms_log", "id", SmsLog.class);
|
||||||
|
arp.addMapping("sms_notice_contact", "id", SmsNoticeContact.class);
|
||||||
arp.addMapping("sync_task", "id", SyncTask.class);
|
arp.addMapping("sync_task", "id", SyncTask.class);
|
||||||
arp.addMapping("ossfile_log", "id", OssfileLog.class);
|
arp.addMapping("ossfile_log", "id", OssfileLog.class);
|
||||||
arp.addMapping("modify_log", "id", ModifyLog.class);
|
arp.addMapping("modify_log", "id", ModifyLog.class);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
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 Fri Nov 06 17:15:34 CST 2020
|
||||||
|
* TableName: sms_notice_contact
|
||||||
|
* Remarks: 系统配置 - 通知短信发送人员
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public abstract class BaseSmsNoticeContact<M extends BaseSmsNoticeContact<M>> extends BaseModel<M> implements IBean {
|
||||||
|
|
||||||
|
public static final String tablename = "sms_notice_contact";
|
||||||
|
|
||||||
|
@JSONField(serialize=false)
|
||||||
|
public String getTablename(){
|
||||||
|
return tablename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: id
|
||||||
|
* type: CHAR(32)
|
||||||
|
* isNullable: NO
|
||||||
|
* isPrimaryKey: YES
|
||||||
|
* defaultValue:
|
||||||
|
* @param id uuid
|
||||||
|
*/
|
||||||
|
@JSONField(name="id")
|
||||||
|
public void setId(String id) {
|
||||||
|
set("id", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return id uuid
|
||||||
|
*/
|
||||||
|
@JSONField(name="id")
|
||||||
|
public String getId() {
|
||||||
|
return getStr("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: phone
|
||||||
|
* type: VARCHAR(20)
|
||||||
|
* isNullable: NO
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param phone 手机号
|
||||||
|
*/
|
||||||
|
@JSONField(name="phone")
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
set("phone", phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return phone 手机号
|
||||||
|
*/
|
||||||
|
@JSONField(name="phone")
|
||||||
|
public String getPhone() {
|
||||||
|
return getStr("phone");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: name
|
||||||
|
* type: VARCHAR(255)
|
||||||
|
* isNullable: YES
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param name 姓名
|
||||||
|
*/
|
||||||
|
@JSONField(name="name")
|
||||||
|
public void setName(String name) {
|
||||||
|
set("name", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return name 姓名
|
||||||
|
*/
|
||||||
|
@JSONField(name="name")
|
||||||
|
public String getName() {
|
||||||
|
return getStr("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: type
|
||||||
|
* type: JSON(1073741824)
|
||||||
|
* isNullable: YES
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param type 格式[1,2,3,...]
|
||||||
|
1.前一天总销售统计
|
||||||
|
其他是预留
|
||||||
|
*/
|
||||||
|
@JSONField(name="type")
|
||||||
|
public void setType(String type) {
|
||||||
|
set("type", type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return type 格式[1,2,3,...]
|
||||||
|
1.前一天总销售统计
|
||||||
|
其他是预留
|
||||||
|
*/
|
||||||
|
@JSONField(name="type")
|
||||||
|
public String getType() {
|
||||||
|
return getStr("type");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.cowr.ssjygl.smslog;
|
package com.cowr.ssjygl.sms.log;
|
||||||
|
|
||||||
|
|
||||||
import com.cowr.common.validator.CrudParamValidator;
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.cowr.ssjygl.smslog;
|
package com.cowr.ssjygl.sms.log;
|
||||||
|
|
||||||
import com.cowr.common.Const;
|
import com.cowr.common.Const;
|
||||||
import com.cowr.common.base.BaseService;
|
import com.cowr.common.base.BaseService;
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.cowr.ssjygl.sms.noticecontact;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.SmsNoticeContact;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Nov 06 17:13:51 CST 2020
|
||||||
|
* TableName: sms_notice_contact
|
||||||
|
* Remarks: 系统配置 - 通知短信发送人员
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class SmsNoticeContactPKValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateRequired("id", "id", "id 必填");
|
||||||
|
validateString("id", 1, 32, "id", "id 长度 1~32");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.cowr.ssjygl.sms.noticecontact;
|
||||||
|
|
||||||
|
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.SmsNoticeContact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Nov 06 17:13:51 CST 2020
|
||||||
|
* TableName: sms_notice_contact
|
||||||
|
* Remarks: 系统配置 - 通知短信发送人员
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class SmsNoticeContactValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
|
||||||
|
if (!"save".equals(getActionMethodName())) {
|
||||||
|
validateRequired("id", "id", "id 必填");
|
||||||
|
|
||||||
|
validateString("id", 1, 32, "id", "id 长度 1~32");
|
||||||
|
}
|
||||||
|
|
||||||
|
validateString("phone", 1, 20, "phone", "phone 长度 1~20");
|
||||||
|
validateString("name", 1, 255, "name", "name 长度 0~255");
|
||||||
|
validateString("type", 1, 1073741824, "type", "type 长度 0~1073741824");
|
||||||
|
|
||||||
|
// 使用 model 更新时,model 不能只有主键有值
|
||||||
|
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
|
||||||
|
// 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段
|
||||||
|
if ("edit".equals(getActionMethodName())) {
|
||||||
|
validateUpdateModel(SmsNoticeContact.class, "", true); // 忽略不在model中的字段
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -78,6 +78,7 @@ public class Main {
|
||||||
"customer_supermarket_product",
|
"customer_supermarket_product",
|
||||||
"invoice_invalid_verify",
|
"invoice_invalid_verify",
|
||||||
"order_invalid_verify",
|
"order_invalid_verify",
|
||||||
|
"sms_notice_contact",
|
||||||
};
|
};
|
||||||
|
|
||||||
PropKit.use("db.properties");
|
PropKit.use("db.properties");
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import com.cowr.local.ssjygl.prepay.refunddetail.RefundDetailController;
|
||||||
import com.cowr.local.ssjygl.product.ProductController;
|
import com.cowr.local.ssjygl.product.ProductController;
|
||||||
import com.cowr.local.ssjygl.purchase.PurchaseController;
|
import com.cowr.local.ssjygl.purchase.PurchaseController;
|
||||||
import com.cowr.local.ssjygl.sandfarm.SandfarmController;
|
import com.cowr.local.ssjygl.sandfarm.SandfarmController;
|
||||||
import com.cowr.local.ssjygl.smslog.SmsLogController;
|
import com.cowr.local.ssjygl.sms.log.SmsLogController;
|
||||||
import com.cowr.local.ssjygl.supermarket.SupermarketController;
|
import com.cowr.local.ssjygl.supermarket.SupermarketController;
|
||||||
import com.cowr.local.ssjygl.supermarket.customerdistance.SupermarketCustomerDistanceController;
|
import com.cowr.local.ssjygl.supermarket.customerdistance.SupermarketCustomerDistanceController;
|
||||||
import com.cowr.local.ssjygl.supermarket.receiverdistance.SupermarketReceiverDistanceController;
|
import com.cowr.local.ssjygl.supermarket.receiverdistance.SupermarketReceiverDistanceController;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package com.cowr.service.ssjygl.smslog;
|
package com.cowr.local.ssjygl.sms.log;
|
||||||
|
|
||||||
import com.cowr.common.validator.StartAndEndIntervalValidator;
|
import com.cowr.common.validator.StartAndEndIntervalValidator;
|
||||||
import com.cowr.common.view.PageParam;
|
import com.cowr.common.view.PageParam;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.SmsLog;
|
import com.cowr.model.SmsLog;
|
||||||
import com.cowr.ssjygl.smslog.SmsLogPKValidator;
|
import com.cowr.ssjygl.sms.log.SmsLogPKValidator;
|
||||||
import com.cowr.ssjygl.smslog.SmsLogService;
|
import com.cowr.ssjygl.sms.log.SmsLogService;
|
||||||
import com.jfinal.aop.Before;
|
import com.jfinal.aop.Before;
|
||||||
import com.jfinal.core.Controller;
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
package com.cowr.local.ssjygl.smslog;
|
|
||||||
|
|
||||||
import com.cowr.local.ssjygl.base.BaseSyncService;
|
|
||||||
|
|
||||||
public class SmsLogSyncService extends BaseSyncService {
|
|
||||||
}
|
|
||||||
|
|
@ -15,23 +15,33 @@ import java.util.List;
|
||||||
public class CleanOSSBakFileJob implements Job {
|
public class CleanOSSBakFileJob implements Job {
|
||||||
private static Log log = Log.getLog(CleanOSSBakFileJob.class);
|
private static Log log = Log.getLog(CleanOSSBakFileJob.class);
|
||||||
|
|
||||||
public void execute(){
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
String[] prefixkeys = new String[]{"ssjy/xsx/dbbak/ssjy_xsx_", "ssjy/dbbak/ssjy"};
|
String[] prefixkeys = new String[]{"ssjy/xsx/dbbak/ssjy_xsx_", "ssjy/dbbak/ssjy"};
|
||||||
List<String> delkeys = new ArrayList<>();
|
List<String> delkeys = new ArrayList<>();
|
||||||
|
long st = System.currentTimeMillis();
|
||||||
|
|
||||||
for(String prefix : prefixkeys){
|
for (String prefix : prefixkeys) {
|
||||||
ObjectListing ret = OSSKit.list(prefix);
|
ObjectListing ret = OSSKit.list(prefix);
|
||||||
|
|
||||||
|
if (ret == null) {
|
||||||
|
log.debug("没有找到相关数据。 %s", prefix);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
List<OSSObjectSummary> list = ret.getObjectSummaries();
|
List<OSSObjectSummary> list = ret.getObjectSummaries();
|
||||||
|
|
||||||
for(OSSObjectSummary obj : list){
|
for (OSSObjectSummary obj : list) {
|
||||||
if(obj.getLastModified().getTime() > 48L * 24 * 60 * 60 * 1000 ){ // 超过两天的
|
if (st - obj.getLastModified().getTime() > 2L * 24 * 60 * 60 * 1000) { // 超过两天的
|
||||||
delkeys.add(obj.getKey());
|
delkeys.add(obj.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(delkeys);
|
for (String key : delkeys) {
|
||||||
|
log.debug("删除备份文件 %s", key);
|
||||||
|
OSSKit.delObject(key);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package com.cowr.service.ssjygl.jobs;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
|
import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||||
|
import com.cowr.service.ssjygl.sms.log.SmsService;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
import com.jfinal.log.Log;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计数据并发送短信
|
||||||
|
*/
|
||||||
|
public class StatSmsJob implements Job {
|
||||||
|
private static Log log = Log.getLog(StatSmsJob.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计固定客户前一天销售情况
|
||||||
|
*/
|
||||||
|
public void statCustomer() {
|
||||||
|
Date now = new Date();
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(now);
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, -1);
|
||||||
|
|
||||||
|
String predaytm = DateTimeUtil.sdf.get().format(c.getTime()); // 前一日
|
||||||
|
String sendtmtext = DateTimeUtil.sdfymd.get().format(c.getTime());
|
||||||
|
|
||||||
|
String sql = " select t.customer_id, t.supermarket_id, count(t.sn) truck_num, sum(t.weight) total_weight, sum(t.total_price) total_price\n" +
|
||||||
|
" from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" and t.customer_id is not null\n" +
|
||||||
|
" and t.create_time like ?\n" +
|
||||||
|
" group by t.customer_id, t.supermarket_id\n" +
|
||||||
|
" order by t.supermarket_id";
|
||||||
|
List<Record> list = Db.find(sql, predaytm + "%");
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
log.debug("%s 没有销售数据", predaytm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, List<Record>> map = new HashMap<>();
|
||||||
|
Map<Integer, JSONObject> smsmap = new HashMap<>();
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
int customer_id = record.getInt("customer_id");
|
||||||
|
|
||||||
|
if (!map.containsKey(customer_id)) {
|
||||||
|
map.put(customer_id, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
map.get(customer_id).add(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。
|
||||||
|
for (Map.Entry<Integer, List<Record>> entry : map.entrySet()) {
|
||||||
|
BigDecimal weight = new BigDecimal("0");
|
||||||
|
BigDecimal total_price = new BigDecimal("0");
|
||||||
|
Integer truck_num = 0;
|
||||||
|
int customer_id = entry.getKey();
|
||||||
|
List<String> supdetail = new ArrayList<>();
|
||||||
|
JSONObject sendobj = new JSONObject();
|
||||||
|
|
||||||
|
List<Record> sups = entry.getValue();
|
||||||
|
for (Record record : sups) {
|
||||||
|
int supermarket_id = record.getInt("supermarket_id");
|
||||||
|
weight = weight.add(record.getBigDecimal("total_weight"));
|
||||||
|
total_price = total_price.add(record.getBigDecimal("total_price"));
|
||||||
|
truck_num += record.getInt("truck_num");
|
||||||
|
|
||||||
|
supdetail.add(
|
||||||
|
String.format(
|
||||||
|
"%s运输%d辆次、%.2f吨、%.2f元",
|
||||||
|
SvrCacheData.SUP_CACHE.get(supermarket_id).getName(),
|
||||||
|
record.getInt("truck_num"),
|
||||||
|
record.getBigDecimal("total_weight"),
|
||||||
|
record.getBigDecimal("total_price")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String supermarket_detail = StrKit.join(supdetail, ",");
|
||||||
|
|
||||||
|
sendobj.put("time", sendtmtext);
|
||||||
|
sendobj.put("weight", String.format("%.2f", weight));
|
||||||
|
sendobj.put("total_price", String.format("%.2f", total_price));
|
||||||
|
sendobj.put("truck_num", truck_num);
|
||||||
|
sendobj.put("supermarket_detail", supermarket_detail.substring(0, supermarket_detail.length() - 1));
|
||||||
|
|
||||||
|
smsmap.put(customer_id, sendobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smsmap.isEmpty()) {
|
||||||
|
log.debug("%s 可以发送的短信内容", predaytm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SmsService.me.sendCustomerDayStat(smsmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stat() {
|
||||||
|
Date now = new Date();
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(now);
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, -1);
|
||||||
|
|
||||||
|
String predaytm = DateTimeUtil.sdf.get().format(c.getTime()); // 前一日
|
||||||
|
String sendtmtext = DateTimeUtil.sdfymd.get().format(c.getTime());
|
||||||
|
|
||||||
|
String sql = "select t.id supermarket_id, t.name supermarket_name, ifnull(a.truck_num, 0) truck_num, ifnull(a.total_weight, 0) total_weight, ifnull(a.total_price, 0)total_price\n" +
|
||||||
|
" from supermarket t\n" +
|
||||||
|
" left join (\n" +
|
||||||
|
" select t.supermarket_id, count(t.sn) truck_num, sum(t.weight) total_weight, sum(t.total_price) total_price\n" +
|
||||||
|
" from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" and t.customer_id is not null\n" +
|
||||||
|
// " and t.create_time like ?\n" +
|
||||||
|
" group by t.supermarket_id\n" +
|
||||||
|
" ) a on a.supermarket_id = t.id\n" +
|
||||||
|
" order by t.id";
|
||||||
|
List<Record> list = Db.find(sql);//, predaytm + "%");
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
log.debug("%s 没有销售数据", predaytm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ${time}销售汇总:${supermarket_count}个砂站共销售${weight}吨黄砂,总价${total_price}元。各砂站详情如下:${supermarket_detail}元。
|
||||||
|
BigDecimal weight = new BigDecimal("0");
|
||||||
|
BigDecimal total_price = new BigDecimal("0");
|
||||||
|
Integer truck_num = 0;
|
||||||
|
List<String> supdetail = new ArrayList<>();
|
||||||
|
JSONObject sendobj = new JSONObject();
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
int supermarket_id = record.getInt("supermarket_id");
|
||||||
|
weight = weight.add(record.getBigDecimal("total_weight"));
|
||||||
|
total_price = total_price.add(record.getBigDecimal("total_price"));
|
||||||
|
truck_num += record.getInt("truck_num");
|
||||||
|
|
||||||
|
supdetail.add(
|
||||||
|
String.format(
|
||||||
|
"%s运输%d辆次、%.2f吨、%.2f元",
|
||||||
|
SvrCacheData.SUP_CACHE.get(supermarket_id).getName(),
|
||||||
|
record.getInt("truck_num"),
|
||||||
|
record.getBigDecimal("total_weight"),
|
||||||
|
record.getBigDecimal("total_price")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String supermarket_detail = StrKit.join(supdetail, ",");
|
||||||
|
|
||||||
|
sendobj.put("time", sendtmtext);
|
||||||
|
sendobj.put("weight", String.format("%.2f", weight));
|
||||||
|
sendobj.put("total_price", String.format("%.2f", total_price));
|
||||||
|
sendobj.put("truck_num", truck_num);
|
||||||
|
sendobj.put("supermarket_detail", supermarket_detail.substring(0, supermarket_detail.length() - 1));
|
||||||
|
|
||||||
|
System.out.println(sendobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) {
|
||||||
|
try {
|
||||||
|
statCustomer();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ package com.cowr.service.ssjygl.jobs;
|
||||||
|
|
||||||
import com.cowr.model.Supermarket;
|
import com.cowr.model.Supermarket;
|
||||||
import com.cowr.service.ssjygl.main.SvrCacheData;
|
import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||||
import com.cowr.service.ssjygl.smslog.SmsService;
|
import com.cowr.service.ssjygl.sms.log.SmsService;
|
||||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import com.cowr.service.ssjygl.driver.DriverController;
|
||||||
import com.cowr.service.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController;
|
import com.cowr.service.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController;
|
||||||
import com.cowr.service.ssjygl.invoice.log.InvoiceLogController;
|
import com.cowr.service.ssjygl.invoice.log.InvoiceLogController;
|
||||||
import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController;
|
import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController;
|
||||||
|
import com.cowr.service.ssjygl.jobs.StatSmsJob;
|
||||||
import com.cowr.service.ssjygl.netty.NettyServer;
|
import com.cowr.service.ssjygl.netty.NettyServer;
|
||||||
import com.cowr.service.ssjygl.order.invalidverify.OrderInvalidVerifyController;
|
import com.cowr.service.ssjygl.order.invalidverify.OrderInvalidVerifyController;
|
||||||
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController;
|
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController;
|
||||||
|
|
@ -31,7 +32,8 @@ import com.cowr.service.ssjygl.prepay.refunddetail.RefundDetailController;
|
||||||
import com.cowr.service.ssjygl.product.ProductController;
|
import com.cowr.service.ssjygl.product.ProductController;
|
||||||
import com.cowr.service.ssjygl.purchase.PurchaseController;
|
import com.cowr.service.ssjygl.purchase.PurchaseController;
|
||||||
import com.cowr.service.ssjygl.sandfarm.SandfarmController;
|
import com.cowr.service.ssjygl.sandfarm.SandfarmController;
|
||||||
import com.cowr.service.ssjygl.smslog.SmsLogController;
|
import com.cowr.service.ssjygl.sms.log.SmsLogController;
|
||||||
|
import com.cowr.service.ssjygl.sms.noticecontact.SmsNoticeContactController;
|
||||||
import com.cowr.service.ssjygl.supermarket.SupermarketController;
|
import com.cowr.service.ssjygl.supermarket.SupermarketController;
|
||||||
import com.cowr.service.ssjygl.supermarket.SupermarketSyncService;
|
import com.cowr.service.ssjygl.supermarket.SupermarketSyncService;
|
||||||
import com.cowr.service.ssjygl.supermarket.customerdistance.SupermarketCustomerDistanceController;
|
import com.cowr.service.ssjygl.supermarket.customerdistance.SupermarketCustomerDistanceController;
|
||||||
|
|
@ -158,6 +160,8 @@ public class Config extends JFinalConfig {
|
||||||
me.add("/product", ProductController.class);
|
me.add("/product", ProductController.class);
|
||||||
me.add("/stock", StockController.class);
|
me.add("/stock", StockController.class);
|
||||||
|
|
||||||
|
me.add("/noticecontact", SmsNoticeContactController.class);
|
||||||
|
|
||||||
// -- 物流公司相关
|
// -- 物流公司相关
|
||||||
me.add("/transCo", TransportCompanyController.class);
|
me.add("/transCo", TransportCompanyController.class);
|
||||||
me.add("/truck", TruckController.class);
|
me.add("/truck", TruckController.class);
|
||||||
|
|
@ -290,6 +294,8 @@ public class Config extends JFinalConfig {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new StatSmsJob().stat();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,12 @@ import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.*;
|
import com.cowr.model.*;
|
||||||
import com.cowr.service.ssjygl.base.BaseSyncService;
|
import com.cowr.service.ssjygl.base.BaseSyncService;
|
||||||
import com.cowr.service.ssjygl.main.SvrCacheData;
|
import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||||
import com.cowr.service.ssjygl.smslog.SmsService;
|
import com.cowr.service.ssjygl.sms.log.SmsService;
|
||||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
import com.cowr.ssjygl.customer.supermarketproduct.CustomerSupermarketProductService;
|
import com.cowr.ssjygl.customer.supermarketproduct.CustomerSupermarketProductService;
|
||||||
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
||||||
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
|
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
|
||||||
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
|
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
|
||||||
import com.cowr.ssjygl.supermarket.SupermarketService;
|
|
||||||
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
|
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
|
||||||
import com.cowr.ssjygl.supermarket.receiverdistance.SupermarketReceiverDistanceService;
|
import com.cowr.ssjygl.supermarket.receiverdistance.SupermarketReceiverDistanceService;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
|
|
@ -24,7 +23,6 @@ import com.jfinal.log.Log;
|
||||||
import com.jfinal.plugin.activerecord.Db;
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
import com.jfinal.plugin.activerecord.IAtom;
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
import com.jfinal.plugin.activerecord.Record;
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.cowr.common.enums.Enums;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.*;
|
import com.cowr.model.*;
|
||||||
import com.cowr.service.ssjygl.base.BaseSyncService;
|
import com.cowr.service.ssjygl.base.BaseSyncService;
|
||||||
|
import com.cowr.service.ssjygl.sms.log.SmsService;
|
||||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||||
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
||||||
|
|
@ -108,6 +109,8 @@ public class PrepayDetailSyncService extends BaseSyncService {
|
||||||
return Result.failed("未找到有效的客户信息");
|
return Result.failed("未找到有效的客户信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PrepayCustomer[] prepayCustomer = {PrepayCustomerService.me.getPrepayCustomer(customer.getId())};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
PrepayDetail oldmodel = model.clone();
|
PrepayDetail oldmodel = model.clone();
|
||||||
|
|
@ -142,28 +145,27 @@ public class PrepayDetailSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
|
if (prepayCustomer[0] == null) {
|
||||||
if (prepayCustomer == null) {
|
prepayCustomer[0] = new PrepayCustomer();
|
||||||
prepayCustomer = new PrepayCustomer();
|
prepayCustomer[0].setCustomerId(customer.getId());
|
||||||
prepayCustomer.setCustomerId(customer.getId());
|
prepayCustomer[0].setSurplus(model.getAmount()); // 更新余额
|
||||||
prepayCustomer.setSurplus(model.getAmount()); // 更新余额
|
prepayCustomer[0].setRechargeTime(now); // 更新最后一次充值时间
|
||||||
prepayCustomer.setRechargeTime(now); // 更新最后一次充值时间
|
prepayCustomer[0].setFirstRechargeTime(now);
|
||||||
prepayCustomer.setFirstRechargeTime(now);
|
|
||||||
|
|
||||||
ret = prepayCustomer.save();
|
ret = prepayCustomer[0].save();
|
||||||
|
|
||||||
synctask.addSaveData(prepayCustomer);
|
synctask.addSaveData(prepayCustomer[0]);
|
||||||
} else {
|
} else {
|
||||||
prepayCustomer.setSurplus(prepayCustomer.getSurplus().add(model.getAmount())); // 更新余额
|
prepayCustomer[0].setSurplus(prepayCustomer[0].getSurplus().add(model.getAmount())); // 更新余额
|
||||||
prepayCustomer.setRechargeTime(now); // 更新最后一次充值时间
|
prepayCustomer[0].setRechargeTime(now); // 更新最后一次充值时间
|
||||||
|
|
||||||
ret = prepayCustomer.update();
|
ret = prepayCustomer[0].update();
|
||||||
|
|
||||||
// 余额变化需要广播
|
// 余额变化需要广播
|
||||||
synctask.addIncrementData(
|
synctask.addIncrementData(
|
||||||
prepayCustomer.getTablename(),
|
prepayCustomer[0].getTablename(),
|
||||||
"id",
|
"id",
|
||||||
prepayCustomer.getId(),
|
prepayCustomer[0].getId(),
|
||||||
new JSONObject().fluentPut("surplus", model.getAmount()) // 取消订单,在原余额上加上一个数
|
new JSONObject().fluentPut("surplus", model.getAmount()) // 取消订单,在原余额上加上一个数
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -195,6 +197,16 @@ public class PrepayDetailSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (ret && model.getAmount() != null) {
|
||||||
|
if (state == 2 && prepayCustomer[0] != null && prepayCustomer[0].getSurplus() != null) {
|
||||||
|
// 审核通过
|
||||||
|
SmsService.me.sendDepositSuccess(customer, model.getAmount(), prepayCustomer[0].getSurplus());
|
||||||
|
} else if (state == 9) {
|
||||||
|
// 审核未通过
|
||||||
|
SmsService.me.sendDepositFail(customer, model.getAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret ? Result.success(true) : Result.failed(false, "更新失败");
|
return ret ? Result.success(true) : Result.failed(false, "更新失败");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package com.cowr.local.ssjygl.smslog;
|
package com.cowr.service.ssjygl.sms.log;
|
||||||
|
|
||||||
import com.cowr.common.validator.StartAndEndIntervalValidator;
|
import com.cowr.common.validator.StartAndEndIntervalValidator;
|
||||||
import com.cowr.common.view.PageParam;
|
import com.cowr.common.view.PageParam;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.SmsLog;
|
import com.cowr.model.SmsLog;
|
||||||
import com.cowr.ssjygl.smslog.SmsLogPKValidator;
|
import com.cowr.ssjygl.sms.log.SmsLogPKValidator;
|
||||||
import com.cowr.ssjygl.smslog.SmsLogService;
|
import com.cowr.ssjygl.sms.log.SmsLogService;
|
||||||
import com.jfinal.aop.Before;
|
import com.jfinal.aop.Before;
|
||||||
import com.jfinal.core.Controller;
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.cowr.service.ssjygl.smslog;
|
package com.cowr.service.ssjygl.sms.log;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cowr.common.Const;
|
import com.cowr.common.Const;
|
||||||
import com.cowr.common.enums.UserTypeEnum;
|
import com.cowr.common.enums.UserTypeEnum;
|
||||||
|
|
@ -13,8 +12,7 @@ import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmsService {
|
public class SmsService {
|
||||||
private static Log log = Log.getLog(SmsService.class);
|
private static Log log = Log.getLog(SmsService.class);
|
||||||
|
|
@ -80,6 +78,60 @@ public class SmsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sendBySysusers(List<Sysuser> users, String temp_code, JSONObject obj, String content, String relate_table, String relate_id){
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
|
for (Sysuser sysuser : users) {
|
||||||
|
try {
|
||||||
|
String phone = sysuser.getPhone();
|
||||||
|
|
||||||
|
if (Config.isDev()) {
|
||||||
|
phone = "13627293906";
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("给 %s 发送短信", phone);
|
||||||
|
|
||||||
|
String response = this.aliyunsms.send(phone, temp_code, obj);
|
||||||
|
log.debug(response);
|
||||||
|
|
||||||
|
JSONObject ret = JSONObject.parseObject(response);
|
||||||
|
|
||||||
|
SmsLog smslog = new SmsLog();
|
||||||
|
smslog.setId(StrKit.getRandomUUID());
|
||||||
|
smslog.setPhone(phone);
|
||||||
|
smslog.setName(sysuser.getName());
|
||||||
|
smslog.setContent(obj.toJSONString());
|
||||||
|
smslog.setCreateTime(now);
|
||||||
|
smslog.setSendcontent(content);
|
||||||
|
|
||||||
|
if (ret.containsKey("BizId")) {
|
||||||
|
smslog.setBizid(ret.getString("BizId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.containsKey("Code")) {
|
||||||
|
smslog.setCode(ret.getString("Code"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.containsKey("RequestId")) {
|
||||||
|
smslog.setRequestid(ret.getString("RequestId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.containsKey("RequestId")) {
|
||||||
|
smslog.setRequestid(ret.getString("RequestId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
smslog.setRelateTable(relate_table);
|
||||||
|
smslog.setRelateId(relate_id);
|
||||||
|
|
||||||
|
smslog.save();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送配额通知短信
|
* 发送配额通知短信
|
||||||
* 模版内容: 已经在${supermarket_name}分配了${weight}吨配额,请在${date}当天安排车辆前去运输。
|
* 模版内容: 已经在${supermarket_name}分配了${weight}吨配额,请在${date}当天安排车辆前去运输。
|
||||||
|
|
@ -147,8 +199,140 @@ public class SmsService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return sendBySysusers(users, Const.TEMP_CODE_PEIE, obj, content, ordercluster.getTablename(), ordercluster.getId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户预付款存入成功通知
|
||||||
|
* ${time}${customer_name}在浠水县长投环保有限公司的预存${amount}元,合计余额${surplus}元。
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean sendDepositSuccess(Customer customer, BigDecimal amount, BigDecimal surplus) {
|
||||||
|
if (customer == null) {
|
||||||
|
log.debug("无效的客户信息");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 充值小于等于 0 的肯定就不发了
|
||||||
|
if (amount.compareTo(new BigDecimal("0")) <= 0) {
|
||||||
|
log.debug("充值金额错误 %s", amount);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Sysuser> users = Sysuser.dao.find("select * from sysuser t where t.type = ? and t.entity_id = ?", UserTypeEnum.CUSTOMER.getTypeid(), customer.getId());
|
||||||
|
|
||||||
|
if (users == null || users.isEmpty()) {
|
||||||
|
log.error("没有找到有效的用户信息");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
String date = DateTimeUtil.sdfymd.get().format(now);
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
obj.put("time", date);
|
||||||
|
obj.put("customer_name", customer.getName());
|
||||||
|
obj.put("amount", String.format("%.2f", amount));
|
||||||
|
obj.put("surplus", String.format("%.2f", surplus));
|
||||||
|
|
||||||
|
String content = null;
|
||||||
|
try {
|
||||||
|
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_DEPOSIT_SUCCESS), obj);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sendBySysusers(users, Const.TEMP_CODE_DEPOSIT_SUCCESS, obj, content, customer.getTablename(), customer.getId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户预付款存入失败通知
|
||||||
|
* ${time}${customer_name}在浠水县长投环保有限公司预存的${amount}元审核未通过,若有疑问请及时联系浠水县长投环保结算中心。
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean sendDepositFail(Customer customer, BigDecimal amount) {
|
||||||
|
if (customer == null) {
|
||||||
|
log.debug("无效的客户信息");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 充值小于等于 0 的肯定就不发了
|
||||||
|
if (amount.compareTo(new BigDecimal("0")) <= 0) {
|
||||||
|
log.debug("充值金额错误 %s", amount);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Sysuser> users = Sysuser.dao.find("select * from sysuser t where t.type = ? and t.entity_id = ?", UserTypeEnum.CUSTOMER.getTypeid(), customer.getId());
|
||||||
|
|
||||||
|
if (users == null || users.isEmpty()) {
|
||||||
|
log.error("没有找到有效的用户信息");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
String date = DateTimeUtil.sdfymd.get().format(now);
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
obj.put("time", date);
|
||||||
|
obj.put("customer_name", customer.getName());
|
||||||
|
obj.put("amount", String.format("%.2f", amount));
|
||||||
|
|
||||||
|
String content = null;
|
||||||
|
try {
|
||||||
|
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_DEPOSIT_FAIL), obj);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sendBySysusers(users, Const.TEMP_CODE_DEPOSIT_FAIL, obj, content, customer.getTablename(), customer.getId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户每日汇总
|
||||||
|
* ${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。。
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean sendCustomerDayStat(Map<Integer, JSONObject> smsmap){
|
||||||
|
if(smsmap.isEmpty()){
|
||||||
|
log.debug("发送对象没有内容");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> ids = new ArrayList<>();
|
||||||
|
for(Integer k : smsmap.keySet()){
|
||||||
|
ids.add("?");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ids.isEmpty()){
|
||||||
|
log.debug("没有有效的id");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Sysuser> users = Sysuser.dao.find(
|
||||||
|
"select * from sysuser t where t.type = " + UserTypeEnum.CUSTOMER.getTypeid() + " and t.entity_id in (" + StrKit.join(ids, ",") + ")",
|
||||||
|
smsmap.keySet().toArray());
|
||||||
|
|
||||||
|
if (users == null || users.isEmpty()) {
|
||||||
|
log.error("没有找到有效的用户信息");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
for (Sysuser sysuser : users) {
|
for (Sysuser sysuser : users) {
|
||||||
try {
|
try {
|
||||||
|
Integer customer_id = sysuser.getEntityId();
|
||||||
|
|
||||||
|
if(!smsmap.containsKey(customer_id)){
|
||||||
|
log.debug("没有找到 %s 关联的发送内容", customer_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String phone = sysuser.getPhone();
|
String phone = sysuser.getPhone();
|
||||||
|
|
||||||
if (Config.isDev()) {
|
if (Config.isDev()) {
|
||||||
|
|
@ -157,7 +341,16 @@ public class SmsService {
|
||||||
|
|
||||||
log.debug("给 %s 发送短信", phone);
|
log.debug("给 %s 发送短信", phone);
|
||||||
|
|
||||||
String response = this.aliyunsms.send(phone, Const.TEMP_CODE_PEIE, obj);
|
JSONObject obj = smsmap.get(customer_id);
|
||||||
|
String content = null;
|
||||||
|
try {
|
||||||
|
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_CUSTOMER_DAY_STAT), obj);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String response = this.aliyunsms.send(phone, Const.TEMP_CODE_CUSTOMER_DAY_STAT, obj);
|
||||||
log.debug(response);
|
log.debug(response);
|
||||||
|
|
||||||
JSONObject ret = JSONObject.parseObject(response);
|
JSONObject ret = JSONObject.parseObject(response);
|
||||||
|
|
@ -186,8 +379,8 @@ public class SmsService {
|
||||||
smslog.setRequestid(ret.getString("RequestId"));
|
smslog.setRequestid(ret.getString("RequestId"));
|
||||||
}
|
}
|
||||||
|
|
||||||
smslog.setRelateTable(ordercluster.getTablename());
|
smslog.setRelateTable(Customer.tablename);
|
||||||
smslog.setRelateId(ordercluster.getId().toString());
|
smslog.setRelateId(customer_id.toString());
|
||||||
|
|
||||||
smslog.save();
|
smslog.save();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -195,34 +388,6 @@ public class SmsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户预付款存入成功通知
|
|
||||||
* ${time}${customer_name}在浠水县长投环保有限公司的预存${amount}元,合计余额${surplus}元。
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean sendDepositSuccess(Customer customer, BigDecimal amount, BigDecimal surplus) {
|
|
||||||
if (customer == null) {
|
|
||||||
log.debug("无效的客户信息");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 充值小于等于 0 的肯定就不发了
|
|
||||||
if (amount.compareTo(new BigDecimal("0")) <= 0) {
|
|
||||||
log.debug("充值金额错误 %s", amount);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Sysuser> users = Sysuser.dao.find("select * from sysuser t where t.type = ? and t.entity_id = ?", UserTypeEnum.CUSTOMER.getTypeid(), customer.getId());
|
|
||||||
|
|
||||||
if (users == null || users.isEmpty()) {
|
|
||||||
log.error("没有找到有效的用户信息");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.cowr.service.ssjygl.sms.noticecontact;
|
||||||
|
|
||||||
|
import com.cowr.common.view.PageParam;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.SmsNoticeContact;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||||
|
import com.cowr.ssjygl.sms.noticecontact.SmsNoticeContactPKValidator;
|
||||||
|
import com.cowr.ssjygl.sms.noticecontact.SmsNoticeContactValidator;
|
||||||
|
import com.jfinal.aop.Before;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Nov 06 17:13:51 CST 2020
|
||||||
|
* TableName: sms_notice_contact
|
||||||
|
* Remarks: 系统配置 - 通知短信发送人员
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class SmsNoticeContactController extends Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增 sms_notice_contact 系统配置 - 通知短信发送人员
|
||||||
|
*/
|
||||||
|
@Before(SmsNoticeContactValidator.class)
|
||||||
|
public void save() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SmsNoticeContact model = getModel(SmsNoticeContact.class, "", true); // 忽略不在model中的字段
|
||||||
|
renderJson(SmsNoticeContactService.me.save(model, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除 sms_notice_contact 系统配置 - 通知短信发送人员
|
||||||
|
*/
|
||||||
|
@Before(SmsNoticeContactPKValidator.class)
|
||||||
|
public void del() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SmsNoticeContact model = getModel(SmsNoticeContact.class, "", true); // 忽略不在model中的字段
|
||||||
|
renderJson(SmsNoticeContactService.me.delete(model, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改 sms_notice_contact 系统配置 - 通知短信发送人员
|
||||||
|
*/
|
||||||
|
@Before(SmsNoticeContactValidator.class)
|
||||||
|
public void edit() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SmsNoticeContact model = getModel(SmsNoticeContact.class, "", true); // 忽略不在model中的字段
|
||||||
|
renderJson(SmsNoticeContactService.me.update(model, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查找 sms_notice_contact 系统配置 - 通知短信发送人员
|
||||||
|
*/
|
||||||
|
public void find() {
|
||||||
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
|
String name = get("name");
|
||||||
|
String phone = get("phone");
|
||||||
|
renderJson(Result.object(SmsNoticeContactService.me.find(pp, name, phone)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按主键查找单个对象 sms_notice_contact 系统配置 - 通知短信发送人员
|
||||||
|
*/
|
||||||
|
@Before(SmsNoticeContactPKValidator.class)
|
||||||
|
public void get() {
|
||||||
|
SmsNoticeContact model = getModel(SmsNoticeContact.class, "", true); // 忽略不在model中的字段
|
||||||
|
renderJson(SmsNoticeContactService.me.findByPk(model));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
package com.cowr.service.ssjygl.sms.noticecontact;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.cowr.common.Const;
|
||||||
|
import com.cowr.common.base.BaseService;
|
||||||
|
import com.cowr.common.view.PageParam;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.SmsNoticeContact;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
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 Fri Nov 06 17:13:51 CST 2020
|
||||||
|
* TableName: sms_notice_contact
|
||||||
|
* Remarks: 系统配置 - 通知短信发送人员
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class SmsNoticeContactService extends BaseService {
|
||||||
|
private static Log log = Log.getLog(SmsNoticeContactService.class);
|
||||||
|
public static final SmsNoticeContactService me = new SmsNoticeContactService();
|
||||||
|
|
||||||
|
public Result save(SmsNoticeContact model, Sysuser sysuser){
|
||||||
|
try {
|
||||||
|
model.setId(StrKit.getRandomUUID());
|
||||||
|
String type = model.getType();
|
||||||
|
List<Integer> list = JSONArray.parseArray(type, Integer.class);
|
||||||
|
|
||||||
|
for(Integer i : list){
|
||||||
|
if(i != 1){
|
||||||
|
return Result.failed("短信类型错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result ret = super.save(model, sysuser);
|
||||||
|
|
||||||
|
if(ret.getCode() == Result.SUCCESS){
|
||||||
|
Record out = model.toRecord();
|
||||||
|
out.set("type", list);
|
||||||
|
ret.setData(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return Result.failed("保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result update(SmsNoticeContact model, Sysuser sysuser){
|
||||||
|
try {
|
||||||
|
SmsNoticeContact chk = SmsNoticeContact.dao.findFirst("select * from sms_notice_contact t where t.id <> ? and t.phone = ? limit 1", model.getId(), model.getPhone());
|
||||||
|
|
||||||
|
if(chk != null){
|
||||||
|
return Result.failedstr("手机号 %s 已存在", model.getPhone());
|
||||||
|
}
|
||||||
|
|
||||||
|
String type = model.getType();
|
||||||
|
List<Integer> list = JSONArray.parseArray(type, Integer.class);
|
||||||
|
|
||||||
|
for(Integer i : list){
|
||||||
|
if(i != 1){
|
||||||
|
return Result.failed("短信类型错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result ret = super.update(model, sysuser);
|
||||||
|
|
||||||
|
if(ret.getCode() == Result.SUCCESS){
|
||||||
|
Record out = model.toRecord();
|
||||||
|
out.set("type", list);
|
||||||
|
ret.setData(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return Result.failed("保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<Record> find(PageParam pp, String name, String phone) {
|
||||||
|
String selectsql = "select * ";
|
||||||
|
String fromsql = "from sms_notice_contact t where 1=1 ";
|
||||||
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (StrKit.notBlank(name)) {
|
||||||
|
fromsql += " and t.name like ?\n";
|
||||||
|
paraList.add("%" + name.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(phone)) {
|
||||||
|
fromsql += " and t.phone like ?\n";
|
||||||
|
paraList.add("%" + phone.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
String totalRowSql = "select count(*) " + fromsql;
|
||||||
|
String findSql = selectsql + fromsql;
|
||||||
|
|
||||||
|
// 前端传了排序字段,并且排序字段存在相关表中
|
||||||
|
if (StrKit.notBlank(pp.getSort_field()) && SmsNoticeContact.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||||
|
List<Record> list = page.getList();
|
||||||
|
|
||||||
|
for(Record record : list){
|
||||||
|
String type = record.getStr("type");
|
||||||
|
List<Integer> ts = JSONArray.parseArray(type, Integer.class);
|
||||||
|
record.set("type", ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -152,7 +152,8 @@ public class SysuserController extends Controller {
|
||||||
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
|
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
|
||||||
Integer type = getInt("type");
|
Integer type = getInt("type");
|
||||||
Integer entity_id = getInt("entity_id");
|
Integer entity_id = getInt("entity_id");
|
||||||
renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id)));
|
String customer_name = get("customer_name");
|
||||||
|
renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id, customer_name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -795,8 +795,10 @@ public class SysuserSyncService extends BaseSyncService {
|
||||||
return sysuser;
|
return sysuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp, String name, String phone, Integer del, Integer type, Integer entity_id) {
|
public Page<Record> find(PageParam pp, String name, String phone, Integer del, Integer type, Integer entity_id, String customer_name) {
|
||||||
|
List<Object> paraList = new ArrayList<>();
|
||||||
StringBuilder sqlbuf = new StringBuilder();
|
StringBuilder sqlbuf = new StringBuilder();
|
||||||
|
|
||||||
sqlbuf.append(" from (\n");
|
sqlbuf.append(" from (\n");
|
||||||
sqlbuf.append("select \n");
|
sqlbuf.append("select \n");
|
||||||
sqlbuf.append(" u.id, u.phone, u.name, u.type, u.role, u.del\n");
|
sqlbuf.append(" u.id, u.phone, u.name, u.type, u.role, u.del\n");
|
||||||
|
|
@ -824,9 +826,12 @@ public class SysuserSyncService extends BaseSyncService {
|
||||||
sqlbuf.append(" left join customer c on u.entity_id = c.id\n");
|
sqlbuf.append(" left join customer c on u.entity_id = c.id\n");
|
||||||
sqlbuf.append(") a\n");
|
sqlbuf.append(") a\n");
|
||||||
sqlbuf.append("where 1 = 1");
|
sqlbuf.append("where 1 = 1");
|
||||||
}
|
|
||||||
|
|
||||||
List<Object> paraList = new ArrayList<>();
|
if(StrKit.notBlank(customer_name)){
|
||||||
|
sqlbuf.append(" and a.customer_name like ? \n");
|
||||||
|
paraList.add("%" + customer_name.trim() + "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (StrKit.notBlank(name)) {
|
if (StrKit.notBlank(name)) {
|
||||||
sqlbuf.append(" and a.name like ? \n");
|
sqlbuf.append(" and a.name like ? \n");
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,13 @@ synctask.enable=true
|
||||||
checkundonordercluster.job=com.cowr.service.ssjygl.jobs.CheckUndonOrderclusterJob
|
checkundonordercluster.job=com.cowr.service.ssjygl.jobs.CheckUndonOrderclusterJob
|
||||||
checkundonordercluster.cron= 1 0 0 * * ?
|
checkundonordercluster.cron= 1 0 0 * * ?
|
||||||
checkundonordercluster.enable=true
|
checkundonordercluster.enable=true
|
||||||
|
|
||||||
|
# 在1点检查超过2天的备份文件
|
||||||
|
cleanossbakfile.job=com.cowr.service.ssjygl.jobs.CleanOSSBakFileJob
|
||||||
|
cleanossbakfile.cron= 1 0 1 * * ?
|
||||||
|
cleanossbakfile.enable=true
|
||||||
|
|
||||||
|
# 每天 8 点统计发送前一天各客户销售情况
|
||||||
|
statsms.job=com.cowr.service.ssjygl.jobs.StatSmsJob
|
||||||
|
statsms.cron= 0 0 8 * * ?
|
||||||
|
statsms.enable=false
|
||||||
Loading…
Reference in New Issue