日销售统计短信修改

dev
徐杰盟 2024-08-20 15:27:52 +08:00
parent fea970bd69
commit f509113769
9 changed files with 102 additions and 10 deletions

View File

@ -30,6 +30,7 @@ public class Const {
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 final String TEMP_CODE_AGGR_DAY_STAT_1 = "SMS_471810248"; // 累计及日销售汇总(含处置砂)
public static Map<String, String> SMS_TEMP_MAP;
static {
@ -44,6 +45,7 @@ public class Const {
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}辆次。");
SMS_TEMP_MAP.put(TEMP_CODE_AGGR_DAY_STAT_1, "截至${time1}累计销售黄砂${aggr_weight}吨,共计${aggr_price}元,运输${aggr_cnt}辆次。处置砂${aggr_weight1}吨,共计${aggr_price1}元,运输${aggr_cnt1}辆次。${time2}当日销售黄砂${total_weight}吨,共计${total_price}元,运输${total_cnt}辆次。处置砂${total_weight1}吨,共计${total_price1}元,运输${total_cnt1}辆次。");
}

View File

@ -137,10 +137,36 @@ public class OrderEndService extends BaseService {
if (CollectionUtils.isEmpty(tempList)) {
log.info("数据结果为空");
throw new IllegalArgumentException("数据结果为空");
return;
}
processing(tm,customerId,tempList);
}
public void queryList(String tm,String customerId,String supermarketId,Integer saleType) {
// 获取历史数据
List<Record> tempList = OrderTempService.me.getOrderTempGroupBy(tm,customerId,supermarketId,null,null);
if (CollectionUtils.isEmpty(tempList)) {
log.info("数据结果为空");
if (StrKit.notBlank(customerId) &&StrKit.notBlank(tm) &&StrKit.notBlank(supermarketId) &&StrKit.notBlank(String.valueOf(saleType)) ){
String id = customerId + "_" + tm + "_" + supermarketId + "_" + saleType;
Record first = Db.findFirst("select * from order_end WHERE ID = '" + id + "'");
if (first != null){
first.set("weight","0");
first.set("total_price","0");
first.set("count","0");
boolean update = Db.update("order_end", first);
if (!update){
log.info("修改失败:" + first.toJson());
}
}
}
return;
}
processing(tm,customerId,tempList);
}
public void queryList(String tm,String customerId) {

View File

@ -486,7 +486,7 @@ public class OrderTempService extends BaseService {
paraList.add(LocalDate.now() + STM_SUFFIX);
}
String sql = "SELECT\n" +
String sql = "SELECT\n" +
"ifnull(CUSTOMER_ID, 0 ) CUSTOMER_ID,\n" +
"DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' ) DATE,\n" +
"SUPERMARKET_ID,\n" +

View File

@ -185,7 +185,8 @@ group by date
// " and t.product_id != 4\n" +
" select \n" +
" ifnull(sum(t.weight), 0) total_weight,\n" +
" ifnull(sum(t.total_price), 0) total_price,\n" +
// " ifnull(sum(t.total_price), 0) total_price,\n" +
" ifnull( sum( CASE WHEN t.sale_type = 0 THEN t.total_price END ), 0 ) total_price,\n" +
" ifnull(sum(t.count), 0) truck_cnt,\n" +
// " ifnull(sum(case when t.date >= ? and t.sale_type = 0 then t.weight end ), 0) year_total_weight,\n" +
" ifnull(sum(case when t.date >= ? then t.weight end ), 0) year_total_weight,\n" +
@ -205,7 +206,8 @@ group by date
" UNION\n" +
" SELECT\n" +
" ifnull( sum( t.weight ), 0 ) total_weight,\n" +
" ifnull( sum( t.total_price ), 0 ) total_price,\n" +
// " ifnull( sum( t.total_price ), 0 ) total_price,\n" +
" ifnull( sum( CASE WHEN t.sale_type = 0 THEN t.total_price END ), 0 ) total_price,\n" +
" ifnull( count( t.sn ), 0 ) truck_cnt,\n" +
" ifnull( sum( t.weight ), 0 ) year_total_weight,\n" +
" ifnull( sum(case when t.sale_type = 0 then t.total_price end ), 0 ) year_total_price,\n" +

View File

@ -9,6 +9,7 @@ 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.ssjygl.addsubtractitemrecord.AddSubtractItemRecordService;
import com.cowr.ssjygl.order.orderend.OrderEndService;
import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
@ -19,6 +20,7 @@ import org.quartz.Job;
import org.quartz.JobExecutionContext;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
/**
@ -343,6 +345,13 @@ public class StatSmsJob extends Controller implements Job {
SmsService.me.sendStatAggr(obj);
}
@Clear(AuthInterceptor.class)
public void statOrderEnd() {
LocalDate localDate = LocalDate.now().minusDays(1);
OrderEndService.me.queryList(localDate.minusDays(60).toString(),localDate.toString(),null); // 最近60天的数据
}
@Clear(AuthInterceptor.class)
public void statAggrAndDay() {
Date now = new Date();
Calendar c = Calendar.getInstance();
@ -369,33 +378,66 @@ public class StatSmsJob extends Controller implements Job {
" and t.product_id != 4 \n " +
" and t.create_time like '" + predaytm + "%'";
// 处置砂
String ordersql1 = "select count(t.sn) aggr_cnt, ifnull(sum(t.weight), 0) aggr_weight, " +
"ifnull(sum(case when t.sale_type = 0 then t.total_price end ), 0) aggr_price \n" +
" from order_temp t \n" +
" where t.state = 5 \n" +
" and t.product_id = 4 \n" +
" and t.create_time >= ? \n" +
" and t.create_time < ? \n";
String daysql1 = "select count(t.sn) total_cnt, ifnull(sum(t.weight), 0) total_weight, " +
"ifnull(sum(case when t.sale_type = 0 then t.total_price end ), 0) total_price \n" +
" from order_temp t \n" +
" where t.state = 5 \n" +
" and t.product_id = 4 \n " +
" and t.create_time like '" + predaytm + "%'";
JSONObject obj = new JSONObject();
Record orderobj = Db.findFirst(ordersql, year_start, daytm);
Record dayobj = Db.findFirst(daysql);
// 处置砂
Record orderobj1 = Db.findFirst(ordersql1, year_start, daytm);
Record dayobj1 = Db.findFirst(daysql1);
obj.put("time1", sendtmtext);
obj.put("time2", sendtmtext);
if (
orderobj == null
|| dayobj == null
|| orderobj1 == null
|| dayobj1 == 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
|| orderobj1.get("aggr_cnt") == null
|| orderobj1.get("aggr_weight") == null
|| orderobj1.get("aggr_price") == null
|| dayobj1.get("total_cnt") == null
|| dayobj1.get("total_weight") == null
|| dayobj1.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());
log.error("5 执行错误 %s", orderobj1 == null ? null : orderobj1.toJson());
log.error("7 执行错误 %s", dayobj1 == null ? null : dayobj1.toJson());
return;
}
BigDecimal aggr_weight = orderobj.getBigDecimal("aggr_weight");
BigDecimal aggr_price = orderobj.getBigDecimal("aggr_price");
BigDecimal aggr_weight1 = orderobj1.getBigDecimal("aggr_weight");
BigDecimal aggr_price1 = orderobj1.getBigDecimal("aggr_price");
String year = DateTimeUtil.year.get().format(now); // 当前年
if ("2024".equals(year)) {
@ -419,8 +461,25 @@ public class StatSmsJob extends Controller implements Job {
obj.put("total_weight", String.format("%.2f", dayobj.getBigDecimal("total_weight")));
obj.put("total_price", String.format("%.2f", dayobj.getBigDecimal("total_price")));
// 处置砂
obj.put("aggr_cnt1", orderobj1.get("aggr_cnt"));
obj.put("aggr_weight1", String.format("%.2f万",
aggr_weight1.divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)
)
);
obj.put("aggr_price1", String.format("%.2f万",
aggr_price1.divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)
)
);
obj.put("total_cnt1", dayobj1.get("total_cnt"));
obj.put("total_weight1", String.format("%.2f", dayobj1.getBigDecimal("total_weight")));
obj.put("total_price1", String.format("%.2f", dayobj1.getBigDecimal("total_price")));
SmsService.me.sendStatAggrAndDay(obj);
// try {
// try {
// AliyunSmsService aliyunsms = new AliyunSmsService();
// String content = aliyunsms.generator(Const.SMS_TEMP_MAP.get("SMS_232891438"), obj);
// log.debug(content);

View File

@ -42,6 +42,7 @@ public class OrderInvalidVerifySyncService {
if (state == OrderStateEnum.INVALID.getStateid()) {
return notPass(model);
} else if (state == 2) {
// 订单取消申请
return OrderTempSyncService.me.cancel(model.getOrderSn(), model.getInvalidMemo(), user, password, model);
}

View File

@ -206,7 +206,7 @@ public class OrderTempSyncService {
try {
// 取消订单删除统计
OrderEndService.me.queryList(tm,String.valueOf( order.getCustomerId()),String.valueOf(order.getSupermarketId()) , null,null); // 訂單取消
OrderEndService.me.queryList(tm,String.valueOf( order.getCustomerId()),String.valueOf(order.getSupermarketId()), order.getSaleType()); // 訂單取消
}catch (Exception e){
log.error(e.getMessage(),e);
}

View File

@ -459,7 +459,8 @@ public class SmsService {
String phone = contact.getPhone();
if (Config.isDev()) {
phone = "13627293906";
// phone = "13627293906";
phone = "18891233883";
}
String response = this.aliyunsms.send(phone, temp_code, obj);
@ -521,6 +522,7 @@ public class SmsService {
}
public boolean sendStatAggrAndDay(JSONObject obj){
return sendStat(obj, Const.TEMP_CODE_AGGR_DAY_STAT, 2);
// return sendStat(obj, Const.TEMP_CODE_AGGR_DAY_STAT, 2);
return sendStat(obj, Const.TEMP_CODE_AGGR_DAY_STAT_1, 2);
}
}

View File

@ -549,7 +549,7 @@ public class SyncTaskService {
String sn = orderData.getJSONObject(0).getString("sn");
if (StrKit.notBlank(sn)){
// 判断sn是否添加过
String statkey = PrepayCustomerSyncService.me.redisbasekey() + sn;
String statkey = PrepayCustomerSyncService.me.redisbasekey() + sn + ":" + increment_data.getString("surplus");
if (! Redis.use().exists(statkey)) {
boolean ret = Db.update(tablename, pks, record);
@ -571,7 +571,7 @@ public class SyncTaskService {
}else{
// 当前sn 已添加过
JSONObject str = Redis.use().get(statkey);
log.info("当前sn 数据 : " + data.toJSONString());
log.info("当前sn 数据 : " + recvdata);
log.info("当前redis 数据" + str);
}
}