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