diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java b/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java index 3d17648c..f0b13fbd 100644 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java +++ b/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java @@ -4,6 +4,7 @@ import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.system.ApplicationHome; +import org.springframework.scheduling.annotation.EnableScheduling; import java.io.File; @@ -13,6 +14,7 @@ import java.io.File; "co.yixiang", "com.zsw.erp" }) @EnableDubbo +@EnableScheduling public class YudaoServerApplication { public static void main(String[] args) { diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java index 7cb8d6ef..3831b967 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java @@ -36,13 +36,16 @@ import co.yixiang.utils.FileUtil; import co.yixiang.utils.RedisUtils; import co.yixiang.utils.ShopKeyUtils; +import co.yixiang.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.http.HttpStatus; @@ -52,6 +55,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import java.io.File; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -87,14 +91,21 @@ public class BxgIndexController { .orderByDesc(StoreCanvas::getCanvasId).last("limit 1")); return new ResponseEntity<>(canvas, HttpStatus.OK); } - @Cacheable(cacheNames = ShopConstants.ZSW_REDIS_INDEX_KEY) @GetMapping("/index") @ApiOperation(value = "首页数据",notes = "首页数据") public ApiResult index(){ + ArrayList list=new ArrayList<>(); + systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_BANNER).forEach(banner->{ + // 如果没有类型认定为首页图,0也认为是首页图 + if (banner.get("type")==null||banner.get("type").equals(0)){ + list.add(banner); + } + }); IndexVo indexVo = IndexVo.builder() //首页图 - .banner(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_BANNER)) +// .banner(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_BANNER)) + .banner(list) .bastList(storeProductService.getList(1,6, ProductEnum.TYPE_1.getValue())) .evaluationList(evaluationService.getList(1,5)) .benefit(storeProductService.getList(1,100,ProductEnum.TYPE_4.getValue())) diff --git a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java index 6b14b53a..cfaa4263 100644 --- a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java +++ b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java @@ -181,6 +181,10 @@ public interface ShopConstants { String ZSW_WECHAT_PUSH_REMARK = "回乡欢迎您!"; + String SHOP_WECHAT_PUSH_REMARK = "获得1张新的优惠券,快来看看吧"; + + String SHOP_WECHAT_NEAR_COUPON = "您领取的券即将到期,请尽快使用"; + String DEFAULT_UNI_H5_URL = "https://www.lotus-wallet.com"; String ZSW_MINI_SESSION_KET = "zsw:session_key:"; diff --git a/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java b/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java index f08e4fa2..b24d96cf 100644 --- a/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java +++ b/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java @@ -29,5 +29,9 @@ public class TemplateBean { * 提现申请ID */ private Long extractId; + /** + * 获得优惠券id + */ + private Integer couponId; } diff --git a/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java b/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java index 9dc68b5d..fecad185 100644 --- a/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java +++ b/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java @@ -22,7 +22,10 @@ public enum TemplateListenEnum { TYPE_6("6","商家收款通知"), TYPE_7("7","用户下单未支付通知"), TYPE_8("8","用户提现通知"), - TYPE_9("9","退款申请通知"); + TYPE_9("9","退款申请通知"), + TYPE_10("10","用户获得优惠券后发送订阅通知"), + TYPE_11("11","用户优惠券将过期发送推送"); + private String value; private String desc; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java index 4d156e28..797ef087 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java @@ -10,6 +10,7 @@ import cn.hutool.core.bean.copier.CopyOptions; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDomain; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -203,6 +204,11 @@ public class YxStoreBargain extends BaseDomain { private Integer share; + /** 运费模板ID */ + @JsonProperty("temp_id") + @ApiModelProperty(value = "运费模板ID") + private Long tempId; + public void copy(YxStoreBargain source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java index db1d7e6b..07685373 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java @@ -99,6 +99,9 @@ public class YxStoreBargainDto implements Serializable { /** 邮费 */ private BigDecimal postage; + /** 运费模板 */ + private Long tempId; + /** 砍价规则 */ private String rule; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java index b6b4feeb..6505695f 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java @@ -9,12 +9,15 @@ package co.yixiang.modules.activity.service.impl; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.common.service.impl.BaseServiceImpl; import co.yixiang.common.utils.QueryHelpPlus; import co.yixiang.dozer.service.IGenerator; import co.yixiang.enums.OrderInfoEnum; import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.exception.BadRequestException; import co.yixiang.modules.activity.domain.YxStoreBargain; import co.yixiang.modules.activity.domain.YxStoreBargainUser; import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; @@ -30,6 +33,10 @@ import co.yixiang.modules.activity.vo.TopCountVo; import co.yixiang.modules.activity.vo.YxStoreBargainQueryVo; import co.yixiang.modules.order.domain.YxStoreOrder; import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.product.service.mapper.StoreProductMapper; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.service.YxShippingTemplatesService; import co.yixiang.modules.user.domain.YxUser; import co.yixiang.modules.user.vo.YxUserQueryVo; import co.yixiang.utils.FileUtil; @@ -76,8 +83,14 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl)returnMap.get("productAttr")) .productValue((Map)returnMap.get("productValue")) - .storeInfo(generator.convert(storeSeckill, YxStoreSeckillQueryVo.class)) + .storeInfo(generator.convert(storeSeckill, YxStoreSeckillQueryVo.class).setConfig(storeProductMapper.selectById(storeSeckill.getProductId()).getConfig())) .reply(replyService.getReply(storeSeckill.getProductId())) .replyCount(replyService.productReplyCount(storeSeckill.getProductId())) .tempName(tempName) diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java index e1fd93a5..0ca1f6c3 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java @@ -11,6 +11,7 @@ package co.yixiang.modules.activity.service.mapper; import co.yixiang.common.mapper.CoreMapper; import co.yixiang.modules.activity.domain.YxStoreCouponUser; import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import io.swagger.annotations.ApiModelProperty; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; @@ -35,4 +36,10 @@ public interface YxStoreCouponUserMapper extends CoreMapper { " ORDER BY B.id DESC") List selectCouponList(@Param("now") Date now, @Param("price") double price, @Param("uid") Long uid); + + + + @Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime}") + List selectUserCouponList(@Param("endTime") Date endTime); + //"状态(0:未使用,1:已使用, 2:已过期)" } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java index 5c37b2d0..29ab859e 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java @@ -18,4 +18,5 @@ public class BargainVo implements Serializable { private YxStoreBargainQueryVo bargain; private YxUserQueryVo userInfo; private Long bargainSumCount;//砍价支付成功订单数量 + private String tempName;//运费模板 } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java index f1ee7703..cd63e225 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java @@ -1,5 +1,6 @@ package co.yixiang.modules.activity.vo; +import co.yixiang.modules.evaluation.domain.EditableTabs; import co.yixiang.serializer.BigDecimalSerializer; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import io.swagger.annotations.ApiModel; @@ -8,6 +9,7 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; /** @@ -34,6 +36,8 @@ public class YxStoreBargainQueryVo implements Serializable { @ApiModelProperty(value = "砍价活动图片") private String image; + //七天无理由等配置 + private ArrayList config; @ApiModelProperty(value = "单位名称") private String unitName; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java index 17a60aa2..adcd275b 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java @@ -1,6 +1,7 @@ package co.yixiang.modules.activity.vo; import cn.hutool.core.util.StrUtil; +import co.yixiang.modules.evaluation.domain.EditableTabs; import co.yixiang.serializer.BigDecimalSerializer; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -43,6 +44,8 @@ public class YxStoreCombinationQueryVo implements Serializable { private List sliderImageArr; + //七天无理由等配置 + private ArrayList config; public List getSliderImageArr() { if(StrUtil.isNotEmpty(images)){ return Arrays.asList(images.split(",")); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java index 50102cd1..608bd083 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java @@ -1,6 +1,7 @@ package co.yixiang.modules.activity.vo; import cn.hutool.core.util.StrUtil; +import co.yixiang.modules.evaluation.domain.EditableTabs; import co.yixiang.serializer.BigDecimalSerializer; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -37,6 +38,8 @@ public class YxStoreSeckillQueryVo implements Serializable{ @ApiModelProperty(value = "推荐图") private String image; + //七天无理由价保等 + private ArrayList config; @ApiModelProperty(value = "轮播图") private String images; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/EditableTabs.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/EditableTabs.java index b63b85ee..c796db94 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/EditableTabs.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/EditableTabs.java @@ -3,9 +3,13 @@ package co.yixiang.modules.evaluation.domain; import lombok.Data; +import java.io.Serializable; + @Data -public class EditableTabs { -// {title: '初始栏', +public class EditableTabs implements Serializable { + private static final long serialVersionUID = 1L; + + // {title: '初始栏', // name: '0', // content: '产品展示栏', // configuration:'富文本框' diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java index 92974195..1c6518a4 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java @@ -8,9 +8,15 @@ */ package co.yixiang.modules.hotList.rest; +import cn.hutool.core.date.DateUtil; import co.yixiang.domain.PageResult; import co.yixiang.dozer.service.IGenerator; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; import co.yixiang.modules.hotList.domain.YxStoreHotList; import co.yixiang.modules.hotList.service.YxStoreHotListService; import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; @@ -19,6 +25,8 @@ import co.yixiang.modules.hotList.service.vo.YxStoreHotListVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -29,6 +37,9 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays; +import java.util.Date; +import java.util.List; + /** * @author ssj * @date 2022-10-08 @@ -42,7 +53,11 @@ public class YxStoreHotListController { private final YxStoreHotListService yxStoreHotListService; private final IGenerator generator; + @Autowired + private YxStoreCouponUserMapper yxStoreCouponUserMapper; + @Autowired + private ApplicationEventPublisher publisher; @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") @@ -56,6 +71,20 @@ public class YxStoreHotListController { @ApiOperation("查询hotList") // @PreAuthorize("@el.check('admin','yxStoreHotList:list')") public ResponseEntity> getYxStoreHotLists(YxStoreHotListQueryCriteria criteria, Pageable pageable){ +// //查出所有用户拥有的券使用时间小于24小时且未使用的券 +// Date now=new Date(); +// Date endTime = DateUtil.offsetDay(now,1); +// List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); +// storeCouponUsers.forEach(storeCouponUser->{ +// //这里调用微信订阅模板发送消息 +// TemplateBean templateBean = TemplateBean.builder() +// .couponId(storeCouponUser.getCid()) +// .uid(storeCouponUser.getUid()) +// .templateType(TemplateListenEnum.TYPE_11.getValue()) +// .time(DateUtil.formatTime(new Date())) +// .build(); +// publisher.publishEvent(new TemplateEvent(this, templateBean)); +// }); return new ResponseEntity<>(yxStoreHotListService.queryAll(criteria,pageable),HttpStatus.OK); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java index e478e632..0fc648bb 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java @@ -21,8 +21,9 @@ public enum WechatTempateEnum { PAY_SUCCESS("pay_success","支付成功通知"), DELIVERY_SUCCESS("delivery_success","发货成功通知"), REFUND_SUCCESS("refund_success","退款成功通知"), - RECHARGE_SUCCESS("recharge_success","充值成功通知"); - + RECHARGE_SUCCESS("recharge_success","充值成功通知"), + COUPON_GET("coupon_get","获得优惠券通知"), + COUPON_NEAR("coupon_near","优惠券将要过期提醒"); private String value; //模板编号 private String desc; //模板id } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java index dadede1e..babac48a 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java @@ -193,6 +193,15 @@ public class TemplateListener implements SmartApplicationListener { log.error("消息发送失败:{}", e); } break; + case TYPE_10: + weiXinSubscribeService.couponGetNotice(templateBean.getCouponId(), + templateBean.getUid(), templateBean.getTime()); + break; + case TYPE_11: + weiXinSubscribeService.couponNearEndTimeNotice(templateBean.getCouponId(), + templateBean.getUid(), templateBean.getTime()); + break; + default: //todo } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java index 6e80fee8..99f3d165 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java @@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.constant.ShopConstants; import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponMapper; import co.yixiang.modules.mp.domain.YxWechatTemplate; import co.yixiang.modules.user.domain.YxUser; import co.yixiang.modules.user.service.YxUserService; @@ -27,6 +29,9 @@ import java.util.Map; @Service public class WeiXinSubscribeService { + + @Autowired + private YxStoreCouponMapper yxStoreCouponMapper; @Autowired private YxUserService userService; @Autowired @@ -56,6 +61,54 @@ public class WeiXinSubscribeService { } } + /** + * 优惠券将要过期通知 + * @param couponId 获得优惠券的id + * @param uid uid + */ + public void couponNearEndTimeNotice(Integer couponId,Long uid,String time){ + String openid = this.getUserOpenid(uid); + if(StrUtil.isBlank(openid)) { + return; + } + YxStoreCoupon yxStoreCoupon=yxStoreCouponMapper.selectById(couponId); + Map map = new HashMap<>(); + map.put("first","优惠券临近过期提醒:"); + map.put("thing1",yxStoreCoupon.getTitle()); //券名 + map.put("time2",yxStoreCoupon.getUseEndTime()); //获取有效期结束时间 + map.put("thing3", ShopConstants.SHOP_WECHAT_NEAR_COUPON); + String tempId = this.getTempId(WechatTempateEnum.COUPON_NEAR.getValue()); + if(StrUtil.isNotBlank(tempId)) { + this.sendSubscribeMsg( openid, tempId,"pages/Loading/index",map); + } + } + + + /** + * 优惠券获得通知 + * @param couponId 获得优惠券的id + * @param uid uid + */ + public void couponGetNotice(Integer couponId,Long uid,String time){ + String openid = this.getUserOpenid(uid); + if(StrUtil.isBlank(openid)) { + return; + } + + YxStoreCoupon yxStoreCoupon=yxStoreCouponMapper.selectById(couponId); + Map map = new HashMap<>(); + map.put("first","优惠券到账提醒:"); + map.put("thing1",yxStoreCoupon.getTitle()); //券名 + /** 优惠券类型(0:通用券,1:商品券,2:内部券) */ + map.put("thing2",yxStoreCoupon.getType()==0?"通用券":(yxStoreCoupon.getType()==1?"商品券":"内部券")); + map.put("time3",time); //获取时间 +// map.put("keyword3",price); + map.put("thing4", ShopConstants.SHOP_WECHAT_PUSH_REMARK); + String tempId = this.getTempId(WechatTempateEnum.COUPON_GET.getValue()); + if(StrUtil.isNotBlank(tempId)) { + this.sendSubscribeMsg( openid, tempId,"pages/Loading/index",map); + } + } /** * 支付成功通知 diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java index 8f41a6fe..9307676d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java @@ -8,11 +8,15 @@ */ package co.yixiang.modules.mp.service; +import cn.binarywang.wx.miniapp.api.WxMaService; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.constant.ShopConstants; import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponMapper; import co.yixiang.modules.mp.config.BxgConstans; +import co.yixiang.modules.mp.config.WxMaConfiguration; import co.yixiang.modules.mp.config.WxMpConfiguration; import co.yixiang.modules.mp.domain.YxWechatTemplate; import co.yixiang.modules.shop.service.YxSystemConfigService; @@ -23,6 +27,7 @@ import co.yixiang.modules.mp.enums.WechatTempateEnum; import co.yixiang.utils.RedisUtils; import co.yixiang.utils.ShopKeyUtils; +import co.yixiang.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -54,6 +59,10 @@ public class WeixinTemplateService { @Autowired private YxSystemConfigService systemConfigService; + + + + /** * 充值成功通知 * @param time 时间 @@ -242,6 +251,7 @@ public class WeixinTemplateService { map.forEach( (k,v)-> { templateMessage.addData(new WxMpTemplateData(k, v, "#000000"));} ); String msgId = null; WxMpService wxService = WxMpConfiguration.getWxMpService(); +// WxMaService wxService = WxMaConfiguration.getWxMaService(); try { msgId = wxService.getTemplateMsgService().sendTemplateMsg(templateMessage); } catch (WxErrorException e) { @@ -305,7 +315,9 @@ public class WeixinTemplateService { if(yxUser == null) { return ""; } - + if (StringUtils.isNotBlank(yxUser.getOpenId())){ + return yxUser.getOpenId(); + } WechatUserDto wechatUserDto = yxUser.getWxProfile(); if(wechatUserDto == null) { return ""; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java index ff45e36b..1d329091 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java @@ -190,7 +190,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl config; /** 商品简介 */ @ApiModelProperty(value = "商品简介") diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java index 4094f38d..013803a4 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java @@ -1,9 +1,7 @@ package co.yixiang.modules.product.service.dto; -import co.yixiang.modules.product.domain.YxStoreProductConfig; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import co.yixiang.modules.evaluation.domain.EditableTabs; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Getter; @@ -12,7 +10,6 @@ import lombok.Setter; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * 商品对象VO @@ -46,7 +43,7 @@ public class ProductDto { private String storeInfo; /**价保和无理由退款等配置**/ - private YxStoreProductConfig config; + private ArrayList config; /** 关键字 */ private String keyword; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java index e2a9f797..2284c08b 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java @@ -1,5 +1,6 @@ package co.yixiang.modules.product.service.dto; +import co.yixiang.modules.evaluation.domain.EditableTabs; import co.yixiang.modules.product.domain.YxStoreProductConfig; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; @@ -55,7 +56,7 @@ public class StoreProductDto /**价保和无理由退款等配置**/ @JsonProperty("config") - private YxStoreProductConfig config; + private ArrayList config; /** 商品条码(一维码) */ @JsonProperty("bar_code") diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java index ae6bd71a..981e101d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java @@ -3,6 +3,7 @@ package co.yixiang.modules.product.vo; import cn.hutool.core.util.StrUtil; +import co.yixiang.modules.evaluation.domain.EditableTabs; import co.yixiang.modules.product.domain.YxStoreProductAttrValue; import co.yixiang.modules.product.domain.YxStoreProductConfig; import co.yixiang.modules.product.service.dto.Parameter; @@ -47,7 +48,7 @@ public class YxStoreProductQueryVo implements Serializable { private String codeBase; /**价保和无理由退款等配置**/ - private YxStoreProductConfig config; + private ArrayList config; public String getImage_base() { return image; diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java index f9d7f5d6..572caef0 100644 --- a/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java +++ b/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java @@ -1,7 +1,14 @@ package co.yixiang.utils; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; +import co.yixiang.modules.activity.vo.StoreCouponUserVo; import co.yixiang.modules.order.service.YxStoreOrderService; import co.yixiang.modules.order.service.dto.YxStoreOrderDto; import co.yixiang.modules.shop.service.YxSystemConfigService; @@ -17,13 +24,13 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.*; @Component @Slf4j @@ -34,6 +41,35 @@ public class WxbotMsgUtil { @Autowired private YxSystemConfigService systemConfigService; + + @Autowired + private YxStoreCouponUserMapper yxStoreCouponUserMapper; + + @Autowired + private ApplicationEventPublisher publisher; + + //定时器,每天下午17点触发 + @Scheduled(cron = "0 0 15 * * ?") + public void scheduled(){ + log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + //查出所有用户拥有的券使用时间小于24小时且未使用的券 + Date now=new Date(); + Date endTime = DateUtil.offsetDay(now,1); + List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); + storeCouponUsers.forEach(storeCouponUser->{ + //这里调用微信订阅模板发送消息 + TemplateBean templateBean = TemplateBean.builder() + .couponId(storeCouponUser.getCid()) + .uid(storeCouponUser.getUid()) + .templateType(TemplateListenEnum.TYPE_10.getValue()) + .time(DateUtil.formatTime(new Date())) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + }); + } + + + public void inform(long orderId, int type) throws IOException { CloseableHttpClient httpClient = HttpClients.createDefault();//实例化对象 // String webhook_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a08fa2aa-e299-4946-8cba-c99bacac6c33";