Browse Source

领券增加消息推送,修复首页图

zyj
sj 2 years ago
parent
commit
26f6a38c6b
  1. 2
      yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java
  2. 15
      zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java
  3. 4
      zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java
  4. 4
      zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java
  5. 5
      zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java
  6. 6
      zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java
  7. 3
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java
  8. 32
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java
  9. 5
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java
  10. 23
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueServiceImpl.java
  11. 6
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreSeckillServiceImpl.java
  12. 7
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java
  13. 1
      zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java
  14. 4
      zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java
  15. 3
      zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java
  16. 3
      zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java
  17. 6
      zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/EditableTabs.java
  18. 29
      zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java
  19. 5
      zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java
  20. 9
      zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java
  21. 53
      zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java
  22. 14
      zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java
  23. 1
      zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java
  24. 3
      zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java
  25. 7
      zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java
  26. 3
      zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java
  27. 3
      zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java
  28. 42
      zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java

2
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) {

15
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<IndexVo> 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()))

4
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:";

4
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;
}

5
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;

6
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));

3
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;

32
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<YxStoreBargainMap
@Autowired
private YxStoreBargainUserHelpService storeBargainUserHelpService;
@Autowired
private StoreProductMapper storeProductMapper;
@Autowired
private YxSystemConfigService systemConfigService;
@Autowired
private YxShippingTemplatesService shippingTemplatesService;
/**
* 退回库存销量
* @param num 数量
@ -281,17 +294,34 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl<YxStoreBargainMap
if(storeBargain == null) {
throw new YshopException("砍价已结束");
}
// 获取运费模板名称
String storeFreePostage = systemConfigService.getData("store_free_postage");
String tempName = "";
if(StrUtil.isBlank(storeFreePostage)
|| !NumberUtil.isNumber(storeFreePostage)
|| Integer.parseInt(storeFreePostage) == 0){
tempName = "全国包邮";
}else{
YxShippingTemplates shippingTemplates = shippingTemplatesService.getById(storeBargain.getTempId());
if(ObjectUtil.isNotNull(shippingTemplates)){
tempName = shippingTemplates.getName();
}else {
throw new BadRequestException("请配置运费模板");
}
}
this.addBargainLook(id);
YxStoreBargainQueryVo storeBargainQueryVo = generator.convert(storeBargain,
YxStoreBargainQueryVo.class);
YxStoreBargainQueryVo.class)
.setConfig(storeProductMapper.selectById(storeBargain.getProductId()).getConfig());
return BargainVo
.builder()
.bargain(storeBargainQueryVo)
.userInfo(generator.convert(yxUser, YxUserQueryVo.class))
.bargainSumCount(this.getBargainPayCount(id))
.tempName(tempName)
.build();
}

5
zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java

@ -43,6 +43,7 @@ import co.yixiang.modules.product.service.YxStoreProductService;
import co.yixiang.modules.product.service.dto.FromatDetailDto;
import co.yixiang.modules.product.service.dto.ProductFormatDto;
import co.yixiang.modules.product.service.dto.ProductResultDto;
import co.yixiang.modules.product.service.mapper.StoreProductMapper;
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
import co.yixiang.modules.shop.service.YxSystemConfigService;
import co.yixiang.modules.template.domain.YxShippingTemplates;
@ -103,6 +104,8 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
@Autowired
private YxSystemConfigService systemConfigService;
@Autowired
private StoreProductMapper storeProductMapper;
/**
@ -131,7 +134,7 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
StoreCombinationVo storeCombinationVo = new StoreCombinationVo();
storeCombinationVo.setStoreInfo(storeCombinationQueryVo);
storeCombinationVo.setStoreInfo(storeCombinationQueryVo.setConfig(storeProductMapper.selectById(storeCombination.getProductId()).getConfig()));
//评价
storeCombinationVo.setReply(replyService

23
zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueServiceImpl.java

@ -8,12 +8,16 @@
*/
package co.yixiang.modules.activity.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
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.CouponEnum;
import co.yixiang.event.TemplateBean;
import co.yixiang.event.TemplateEvent;
import co.yixiang.event.TemplateListenEnum;
import co.yixiang.modules.activity.domain.YxStoreCouponIssue;
import co.yixiang.modules.activity.domain.YxStoreCouponIssueUser;
import co.yixiang.modules.activity.service.YxStoreCouponIssueService;
@ -27,6 +31,8 @@ import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -34,11 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
@ -58,7 +60,8 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
private final YxStoreCouponUserService storeCouponUserService;
private final YxStoreCouponIssueUserService storeCouponIssueUserService;
@Autowired
private ApplicationEventPublisher publisher;
/**
* 领取优惠券
* @param id id 优惠券id
@ -83,6 +86,14 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
}
storeCouponUserService.addUserCoupon(uid,couponIssueQueryVo.getCid());
//这里调用微信订阅模板发送消息
TemplateBean templateBean = TemplateBean.builder()
.couponId(couponIssueQueryVo.getCid())
.uid(uid)
.templateType(TemplateListenEnum.TYPE_10.getValue())
.time(DateUtil.formatTime(new Date()))
.build();
publisher.publishEvent(new TemplateEvent(this, templateBean));
storeCouponIssueUserService.addUserIssue(uid,id);

6
zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreSeckillServiceImpl.java

@ -27,12 +27,14 @@ import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper;
import co.yixiang.modules.activity.vo.StoreSeckillVo;
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo;
import co.yixiang.modules.product.domain.YxStoreProduct;
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
import co.yixiang.modules.product.service.YxStoreProductAttrService;
import co.yixiang.modules.product.service.YxStoreProductReplyService;
import co.yixiang.modules.product.service.dto.FromatDetailDto;
import co.yixiang.modules.product.service.dto.ProductFormatDto;
import co.yixiang.modules.product.service.dto.ProductResultDto;
import co.yixiang.modules.product.service.mapper.StoreProductMapper;
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
import co.yixiang.modules.shop.service.YxSystemConfigService;
import co.yixiang.modules.template.domain.YxShippingTemplates;
@ -83,6 +85,8 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
@Autowired
private YxSystemConfigService systemConfigService;
@Autowired
private StoreProductMapper storeProductMapper;
/**
* 产品详情
* @param id 砍价商品id
@ -122,7 +126,7 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
return StoreSeckillVo.builder()
.productAttr((List<YxStoreProductAttrQueryVo>)returnMap.get("productAttr"))
.productValue((Map<String, YxStoreProductAttrValue>)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)

7
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<YxStoreCouponUser> {
" ORDER BY B.id DESC")
List<StoreCouponUserVo> 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<YxStoreCouponUser> selectUserCouponList(@Param("endTime") Date endTime);
//"状态(0:未使用,1:已使用, 2:已过期)"
}

1
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;//运费模板
}

4
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<EditableTabs> config;
@ApiModelProperty(value = "单位名称")
private String unitName;

3
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<String> sliderImageArr;
//七天无理由等配置
private ArrayList<EditableTabs> config;
public List<String> getSliderImageArr() {
if(StrUtil.isNotEmpty(images)){
return Arrays.asList(images.split(","));

3
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<EditableTabs> config;
@ApiModelProperty(value = "轮播图")
private String images;

6
zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/EditableTabs.java

@ -3,8 +3,12 @@ package co.yixiang.modules.evaluation.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class EditableTabs {
public class EditableTabs implements Serializable {
private static final long serialVersionUID = 1L;
// {title: '初始栏',
// name: '0',
// content: '产品展示栏',

29
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<PageResult<YxStoreHotListVo>> getYxStoreHotLists(YxStoreHotListQueryCriteria criteria, Pageable pageable){
// //查出所有用户拥有的券使用时间小于24小时且未使用的券
// Date now=new Date();
// Date endTime = DateUtil.offsetDay(now,1);
// List<YxStoreCouponUser> 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);
}

5
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
}

9
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
}

53
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<String,String> 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<String,String> 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);
}
}
/**
* 支付成功通知

14
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 "";

1
zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java

@ -190,7 +190,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Autowired
private ApplicationEventPublisher publisher;
@Autowired
private StoreAfterSalesService storeAfterSalesService;

3
zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java

@ -9,6 +9,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDomain;
import co.yixiang.modules.category.domain.YxStoreCategory;
import co.yixiang.modules.evaluation.domain.EditableTabs;
import co.yixiang.modules.product.service.dto.Parameter;
import co.yixiang.modules.store.domain.YxStoreBrand;
import com.baomidou.mybatisplus.annotation.TableField;
@ -75,7 +76,7 @@ public class YxStoreProduct extends BaseDomain {
/**价保和无理由退款等配置**/
@TableField(typeHandler = JacksonTypeHandler.class)
private YxStoreProductConfig config;
private ArrayList<EditableTabs> config;
/** 商品简介 */
@ApiModelProperty(value = "商品简介")

7
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<EditableTabs> config;
/** 关键字 */
private String keyword;

3
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<EditableTabs> config;
/** 商品条码(一维码) */
@JsonProperty("bar_code")

3
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<EditableTabs> config;
public String getImage_base() {
return image;

42
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<YxStoreCouponUser> 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";

Loading…
Cancel
Save