|
@@ -0,0 +1,714 @@
|
|
|
+package com.caimei365.tools.task;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.caimei365.tools.mapper.MessageCenterMapper;
|
|
|
+import com.caimei365.tools.mapper.OrderClubMapper;
|
|
|
+import com.caimei365.tools.model.po.CmCouponPo;
|
|
|
+import com.caimei365.tools.model.po.CmUserPo;
|
|
|
+import com.caimei365.tools.model.po.MessageCenterPo;
|
|
|
+import com.caimei365.tools.model.po.OrderVo;
|
|
|
+import com.caimei365.tools.service.WeChatService;
|
|
|
+import com.caimei365.tools.utils.SmsUtil;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.SneakyThrows;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.juli.logging.Log;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import redis.clients.jedis.Jedis;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+import java.util.concurrent.ScheduledExecutorService;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Description
|
|
|
+ *
|
|
|
+ * @author : Charles
|
|
|
+ * @date : 2022/7/29
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Configuration
|
|
|
+@EnableScheduling
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class ShopMessTask {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MessageCenterMapper messageCenterMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrderClubMapper orderClubMapper;
|
|
|
+ @Resource
|
|
|
+ private WeChatService weChatService;
|
|
|
+
|
|
|
+// @SneakyThrows
|
|
|
+// public static void main(String[] args) {
|
|
|
+// Calendar calendar = Calendar.getInstance();
|
|
|
+//
|
|
|
+// Date d = new Date();
|
|
|
+// Date time=new Date();
|
|
|
+// //1.日期格式
|
|
|
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
+// String receiptDate="2022-08-02 19:07:46";
|
|
|
+//// if(!receiptDate.contains(":")){
|
|
|
+//// receiptDate+=" 00:00:01";
|
|
|
+//// }
|
|
|
+//
|
|
|
+// Date s= sdf.parse(receiptDate);
|
|
|
+//
|
|
|
+// calendar.setTime(time);
|
|
|
+// calendar.add(Calendar.HOUR, -1);
|
|
|
+// String hTime= sdf.format(calendar.getTime());
|
|
|
+// Integer i= hTime.compareTo(sdf.format(s));
|
|
|
+// System.out.println(i);
|
|
|
+// System.out.println(hTime);
|
|
|
+// System.out.println(s);
|
|
|
+////if(i==0){
|
|
|
+////
|
|
|
+////}
|
|
|
+//// time = sdf.parse(receiptDate);
|
|
|
+////
|
|
|
+//// calendar.setTime(time);
|
|
|
+////// calendar.add(Calendar.YEAR, 1);
|
|
|
+//// String dateStrings = sdf.format(calendar.getTime());
|
|
|
+//// //2.到期时间
|
|
|
+////
|
|
|
+//// Date da1 = da1 = sdf.parse(dateStrings);
|
|
|
+//// //到期时间-当前时间=还剩多少天
|
|
|
+//// Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+//// System.out.println(da1);
|
|
|
+//// System.out.println(d);
|
|
|
+//// System.out.println(s);
|
|
|
+// }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 15 * * ?")
|
|
|
+// @Scheduled(cron = "0 0/15 * * * ?")
|
|
|
+ public void Timesjf() {
|
|
|
+ log.info("上架费过期推送开始");
|
|
|
+ //1.获取下午3点的时间
|
|
|
+ List<Integer> shopIDs = messageCenterMapper.receiptShopID();
|
|
|
+ shopIDs.forEach(shopID -> {
|
|
|
+ if (shopID != null) {
|
|
|
+ String receiptDate = messageCenterMapper.receiptDate(shopID);
|
|
|
+ Double receiptAmount = messageCenterMapper.receiptAmount(shopID);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+
|
|
|
+ String firsts = "";
|
|
|
+
|
|
|
+ Date d = new Date();
|
|
|
+ Date time = new Date();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ if (!receiptDate.contains(":")) {
|
|
|
+ receiptDate += " 00:00:01";
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ time = sdf.parse(receiptDate);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ calendar.setTime(time);
|
|
|
+ calendar.add(Calendar.YEAR, 1);
|
|
|
+ String dateStrings = sdf.format(calendar.getTime());
|
|
|
+ //2.到期时间
|
|
|
+ Date da1 = new Date();
|
|
|
+ try {
|
|
|
+ da1 = sdf.parse(dateStrings);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //到期时间-当前时间=还剩多少天
|
|
|
+ Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+ //3.输出间隔天数 getTime获取的是毫秒
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-上架费服务通知
|
|
|
+ if (s <= 0) {
|
|
|
+ messageCenter.setShopId(shopID);
|
|
|
+ messageCenter.setClubId(null);
|
|
|
+ messageCenter.setUserType(2);
|
|
|
+ messageCenter.setMessageType(3);
|
|
|
+ messageCenter.setShopTieredType(1);
|
|
|
+ messageCenter.setContent("已过期");
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ } else if (s == 1) {
|
|
|
+ messageCenter.setShopId(shopID);
|
|
|
+ messageCenter.setClubId(null);
|
|
|
+ messageCenter.setUserType(2);
|
|
|
+ messageCenter.setMessageType(3);
|
|
|
+ messageCenter.setShopTieredType(1);
|
|
|
+ messageCenter.setContent("今日后到期");
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String mobile = messageCenterMapper.contractMobiles(shopID);
|
|
|
+ String content = "您的供应商账号上架费将于今日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365";
|
|
|
+ String result = SmsUtil.sendSms(3, mobile, content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(mobile + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(mobile + "发送失败");
|
|
|
+ }
|
|
|
+ firsts = "尊敬的采美供应商用户,您的账号维护费用今天后即将到期!";
|
|
|
+ } else if (s == 7) {
|
|
|
+ messageCenter.setShopId(shopID);
|
|
|
+ messageCenter.setClubId(null);
|
|
|
+ messageCenter.setUserType(2);
|
|
|
+ messageCenter.setMessageType(3);
|
|
|
+ messageCenter.setShopTieredType(1);
|
|
|
+ messageCenter.setContent("7日后到期");
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String mobile = messageCenterMapper.contractMobiles(shopID);
|
|
|
+ String content = "您的供应商账号上架费将于7日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365";
|
|
|
+ String result = SmsUtil.sendSms(3, mobile, content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(mobile + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(mobile + "发送失败");
|
|
|
+ }
|
|
|
+ firsts = "尊敬的采美供应商用户,您的账号维护费用7天后即将到期!";
|
|
|
+ } else if (s == 30) {
|
|
|
+ messageCenter.setShopId(shopID);
|
|
|
+ messageCenter.setClubId(null);
|
|
|
+ messageCenter.setUserType(2);
|
|
|
+ messageCenter.setMessageType(3);
|
|
|
+ messageCenter.setShopTieredType(1);
|
|
|
+ messageCenter.setContent("30日后到期");
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String mobile = messageCenterMapper.contractMobiles(shopID);
|
|
|
+ String content = "您的供应商账号上架费将于30日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365";
|
|
|
+ String result = SmsUtil.sendSms(3, mobile, content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(mobile + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(mobile + "发送失败");
|
|
|
+ }
|
|
|
+ firsts = "尊敬的采美供应商用户,您的账号维护费用30天后即将到期!";
|
|
|
+ }
|
|
|
+ try {
|
|
|
+
|
|
|
+ Integer userId = messageCenterMapper.userIds(shopID);
|
|
|
+ String accessToken = weChatService.getAccessToken();
|
|
|
+ String openid = messageCenterMapper.getOpenidListByPermission(messageCenterMapper.FromUnionId(userId));
|
|
|
+ String date = s.toString();
|
|
|
+ // 跳转到【小程序付款-选择支付方式页面】
|
|
|
+ String pagePath = "https://www.caimei365.com/";
|
|
|
+ // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
|
|
|
+ weChatService.messtemes(accessToken, openid, firsts, receiptDate, sdf.format(da1), receiptAmount, pagePath);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("上架费过期推送结束");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 10 15 * ?")
|
|
|
+//@Scheduled(cron = "0 0/10 * * * ?")
|
|
|
+ public void gwc() {
|
|
|
+ log.info("------------开始推送购物车相关短信------------------------>");
|
|
|
+ List<Integer> userId = orderClubMapper.userIds();
|
|
|
+ userId.forEach(userIds -> {
|
|
|
+ OrderVo orderVo = orderClubMapper.getcartNess(userIds);
|
|
|
+ if (orderVo.getProName() != null) {
|
|
|
+ String name = orderVo.getProName();
|
|
|
+
|
|
|
+ if (name.length() > 10) {
|
|
|
+ name = StringUtils.strip(name.substring(0, 11));
|
|
|
+ name += "...";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orderVo.getMobile() != null) {
|
|
|
+ String content = "有件商品" + name + "在您购物车内已经待了很久啦,快戳采美网站链接www.caimei365.com或微信搜索“采美采购商城”小程序登录采美平台去购物车看看吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, orderVo.getMobile(), content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(orderVo.getMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(orderVo.getMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("号码为空" + "发送失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ log.info("------------推送购物车相关短信-结束----------------------->");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0/60 * * * ?")
|
|
|
+ public void ConSumertime() {
|
|
|
+ log.info("》》》》》》》》》》》开始检测优惠券是否生效");
|
|
|
+ List<CmCouponPo> coupons = messageCenterMapper.couponTime();
|
|
|
+ coupons.forEach(cmCoupon -> {
|
|
|
+ List<Integer> clubIds = messageCenterMapper.ClubIds();
|
|
|
+ new Thread(() -> clubIds.forEach(clubId -> {
|
|
|
+ Jedis jedis = null;
|
|
|
+ String constraint = "";
|
|
|
+ if (clubId != null) {
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ Date date = new Date();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ CmUserPo user = messageCenterMapper.clubList(clubId);
|
|
|
+ int coumt = 0;//计数五种消息只推送一条
|
|
|
+ String catego = "";
|
|
|
+ Integer ts = (date.compareTo(cmCoupon.getStartDate()));
|
|
|
+ if (ts >= 0) {
|
|
|
+ if ("90".equals(user.getClubStatus()) && 0 == cmCoupon.getCouponType()) {
|
|
|
+ CmCouponPo coupon = messageCenterMapper.CouponList(0);//查询优惠券信息
|
|
|
+ if (coupon != null) {
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(clubId);
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setContent(null);
|
|
|
+ messageCenter.setTime(curDateStr);
|
|
|
+ messageCenter.setCouponType(0);
|
|
|
+ messageCenter.setCouponMessageType(1);
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String content = "采美平台送您" + coupon.getCouponAmount() + "元优惠券,众多大牌正品等着您,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取下单吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ coumt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("90".equals(user.getClubStatus()) && coumt == 0 && 1 == cmCoupon.getCouponType()) {
|
|
|
+ CmCouponPo coupon = messageCenterMapper.CouponList(1);//查询优惠券信息
|
|
|
+ if (coupon != null) {
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(clubId);
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ if (coupon != null && "1".equals(coupon.getCategoryType())) {
|
|
|
+ catego = "产品";
|
|
|
+ }
|
|
|
+ if (coupon != null && "2".equals(coupon.getCategoryType())) {
|
|
|
+ catego = "仪器";
|
|
|
+ }
|
|
|
+ messageCenter.setContent(catego);
|
|
|
+ messageCenter.setTime(curDateStr);
|
|
|
+ messageCenter.setCouponType(1);
|
|
|
+ messageCenter.setCouponMessageType(1);
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String content = "采美平台" + catego + "类商品大优惠,采美平台送您" + coupon.getCouponAmount() + "元优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ coumt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (coumt == 0 && 2 == cmCoupon.getCouponType()) {
|
|
|
+ CmCouponPo coupon = messageCenterMapper.CouponList(2);//查询优惠券信息
|
|
|
+ if (coupon != null) {
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
+ if (coupon != null && coupon.getUserId() != null) {
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(clubId);
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setContent(null);
|
|
|
+ messageCenter.setTime(curDateStr);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setCouponMessageType(1);
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+
|
|
|
+ String content = "为了答谢您对采美平台的支持,采美平台送您" + coupon.getCouponAmount() + "元优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ coumt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("90".equals(user.getClubStatus()) && coumt == 0 && 3 == cmCoupon.getCouponType()) {
|
|
|
+ CmCouponPo coupon = messageCenterMapper.CouponList(3);//查询优惠券信息
|
|
|
+ if (coupon != null) {
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(clubId);
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setContent(user.getName());
|
|
|
+ messageCenter.setTime(curDateStr);
|
|
|
+ messageCenter.setCouponType(3);
|
|
|
+ messageCenter.setCouponMessageType(1);
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+
|
|
|
+ String content = "采美平台为了回馈客户,赠送您" + coupon.getCouponAmount() + "元的店铺专属优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ coumt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (coumt == 0 && 4 == cmCoupon.getCouponType()) {
|
|
|
+ CmCouponPo coupon = messageCenterMapper.CouponList(4);//查询优惠券信息
|
|
|
+ if (coupon != null) {
|
|
|
+ String startDate = sdf.format(coupon.getStartDate());
|
|
|
+ int num = startDate.compareTo(user.getRegisterTime());
|
|
|
+ if (num > 0) {
|
|
|
+ String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
|
|
|
+ if (coupon != null && coupon.getUserId() != null) {
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(clubId);
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setContent(null);
|
|
|
+ messageCenter.setTime(curDateStr);
|
|
|
+ messageCenter.setCouponType(4);
|
|
|
+ messageCenter.setCouponMessageType(1);
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+
|
|
|
+ String content = "恭喜成功注册采美平台。采美平台赠送您" + coupon.getCouponAmount() + "元新用户优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ coumt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天12点推送
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 12 * * ?")
|
|
|
+// @Scheduled(cron = "0 0/10 * * * ?")
|
|
|
+ private void Timerw() {
|
|
|
+ log.info(">>>>>7天后下架");
|
|
|
+ List<Integer> userIds = messageCenterMapper.CouponUserId();
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ List<CmCouponPo> coupons = messageCenterMapper.CouponLists(userId);
|
|
|
+ coupons.forEach(coupon -> {
|
|
|
+ if (userId != null) {
|
|
|
+ CmUserPo user = messageCenterMapper.clubLists(userId);
|
|
|
+ String contractMobile = messageCenterMapper.contractMobile(userId);
|
|
|
+ Date date = new Date();
|
|
|
+ Date d = coupon.getStartDate();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String endTime = sdf.format(coupon.getEndDate());
|
|
|
+ //2.某天的日期
|
|
|
+ Date da1 = null;
|
|
|
+ try {
|
|
|
+ da1 = sdf.parse(endTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+ Long t = (date.getTime() - da1.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ if (s > 15) {
|
|
|
+ if (t == 7) {
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(Integer.parseInt(user.getClubID()));
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setCouponMessageType(3);
|
|
|
+ messageCenter.setContent("7天");
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String content = "您有" + coupon.getCouponAmount() + "元优惠券将于7日后过期,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, contractMobile, content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天10点判断
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 10 * * ?")
|
|
|
+// @Scheduled(cron = "0 0/2 * * * ?")
|
|
|
+ private void Timeto() {
|
|
|
+ log.info(">>>>>1天后下架");
|
|
|
+ List<Integer> userIds = messageCenterMapper.CouponUserId();
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ String contractMobile = messageCenterMapper.contractMobile(userId);
|
|
|
+ List<CmCouponPo> coupons = messageCenterMapper.CouponLists(userId);
|
|
|
+ coupons.forEach(coupon -> {
|
|
|
+ if (userId != null) {
|
|
|
+ CmUserPo user = messageCenterMapper.clubLists(userId);
|
|
|
+ Date d = new Date();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String endTime = sdf.format(coupon.getEndDate());
|
|
|
+ //2.某天的日期
|
|
|
+ Date da1 = null;
|
|
|
+ try {
|
|
|
+ da1 = sdf.parse(endTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ if (s == 1) {
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(Integer.parseInt(user.getClubID()));
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setCouponMessageType(3);
|
|
|
+ messageCenter.setContent("今日");
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String content = "您有" + coupon.getCouponAmount() + "元优惠券今日过期,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, contractMobile, content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+// @Scheduled(cron = "0 0/2 * * * ?")
|
|
|
+ @Scheduled(cron = "0 0 15 * * ?")
|
|
|
+ private void Timeth() {
|
|
|
+ log.info(">>>>>三天后下架");
|
|
|
+ List<Integer> userIds = messageCenterMapper.CouponUserId();
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ String contractMobile = messageCenterMapper.contractMobile(userId);
|
|
|
+ List<CmCouponPo> coupons = messageCenterMapper.CouponLists(userId);
|
|
|
+ coupons.forEach(coupon -> {
|
|
|
+ if (userId != null) {
|
|
|
+ CmUserPo user = messageCenterMapper.clubLists(userId);
|
|
|
+ Date date = new Date();
|
|
|
+ Date d = coupon.getStartDate();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String endTime = sdf.format(coupon.getEndDate());
|
|
|
+ //2.某天的日期
|
|
|
+ Date da1 = null;
|
|
|
+ try {
|
|
|
+ da1 = sdf.parse(endTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+ Long t = (date.getTime() - da1.getTime()) / 24 / 60 / 60 / 1000;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ if (t == 3) {
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(Integer.parseInt(user.getClubID()));
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setCouponMessageType(3);
|
|
|
+ messageCenter.setContent("3天");
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ String content = "您有" + coupon.getCouponAmount() + "元优惠券3日后过期,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
|
|
|
+ String result = SmsUtil.sendSms(3, contractMobile, content);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ log.info("发送结果:" + result + ",短信内容:" + content);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ log.info(user.getBindMobile() + "发送成功");
|
|
|
+ } else {
|
|
|
+ log.error(user.getBindMobile() + "发送失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0/60 * * * ?")
|
|
|
+ private void config() throws ParseException {
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat dateF = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
+ SimpleDateFormat dateR = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ //订单超时未确认的时间
|
|
|
+ Integer hour= orderClubMapper.cmorderconfig("confirmOverTime");
|
|
|
+ //待收款 待发货超时
|
|
|
+ Integer hours=orderClubMapper.cmorderconfig("receivableOverTime");
|
|
|
+ //待收款 待发货超时
|
|
|
+ Integer hourmex=orderClubMapper.cmorderconfig("autoReceiptGoodsTime");
|
|
|
+ //前日期
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ String day= dateF.format(new Date());
|
|
|
+ Date receipttime = dateF.parse(day);
|
|
|
+ calendar.setTime(receipttime);
|
|
|
+ calendar.add(Calendar.HOUR, -hour);
|
|
|
+ String hTime=dateF.format(calendar.getTime());
|
|
|
+ List<OrderVo>orderStatuslist= orderClubMapper.oredrStatus();
|
|
|
+ log.info(">>>>订单因超时未付款站内推送");
|
|
|
+ orderStatuslist.forEach(order -> {
|
|
|
+ Date i=new Date();
|
|
|
+ try {
|
|
|
+ i=dateF.parse(order.getOrderTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Integer num=hTime.compareTo(dateF.format(i));
|
|
|
+ if(num==0){
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-交易物流-待确认超时
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(order.getClubId());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(1);
|
|
|
+ messageCenter.setOrderId(order.getOrderId());
|
|
|
+ messageCenter.setOrderMessageType(4);
|
|
|
+ messageCenter.setContent("您的订单因超时未付款,系统已自动取消订单!");
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //待收款 待发货超时
|
|
|
+ Calendar calendars = Calendar.getInstance();
|
|
|
+ String days= dateF.format(new Date());
|
|
|
+ Date receiptime = dateF.parse(days);
|
|
|
+ calendars.setTime(receiptime);
|
|
|
+ calendars.add(Calendar.HOUR, -hours);
|
|
|
+ String hTimes=dateF.format(calendars.getTime());
|
|
|
+ List<OrderVo> cmorderConfigStatus =orderClubMapper.cmorderConfigStatus();
|
|
|
+ log.info(">>>>待收款 待发货超时站内推送!");
|
|
|
+ cmorderConfigStatus.forEach(order -> {
|
|
|
+ Date i=new Date();
|
|
|
+ try {
|
|
|
+ i=dateF.parse(order.getOrderTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Integer num=hTimes.compareTo(dateF.format(i));
|
|
|
+ if(num==0){
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(order.getClubId());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(1);
|
|
|
+ messageCenter.setOrderId(order.getOrderId());
|
|
|
+ messageCenter.setOrderMessageType(6);
|
|
|
+ messageCenter.setContent(null);
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Calendar calendarmax = Calendar.getInstance();
|
|
|
+ String daymax= dateR.format(new Date());
|
|
|
+ Date receiptimemax = dateR.parse(daymax);
|
|
|
+ calendarmax.setTime(receiptimemax);
|
|
|
+ calendarmax.add(Calendar.DATE, -hourmex);
|
|
|
+ String hTimemax=dateR.format(calendarmax.getTime());
|
|
|
+ List<OrderVo> cmorderStatus =orderClubMapper.cmorderConfigStatus();
|
|
|
+ log.info(">>>>订单因超时已被系统自动确认收货站内推送!");
|
|
|
+ cmorderStatus.forEach(order -> {
|
|
|
+ Date i=new Date();
|
|
|
+ try {
|
|
|
+ i=dateR.parse(order.getOrderTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Integer num=hTimemax.compareTo(dateR.format(i));
|
|
|
+ if(num==0){
|
|
|
+ MessageCenterPo messageCenter = new MessageCenterPo();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ messageCenter.setShopId(null);
|
|
|
+ messageCenter.setClubId(order.getClubId());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(1);
|
|
|
+ messageCenter.setOrderId(order.getOrderId());
|
|
|
+ messageCenter.setOrderMessageType(6);
|
|
|
+ messageCenter.setContent("您的订单因超时已被系统自动确认收货!");
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+}
|