累计统计及日统计短信
parent
a9f177230c
commit
7e6d613083
|
|
@ -29,6 +29,7 @@ public class Const {
|
|||
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 final String TEMP_CODE_AGGR_DAY_STAT = "SMS_232891438"; // 累计及日销售汇总(不含预售)
|
||||
public static Map<String, String> SMS_TEMP_MAP;
|
||||
|
||||
static {
|
||||
|
|
@ -42,5 +43,6 @@ public class Const {
|
|||
SMS_TEMP_MAP.put(TEMP_CODE_AGGR_STAT_2, "截至${time1}累计销售黄砂${aggr_weight}吨,共计${aggr_price}元,运输${aggr_cnt}辆次;其中2020年充值客户销售${customer_weight}吨,共${customer_price}元,2021年新增客户销售${revenue_weight}吨,共${revenue}元。${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}元。");
|
||||
SMS_TEMP_MAP.put(TEMP_CODE_AGGR_DAY_STAT, "截至${time1}累计销售黄砂${aggr_weight}吨,共计${aggr_price}元,运输${aggr_cnt}辆次。${time2}当日销售黄砂${total_weight}吨,共计${total_price}元,运输${total_cnt}辆次。");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.cowr.model.PrepayCustomer;
|
|||
import com.cowr.service.ssjygl.main.Config;
|
||||
import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||
import com.cowr.service.ssjygl.sms.log.SmsService;
|
||||
import com.cowr.sms.AliyunSmsService;
|
||||
import com.cowr.ssjygl.addsubtractitemrecord.AddSubtractItemRecordService;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
|
|
@ -331,11 +332,81 @@ public class StatSmsJob implements Job {
|
|||
obj.put("total_price", String.format("%.2f", dayobj.getBigDecimal("total_price")));
|
||||
|
||||
SmsService.me.sendStatAggr(obj);
|
||||
}
|
||||
|
||||
public void statAggrAndDay() {
|
||||
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 daytm = DateTimeUtil.sdf.get().format(now); // 当日
|
||||
String sendtmtext = DateTimeUtil.sdfymd.get().format(c.getTime());
|
||||
String year_start = DateTimeUtil.year_start.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" +
|
||||
" from order_temp t \n" +
|
||||
" where t.state = 5 \n" +
|
||||
" and t.sale_type = 0 \n" +
|
||||
" and t.create_time >= ? \n" +
|
||||
" and t.create_time < ? \n";
|
||||
|
||||
String daysql = "select count(t.sn) total_cnt, ifnull(sum(t.weight), 0) total_weight, ifnull(sum(t.total_price), 0) total_price \n" +
|
||||
" from order_temp t \n" +
|
||||
" where t.state = 5 \n" +
|
||||
" and t.sale_type = 0 \n " +
|
||||
" and t.create_time like '" + predaytm + "%'";
|
||||
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
Record orderobj = Db.findFirst(ordersql, year_start, daytm);
|
||||
Record dayobj = Db.findFirst(daysql);
|
||||
|
||||
obj.put("time1", sendtmtext);
|
||||
obj.put("time2", sendtmtext);
|
||||
|
||||
if (
|
||||
orderobj == null
|
||||
|| dayobj == null
|
||||
|| orderobj.get("aggr_cnt") == null
|
||||
|| orderobj.get("aggr_weight") == null
|
||||
|| orderobj.get("aggr_price") == null
|
||||
|| dayobj.get("total_cnt") == null
|
||||
|| dayobj.get("total_weight") == null
|
||||
|| dayobj.get("total_price") == null
|
||||
) {
|
||||
log.error("sql 执行错误");
|
||||
log.error("1 执行错误 %s", orderobj == null ? null : orderobj.toJson());
|
||||
log.error("3 执行错误 %s", dayobj == null ? null : dayobj.toJson());
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal aggr_weight = orderobj.getBigDecimal("aggr_weight");
|
||||
BigDecimal aggr_price = orderobj.getBigDecimal("aggr_price");
|
||||
|
||||
|
||||
obj.put("aggr_cnt", orderobj.get("aggr_cnt"));
|
||||
obj.put("aggr_weight", String.format("%.2f万",
|
||||
aggr_weight.divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)
|
||||
)
|
||||
);
|
||||
obj.put("aggr_price", String.format("%.2f万",
|
||||
aggr_price.divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
obj.put("total_cnt", dayobj.get("total_cnt"));
|
||||
obj.put("total_weight", String.format("%.2f", dayobj.getBigDecimal("total_weight")));
|
||||
obj.put("total_price", String.format("%.2f", dayobj.getBigDecimal("total_price")));
|
||||
|
||||
SmsService.me.sendStatAggrAndDay(obj);
|
||||
// try {
|
||||
// AliyunSmsService aliyunsms = new AliyunSmsService();
|
||||
// String content = aliyunsms.generator(Const.SMS_TEMP_MAP.get("SMS_212486582"), obj);
|
||||
// String content = aliyunsms.generator(Const.SMS_TEMP_MAP.get("SMS_232891438"), obj);
|
||||
// log.debug(content);
|
||||
// String response = aliyunsms.send("13627293906", "SMS_212486582", obj);
|
||||
// String response = aliyunsms.send("15071482140", "SMS_232891438", obj);
|
||||
// log.debug(content);
|
||||
// log.debug(response);
|
||||
// } catch (Exception e) {
|
||||
|
|
@ -355,6 +426,12 @@ public class StatSmsJob implements Job {
|
|||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
|
||||
try {
|
||||
statAggrAndDay();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
stat();
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -519,4 +519,8 @@ public class SmsService {
|
|||
public boolean sendStatAggr(JSONObject obj){
|
||||
return sendStat(obj, Const.TEMP_CODE_AGGR_STAT_2, 2);
|
||||
}
|
||||
|
||||
public boolean sendStatAggrAndDay(JSONObject obj){
|
||||
return sendStat(obj, Const.TEMP_CODE_AGGR_DAY_STAT, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue