|
@@ -21,8 +21,8 @@ import com.fs.his.dto.ExpressInfoDTO;
|
|
|
import com.fs.his.service.IFsExpressService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
-import com.fs.hisStore.config.FsErpConfig;
|
|
|
import com.fs.hisStore.domain.*;
|
|
|
+import com.fs.hisStore.dto.DateComparisonConfigDTO;
|
|
|
import com.fs.hisStore.enums.ShipperCodeEnum;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
@@ -35,16 +35,20 @@ import com.fs.pay.service.IPayService;
|
|
|
import com.fs.store.config.StoreConfig;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.ybPay.domain.OrderResult;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
|
|
|
|
|
@@ -53,8 +57,9 @@ import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
|
|
|
*
|
|
|
* @author fs
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Component("mallStoreTask")
|
|
|
-public class StoreTask
|
|
|
+public class MallStoreTask
|
|
|
{
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
@@ -504,4 +509,82 @@ public class StoreTask
|
|
|
fsUserOnlineStateService.insertUserNotOnline();
|
|
|
}*/
|
|
|
|
|
|
+ /**
|
|
|
+ * 提醒证件到期任务
|
|
|
+ * */
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+ public void remindCertValidation() {
|
|
|
+ log.info("提醒店铺证件到期任务执行... 当前时间: {}", LocalTime.now());
|
|
|
+
|
|
|
+ // 从配置表获取需要比较的表和字段
|
|
|
+ List<DateComparisonConfigDTO> tablesToCheck = jdbcTemplate.query(
|
|
|
+ "SELECT table_name, date_column,in_advance,user_column,phone_column,remind_words,platform,cert_type" +
|
|
|
+ " FROM date_comparison_config",(rs, rowNum)->{
|
|
|
+ return DateComparisonConfigDTO.builder()
|
|
|
+ .tableName(rs.getString("table_name"))//表名
|
|
|
+ .certType(rs.getString("cert_type"))//证件类型
|
|
|
+ .dateColumn(rs.getString("date_column"))//日期字段
|
|
|
+ .userColumn(rs.getString("user_column"))//用户字段
|
|
|
+ .remindWords(rs.getString("remindWords"))//提醒内容
|
|
|
+ .phoneColumn(rs.getString("phone_column"))//提醒手机
|
|
|
+ .inAdvance(rs.getInt("inAdvance"))//提前天数
|
|
|
+ .platform(rs.getString("platform")).build();//平台
|
|
|
+ });
|
|
|
+
|
|
|
+ tablesToCheck.forEach(dto -> {
|
|
|
+ //获取证件失效日期字段小于当前时间加提前天数的用户和电话号码
|
|
|
+ String sql = String.format("SELECT %s , %s " +
|
|
|
+ "FROM %s " +
|
|
|
+ "WHERE %s >= DATE_SUB(CURDATE(), INTERVAL %d DAY)",
|
|
|
+ dto.getUserColumn(),
|
|
|
+ dto.getPhoneColumn(),
|
|
|
+ dto.getTableName(),
|
|
|
+ dto.getDateColumn(),
|
|
|
+ dto.getInAdvance()
|
|
|
+ );
|
|
|
+ List<Map<String, Object>> users = jdbcTemplate.queryForList(sql);
|
|
|
+ users.forEach(user -> {
|
|
|
+ String userName = (String) user.get(dto.getUserColumn());
|
|
|
+ String phone = (String) user.get(dto.getPhoneColumn());
|
|
|
+ String remindWords = String.format("【%s平台提示】尊敬的%s用户,店铺%s证件即将到期,请及时处理!",
|
|
|
+ dto.getPlatform(),
|
|
|
+ userName,
|
|
|
+ dto.getCertType());
|
|
|
+ // 使用phone发送remindWords短信
|
|
|
+ // TODO 发送通知
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 禁用店铺
|
|
|
+ * */
|
|
|
+ public void disable() {
|
|
|
+ log.info("禁用店铺任务执行... 当前时间: {}", LocalTime.now());
|
|
|
+ // 从配置表获取需要禁用的表和字段
|
|
|
+ List<DateComparisonConfigDTO> toDisable = jdbcTemplate.query(
|
|
|
+ "SELECT table_name, date_column,invalid_expression,status_column" +
|
|
|
+ " FROM date_comparison_config " +
|
|
|
+ " WHERE is_do_invalid = '1'",(rs, rowNum)-> DateComparisonConfigDTO.builder()
|
|
|
+ .tableName(rs.getString("table_name"))//表名
|
|
|
+ .dateColumn(rs.getString("date_column"))//日期字段
|
|
|
+ .invalidExpression(rs.getString("invalid_expression"))//失效表达式
|
|
|
+ .statusColumn(rs.getString("status_column"))//状态字段
|
|
|
+ .build());
|
|
|
+
|
|
|
+ toDisable.forEach(dto -> {
|
|
|
+ //更新证件失效日期字段小于当前时间的数据
|
|
|
+ String sql = String.format("UPDATE %s " +
|
|
|
+ "SET %s = %s " +
|
|
|
+ "WHERE %s < CURDATE()",
|
|
|
+ dto.getTableName(),
|
|
|
+ dto.getStatusColumn(),
|
|
|
+ dto.getInvalidExpression(),
|
|
|
+ dto.getDateColumn());
|
|
|
+ jdbcTemplate.update(sql);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|