lisai17@sina.com 2021-01-07 21:49:24 +08:00
parent eff2a8aea4
commit 2193834913
10 changed files with 211 additions and 74 deletions

View File

@ -22,21 +22,25 @@ public class Const {
public static final String TEMP_CODE_AGGR_STAT = "SMS_205434464"; // 累计销售汇总 public static final String TEMP_CODE_AGGR_STAT = "SMS_205434464"; // 累计销售汇总
public static final String TEMP_CODE_DAY_STAT = "SMS_205430436"; // 日销售汇总 public static final String TEMP_CODE_DAY_STAT = "SMS_205430436"; // 日销售汇总
public static final String TEMP_CODE_CUSTOMER_DAY_STAT = "SMS_205430478"; // 客户日销售汇总 public static final String TEMP_CODE_CUSTOMER_DAY_STAT = "SMS_208985081"; // 客户日销售汇总
public static final String TEMP_CODE_PEIE = "SMS_203673037"; // 配额分配通知 public static final String TEMP_CODE_PEIE = "SMS_203673037"; // 配额分配通知
public static final String TEMP_CODE_DEPOSIT_SUCCESS = "SMS_205430440"; // 客户预存成功通知 public static final String TEMP_CODE_DEPOSIT_SUCCESS = "SMS_208980426"; // 客户预存成功通知
public static final String TEMP_CODE_DEPOSIT_FAIL = "SMS_205440366"; // 客户预存失败通知 public static final String TEMP_CODE_DEPOSIT_FAIL = "SMS_208985365"; // 客户预存失败通知
public static final String TEMP_CODE_SURPLUS_WARN = "SMS_208975325"; // 客户余额预警
public static final String TEMP_CODE_REFUND_SUCCESS = "SMS_208965364"; // 客户退款成功通知
public static Map<String, String> SMS_TEMP_MAP; public static Map<String, String> SMS_TEMP_MAP;
static { static {
SMS_TEMP_MAP = new HashMap<>(); SMS_TEMP_MAP = new HashMap<>();
SMS_TEMP_MAP.put(TEMP_CODE_DAY_STAT, "${time}销售汇总:${supermarket_count}个砂站共销售${weight}吨黄砂,总价${total_price}元。各砂站详情如下:${supermarket_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}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。"); SMS_TEMP_MAP.put(TEMP_CODE_CUSTOMER_DAY_STAT, "${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。账户余额${surplus}元。");
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}在${vendor}的预存${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}在${vendor}预存的${amount}元审核未通过,若有疑问请及时联系结算中心。");
SMS_TEMP_MAP.put(TEMP_CODE_AGGR_STAT, "截至${time1}累计销售黄砂${aggr_weight}吨,共计${aggr_price}元,运输${aggr_cnt}辆次。" + SMS_TEMP_MAP.put(TEMP_CODE_AGGR_STAT, "截至${time1}累计销售黄砂${aggr_weight}吨,共计${aggr_price}元,运输${aggr_cnt}辆次。" +
"账户累计${aggr_total_price}元,其中预付费客户总余额${customer_total_surplus}元。" + "账户累计${aggr_total_price}元,其中预付费客户总余额${customer_total_surplus}元。" +
"${time2}当日销售黄砂${total_weight}吨,共计${total_price}元,运输${total_cnt}辆次。"); "${time2}当日销售黄砂${total_weight}吨,共计${total_price}元,运输${total_cnt}辆次。");
SMS_TEMP_MAP.put(TEMP_CODE_SURPLUS_WARN, "截至${time}${customer_name}在${vendor}的预存账户余额为${surplus}元。请及时关注。");
SMS_TEMP_MAP.put(TEMP_CODE_REFUND_SUCCESS, "${time}${customer_name}在${vendor}的退款${amount}元,合计余额${surplus}元。");
} }
} }

View File

@ -51,6 +51,11 @@ public class DateTimeUtil {
return new SimpleDateFormat("yyyy-MM-dd HH:mm"); return new SimpleDateFormat("yyyy-MM-dd HH:mm");
} }
}; };
public static final ThreadLocal<SimpleDateFormat> sdfhmch = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy年MM月dd日HH时mm分");
}
};
/** /**
* *

View File

@ -5,9 +5,9 @@ import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
/** /**
* Generated by COWR Sun May 17 21:43:18 CST 2020 * Generated by COWR Thu Jan 07 10:50:36 CST 2021
* TableName: prepay_customer * TableName: prepay_customer
* Remarks: - * Remarks: -
* PrimaryKey: id * PrimaryKey: id
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@ -15,8 +15,8 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
public static final String tablename = "prepay_customer"; public static final String tablename = "prepay_customer";
@JSONField(serialize = false) @JSONField(serialize=false)
public String getTablename() { public String getTablename(){
return tablename; return tablename;
} }
@ -25,20 +25,19 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* type: INT(10) * type: INT(10)
* isNullable: NO * isNullable: NO
* isPrimaryKey: YES * isPrimaryKey: YES
* defaultValue: * defaultValue:
* * @param id
* @param id
*/ */
@JSONField(name = "id") @JSONField(name="id")
public void setId(Integer id) { public void setId(Integer id) {
set("id", id); set("id", id);
} }
/** /**
* @return id * @return id
*/ */
@JSONField(name = "id") @JSONField(name="id")
public Integer getId() { public Integer getId() {
return getInt("id"); return getInt("id");
} }
@ -48,20 +47,19 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* type: INT(10) * type: INT(10)
* isNullable: NO * isNullable: NO
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: * defaultValue:
*
* @param customerId customer id * @param customerId customer id
*/ */
@JSONField(name = "customer_id") @JSONField(name="customer_id")
public void setCustomerId(Integer customerId) { public void setCustomerId(Integer customerId) {
set("customer_id", customerId); set("customer_id", customerId);
} }
/** /**
* @return customer_id customer id * @return customer_id customer id
*/ */
@JSONField(name = "customer_id") @JSONField(name="customer_id")
public Integer getCustomerId() { public Integer getCustomerId() {
return getInt("customer_id"); return getInt("customer_id");
} }
@ -71,20 +69,19 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* type: INT(10) * type: INT(10)
* isNullable: YES * isNullable: YES
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: * defaultValue:
* * @param supermarketId id
* @param supermarketId id
*/ */
@JSONField(name = "supermarket_id") @JSONField(name="supermarket_id")
public void setSupermarketId(Integer supermarketId) { public void setSupermarketId(Integer supermarketId) {
set("supermarket_id", supermarketId); set("supermarket_id", supermarketId);
} }
/** /**
* @return supermarket_id id * @return supermarket_id id
*/ */
@JSONField(name = "supermarket_id") @JSONField(name="supermarket_id")
public Integer getSupermarketId() { public Integer getSupermarketId() {
return getInt("supermarket_id"); return getInt("supermarket_id");
} }
@ -95,19 +92,18 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* isNullable: NO * isNullable: NO
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: 0.00 * defaultValue: 0.00
*
* @param surplus * @param surplus
*/ */
@JSONField(name = "surplus") @JSONField(name="surplus")
public void setSurplus(java.math.BigDecimal surplus) { public void setSurplus(java.math.BigDecimal surplus) {
set("surplus", surplus); set("surplus", surplus);
} }
/** /**
* @return surplus * @return surplus
*/ */
@JSONField(name = "surplus") @JSONField(name="surplus")
public java.math.BigDecimal getSurplus() { public java.math.BigDecimal getSurplus() {
return get("surplus"); return get("surplus");
} }
@ -117,20 +113,19 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* type: DATETIME(19) * type: DATETIME(19)
* isNullable: YES * isNullable: YES
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: * defaultValue:
*
* @param rechargeTime * @param rechargeTime
*/ */
@JSONField(name = "recharge_time") @JSONField(name="recharge_time")
public void setRechargeTime(java.util.Date rechargeTime) { public void setRechargeTime(java.util.Date rechargeTime) {
set("recharge_time", rechargeTime); set("recharge_time", rechargeTime);
} }
/** /**
* @return recharge_time * @return recharge_time
*/ */
@JSONField(name = "recharge_time") @JSONField(name="recharge_time")
public java.util.Date getRechargeTime() { public java.util.Date getRechargeTime() {
return get("recharge_time"); return get("recharge_time");
} }
@ -140,20 +135,19 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* type: DATETIME(19) * type: DATETIME(19)
* isNullable: YES * isNullable: YES
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: * defaultValue:
*
* @param spendTime * @param spendTime
*/ */
@JSONField(name = "spend_time") @JSONField(name="spend_time")
public void setSpendTime(java.util.Date spendTime) { public void setSpendTime(java.util.Date spendTime) {
set("spend_time", spendTime); set("spend_time", spendTime);
} }
/** /**
* @return spend_time * @return spend_time
*/ */
@JSONField(name = "spend_time") @JSONField(name="spend_time")
public java.util.Date getSpendTime() { public java.util.Date getSpendTime() {
return get("spend_time"); return get("spend_time");
} }
@ -163,20 +157,19 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* type: DATETIME(19) * type: DATETIME(19)
* isNullable: YES * isNullable: YES
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: * defaultValue:
*
* @param firstRechargeTime * @param firstRechargeTime
*/ */
@JSONField(name = "first_recharge_time") @JSONField(name="first_recharge_time")
public void setFirstRechargeTime(java.util.Date firstRechargeTime) { public void setFirstRechargeTime(java.util.Date firstRechargeTime) {
set("first_recharge_time", firstRechargeTime); set("first_recharge_time", firstRechargeTime);
} }
/** /**
* @return first_recharge_time * @return first_recharge_time
*/ */
@JSONField(name = "first_recharge_time") @JSONField(name="first_recharge_time")
public java.util.Date getFirstRechargeTime() { public java.util.Date getFirstRechargeTime() {
return get("first_recharge_time"); return get("first_recharge_time");
} }
@ -187,21 +180,43 @@ public abstract class BasePrepayCustomer<M extends BasePrepayCustomer<M>> extend
* isNullable: YES * isNullable: YES
* isPrimaryKey: NO * isPrimaryKey: NO
* defaultValue: 3000.00 * defaultValue: 3000.00
*
* @param threshold * @param threshold
*/ */
@JSONField(name = "threshold") @JSONField(name="threshold")
public void setThreshold(java.math.BigDecimal threshold) { public void setThreshold(java.math.BigDecimal threshold) {
set("threshold", threshold); set("threshold", threshold);
} }
/** /**
* @return threshold * @return threshold
*/ */
@JSONField(name = "threshold") @JSONField(name="threshold")
public java.math.BigDecimal getThreshold() { public java.math.BigDecimal getThreshold() {
return get("threshold"); return get("threshold");
} }
/**
* name: notice
* type: INT(10)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue: 0
* @param notice 10
*/
@JSONField(name="notice")
public void setNotice(Integer notice) {
set("notice", notice);
}
/**
* @return notice 10
*/
@JSONField(name="notice")
public Integer getNotice() {
return getInt("notice");
}
} }

View File

@ -0,0 +1,81 @@
package com.cowr.service.ssjygl.jobs;
import com.alibaba.fastjson.JSONObject;
import com.cowr.common.Const;
import com.cowr.common.utils.DateTimeUtil;
import com.cowr.model.PrepayCustomer;
import com.cowr.service.ssjygl.main.Config;
import com.cowr.service.ssjygl.sms.log.SmsService;
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 org.quartz.JobExecutionException;
import java.util.*;
public class CheckPrepaySurplusJob implements Job {
private static Log log = Log.getLog(CheckPrepaySurplusJob.class);
//截至${time}${customer_name}在${vendor}的预存账户余额为${surplus}元。请及时关注。
public void checkSurplus() {
List<Record> list = Db.find("select t.*, c.name customer_name from prepay_customer t\n" +
" left join customer c on c.id = t.customer_id\n" +
" where t.notice = 0\n" +
" and t.surplus < t.threshold");
if (list.isEmpty()) {
log.debug("没有低于阈值的客户需要发送通知");
return;
}
List<Record> ps = new ArrayList<>();
Map<Integer, JSONObject> smsmap = new HashMap<>();
Date now = new Date();
for (Record record : list) {
smsmap.put(record.getInt("customer_id"),
new JSONObject()
.fluentPut("time", DateTimeUtil.sdfhmch.get().format(now))
.fluentPut("customer_name", record.getStr("customer_name"))
.fluentPut("surplus", String.format("%.2f", record.getBigDecimal("surplus")))
.fluentPut("vendor", Config.configprop.get("print.vendor"))
);
Record p = new Record();
p.set("id", record.getInt("id"));
p.set("notice", 1);
ps.add(p);
}
if (smsmap.isEmpty()) {
log.debug("没有可以发送的短信内容");
return;
}
try {
SmsService.me.sendCustomerSms(Const.TEMP_CODE_SURPLUS_WARN, smsmap);
}catch (Exception e){
log.error(e.getMessage(),e);
}
try {
if(!ps.isEmpty()){
Db.batchUpdate(PrepayCustomer.tablename, ps, ps.size());
}
}catch (Exception e){
log.error(e.getMessage(),e);
}
}
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
checkSurplus();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}

View File

@ -1,7 +1,9 @@
package com.cowr.service.ssjygl.jobs; package com.cowr.service.ssjygl.jobs;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cowr.common.Const;
import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.utils.DateTimeUtil;
import com.cowr.model.PrepayCustomer;
import com.cowr.service.ssjygl.main.Config; import com.cowr.service.ssjygl.main.Config;
import com.cowr.service.ssjygl.main.SvrCacheData; import com.cowr.service.ssjygl.main.SvrCacheData;
import com.cowr.service.ssjygl.sms.log.SmsService; import com.cowr.service.ssjygl.sms.log.SmsService;
@ -47,11 +49,14 @@ public class StatSmsJob implements Job {
return; return;
} }
Map<Integer, List<Record>> map = new HashMap<>(); Map<Integer, List<Record>> map = new HashMap<>();
Map<Integer, JSONObject> smsmap = new HashMap<>(); Map<Integer, JSONObject> smsmap = new HashMap<>();
Map<Integer, PrepayCustomer> pmap = new HashMap<>();
List<String> ids = new ArrayList<>();
for (Record record : list) { for (Record record : list) {
int customer_id = record.getInt("customer_id"); Integer customer_id = record.getInt("customer_id");
ids.add(customer_id.toString());
if (!map.containsKey(customer_id)) { if (!map.containsKey(customer_id)) {
map.put(customer_id, new ArrayList<>()); map.put(customer_id, new ArrayList<>());
@ -60,6 +65,12 @@ public class StatSmsJob implements Job {
map.get(customer_id).add(record); map.get(customer_id).add(record);
} }
List<PrepayCustomer> prepayCustomers = PrepayCustomer.dao.find("select * from prepay_customer t where t.id in (" + StrKit.join(ids, ",") + ")");
for (PrepayCustomer p : prepayCustomers) {
pmap.put(p.getCustomerId(), p);
}
// ${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。 // ${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。
for (Map.Entry<Integer, List<Record>> entry : map.entrySet()) { for (Map.Entry<Integer, List<Record>> entry : map.entrySet()) {
BigDecimal weight = new BigDecimal("0"); BigDecimal weight = new BigDecimal("0");
@ -95,6 +106,10 @@ public class StatSmsJob implements Job {
sendobj.put("truck_num", truck_num); sendobj.put("truck_num", truck_num);
sendobj.put("supermarket_detail", supermarket_detail.substring(0, supermarket_detail.length() - 1)); sendobj.put("supermarket_detail", supermarket_detail.substring(0, supermarket_detail.length() - 1));
if (pmap.containsKey(customer_id)) {
sendobj.put("surplus", String.format("%.2f", pmap.get(customer_id).getSurplus()));
}
smsmap.put(customer_id, sendobj); smsmap.put(customer_id, sendobj);
} }
@ -103,7 +118,7 @@ public class StatSmsJob implements Job {
return; return;
} }
SmsService.me.sendCustomerDayStat(smsmap); SmsService.me.sendCustomerSms(Const.TEMP_CODE_CUSTOMER_DAY_STAT, smsmap);
} }
/** /**
@ -188,9 +203,9 @@ public class StatSmsJob implements Job {
String predaytm = DateTimeUtil.sdf.get().format(c.getTime()); // 前一日 String predaytm = DateTimeUtil.sdf.get().format(c.getTime()); // 前一日
String sendtmtext = DateTimeUtil.sdfymd.get().format(c.getTime()); String sendtmtext = DateTimeUtil.sdfymd.get().format(c.getTime());
String year_start = DateTimeUtil.year_start.get().format(now); String year_start = DateTimeUtil.year_start.get().format(now);
String year_end = DateTimeUtil.sdf.get().format(now); String year_end = DateTimeUtil.sdf.get().format(now);
String ordersql = "select count(t.sn) aggr_cnt, ifnull(sum(t.weight), 0) aggr_weight, ifnull(sum(t.total_price), 0) aggr_price \n" + String ordersql = "select count(t.sn) aggr_cnt, ifnull(sum(t.weight), 0) aggr_weight, ifnull(sum(t.total_price), 0) aggr_price \n" +
" from order_temp t \n" + " from order_temp t \n" +
" where t.create_time >= ? \n" + " where t.create_time >= ? \n" +
" and t.create_time < ? \n" + " and t.create_time < ? \n" +

View File

@ -16,8 +16,6 @@ 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.CheckExceptionDataJob;
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;

View File

@ -1,6 +1,7 @@
package com.cowr.service.ssjygl.prepay.prepaydetail; package com.cowr.service.ssjygl.prepay.prepaydetail;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cowr.common.Const;
import com.cowr.common.enums.Enums; 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.*;
@ -155,6 +156,7 @@ public class PrepayDetailSyncService extends BaseSyncService {
prepayCustomer[0].setSurplus(model.getAmount()); // 更新余额 prepayCustomer[0].setSurplus(model.getAmount()); // 更新余额
prepayCustomer[0].setRechargeTime(now); // 更新最后一次充值时间 prepayCustomer[0].setRechargeTime(now); // 更新最后一次充值时间
prepayCustomer[0].setFirstRechargeTime(now); prepayCustomer[0].setFirstRechargeTime(now);
prepayCustomer[0].setNotice(0);
ret = prepayCustomer[0].save(); ret = prepayCustomer[0].save();
@ -162,6 +164,7 @@ public class PrepayDetailSyncService extends BaseSyncService {
} else { } else {
prepayCustomer[0].setSurplus(prepayCustomer[0].getSurplus().add(model.getAmount())); // 更新余额 prepayCustomer[0].setSurplus(prepayCustomer[0].getSurplus().add(model.getAmount())); // 更新余额
prepayCustomer[0].setRechargeTime(now); // 更新最后一次充值时间 prepayCustomer[0].setRechargeTime(now); // 更新最后一次充值时间
prepayCustomer[0].setNotice(0);
ret = prepayCustomer[0].update(); ret = prepayCustomer[0].update();
@ -204,7 +207,7 @@ public class PrepayDetailSyncService extends BaseSyncService {
if (ret && model.getAmount() != null) { if (ret && model.getAmount() != null) {
if (state == 2 && prepayCustomer[0] != null && prepayCustomer[0].getSurplus() != null) { if (state == 2 && prepayCustomer[0] != null && prepayCustomer[0].getSurplus() != null) {
// 审核通过 // 审核通过
SmsService.me.sendDepositSuccess(customer, model.getAmount(), prepayCustomer[0].getSurplus()); SmsService.me.sendCustomerNoticeSuccess(Const.TEMP_CODE_DEPOSIT_SUCCESS, customer, model.getAmount(), prepayCustomer[0].getSurplus());
} else if (state == 9) { } else if (state == 9) {
// 审核未通过 // 审核未通过
SmsService.me.sendDepositFail(customer, model.getAmount()); SmsService.me.sendDepositFail(customer, model.getAmount());

View File

@ -1,10 +1,12 @@
package com.cowr.service.ssjygl.prepay.refunddetail; package com.cowr.service.ssjygl.prepay.refunddetail;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cowr.common.Const;
import com.cowr.common.enums.Enums; 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;
@ -231,6 +233,10 @@ public class RefundDetailSyncService extends BaseSyncService {
model.setSerialnum(serialnum); model.setSerialnum(serialnum);
model.setState(3); model.setState(3);
if (model.checkDuplicate("serialnum")) {
return Result.failedstr("流水号【%s】已存在", model.getSerialnum());
}
SyncTask synctask = new SyncTask(); SyncTask synctask = new SyncTask();
RefundDetail oldmodel = model.clone(); RefundDetail oldmodel = model.clone();
@ -290,6 +296,10 @@ public class RefundDetailSyncService extends BaseSyncService {
} }
}); });
if (ret && model.getState() == 3) {
SmsService.me.sendCustomerNoticeSuccess(Const.TEMP_CODE_REFUND_SUCCESS, customer, model.getAmount(), prepayCustomer.getSurplus());
}
return ret ? Result.object(model) : Result.failed(false, "更新失败"); return ret ? Result.object(model) : Result.failed(false, "更新失败");
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

View File

@ -221,11 +221,11 @@ public class SmsService {
/** /**
* *
* ${time}${customer_name}${amount}${surplus} * ${time}${customer_name}${vendor}${amount}${surplus}
* *
* @return * @return
*/ */
public boolean sendDepositSuccess(Customer customer, BigDecimal amount, BigDecimal surplus) { public boolean sendCustomerNoticeSuccess(String temp_code, Customer customer, BigDecimal amount, BigDecimal surplus) {
if (customer == null) { if (customer == null) {
log.debug("无效的客户信息"); log.debug("无效的客户信息");
return false; return false;
@ -252,22 +252,22 @@ public class SmsService {
obj.put("customer_name", customer.getName()); obj.put("customer_name", customer.getName());
obj.put("amount", String.format("%.2f", amount)); obj.put("amount", String.format("%.2f", amount));
obj.put("surplus", String.format("%.2f", surplus)); obj.put("surplus", String.format("%.2f", surplus));
obj.put("vendor", Config.configprop.get("print.vendor"));
String content = null; String content = null;
try { try {
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_DEPOSIT_SUCCESS), obj); content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(temp_code), obj);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return false; return false;
} }
return sendBySysusers(users, Const.TEMP_CODE_DEPOSIT_SUCCESS, obj, content, customer.getTablename(), customer.getId().toString()); return sendBySysusers(users, temp_code, obj, content, customer.getTablename(), customer.getId().toString());
} }
/** /**
* *
* ${time}${customer_name}${amount} * ${time}${customer_name}${vendor}${amount}
* *
* @return * @return
*/ */
@ -297,6 +297,7 @@ public class SmsService {
obj.put("time", date); obj.put("time", date);
obj.put("customer_name", customer.getName()); obj.put("customer_name", customer.getName());
obj.put("amount", String.format("%.2f", amount)); obj.put("amount", String.format("%.2f", amount));
obj.put("vendor", Config.configprop.get("print.vendor"));
String content = null; String content = null;
try { try {
@ -310,12 +311,12 @@ public class SmsService {
} }
/** /**
* * map
* ${time}${weight}${truck_num}${total_price}${supermarket_detail} * ${time}${weight}${truck_num}${total_price}${supermarket_detail}
* * ${time}${customer_name}${vendor}${surplus}
* @return * @return
*/ */
public boolean sendCustomerDayStat(Map<Integer, JSONObject> smsmap) { public boolean sendCustomerSms(String temp_code, Map<Integer, JSONObject> smsmap) {
if (smsmap.isEmpty()) { if (smsmap.isEmpty()) {
log.debug("发送对象没有内容"); log.debug("发送对象没有内容");
return false; return false;
@ -363,13 +364,13 @@ public class SmsService {
JSONObject obj = smsmap.get(customer_id); JSONObject obj = smsmap.get(customer_id);
String content = null; String content = null;
try { try {
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_CUSTOMER_DAY_STAT), obj); content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(temp_code), obj);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return false; return false;
} }
String response = this.aliyunsms.send(phone, Const.TEMP_CODE_CUSTOMER_DAY_STAT, obj); String response = this.aliyunsms.send(phone, temp_code, obj);
log.debug(response); log.debug(response);
JSONObject ret = JSONObject.parseObject(response); JSONObject ret = JSONObject.parseObject(response);

View File

@ -4,6 +4,11 @@ synctask.job=com.cowr.service.ssjygl.jobs.SyncJob
synctask.cron= 0 * * * * ? synctask.cron= 0 * * * * ?
synctask.enable=true synctask.enable=true
# 检查低于阈值的客户,发送一次短信通知
checkprepaysurplus.job=com.cowr.service.ssjygl.jobs.CheckPrepaySurplusJob
checkprepaysurplus.cron= 30 * * * * ?
checkprepaysurplus.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 * * ?