|
|
@@ -14,22 +14,22 @@ import com.cyksj.common.util.IoKit;
|
|
|
import com.cyksj.common.util.J11HttpC;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.config.corp.WeChatCorpFactory;
|
|
|
+import com.cyksj.mapper.GroupsRelationExpiryRecordMapper;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.corp.*;
|
|
|
+import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.corp.Attachments;
|
|
|
import com.cyksj.model.request.corp.CorpXmlMessage;
|
|
|
import com.cyksj.model.request.corp.CorpXmlOutMessage;
|
|
|
import com.cyksj.model.response.ExternalContact;
|
|
|
import com.cyksj.model.response.FollowedUser;
|
|
|
-import com.cyksj.model.response.corp.CorpExternalContactInfo;
|
|
|
-import com.cyksj.model.response.corp.CorpUserExternalTagGroupInfo;
|
|
|
-import com.cyksj.model.response.corp.CorpUserExternalTagGroupList;
|
|
|
-import com.cyksj.service.corp.CorpService;
|
|
|
import com.cyksj.model.response.corp.*;
|
|
|
import com.cyksj.model.views.CorpUserSearchView;
|
|
|
+import com.cyksj.model.views.RenewalView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
+import com.cyksj.service.corp.CorpService;
|
|
|
import com.cyksj.service.corp.WxCorpOps;
|
|
|
import com.cyksj.service.corp.msg.CorpEventActionService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
@@ -110,6 +110,12 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
|
|
|
private final BeanSearcher beanSearcher;
|
|
|
|
|
|
+ private final CouponMapper couponMapper;
|
|
|
+
|
|
|
+ private final GroupsRelationExpiryRecordMapper groupsRelationExpiryRecordMapper;
|
|
|
+
|
|
|
+ private final CorpUserRelateMapper corpUserRelateMapper;
|
|
|
+
|
|
|
private static final String DEFAULT_MSG = "您好,欢迎加入银河录像局";
|
|
|
|
|
|
/**
|
|
|
@@ -739,6 +745,27 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
} else {
|
|
|
corpUserMapper.updateById(corpUser);
|
|
|
}
|
|
|
+ followedUsers.forEach(followedUser -> {
|
|
|
+ //备注手机号 客服跟进用户年付续费
|
|
|
+ String description = followedUser.getDescription();
|
|
|
+ if (Validator.isMobile(description)) {
|
|
|
+ THREAD_POOL.execute(() ->{
|
|
|
+ CorpUserRelate corpUserRelate = corpUserRelateMapper.selectOne(Wrappers.lambdaQuery(CorpUserRelate.class)
|
|
|
+ .eq(CorpUserRelate::getCorpUserId, corpUser.getId()).last("limit 1"));
|
|
|
+ if (corpUserRelate != null) {
|
|
|
+ corpUserRelate.setPhone(description);
|
|
|
+ corpUserRelateMapper.updateById(corpUserRelate);
|
|
|
+ } else {
|
|
|
+ corpUserRelate = new CorpUserRelate();
|
|
|
+ corpUserRelate.setCorpUserId(corpUser.getId());
|
|
|
+ corpUserRelate.setPhone(description);
|
|
|
+ corpUserRelateMapper.insert(corpUserRelate);
|
|
|
+ }
|
|
|
+ //客服续费跟进
|
|
|
+ corpRenewFollowUser(description);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
return corpUser;
|
|
|
}
|
|
|
|
|
|
@@ -850,4 +877,59 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客服备注手机号 跟进用户年付车票续费
|
|
|
+ */
|
|
|
+ public void corpRenewFollowUser(String phone) {
|
|
|
+ //是否是手机用户 或者 邮箱用户
|
|
|
+ Set<Long> relationUserIds = userMapper.getRelationUserIdsByPhone(phone);
|
|
|
+ if (CollUtil.isEmpty(relationUserIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<RenewalView> list = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
|
|
|
+ .field(RenewalView::getUserId, 0).op(Operator.NotEqual)
|
|
|
+ .field(RenewalView::getUserId, relationUserIds).op(Operator.InList)
|
|
|
+ .field(RenewalView::getYhsId, 0)
|
|
|
+ //年付
|
|
|
+ .field(RenewalView::getMonths, 12)
|
|
|
+ .field(RenewalView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
|
|
|
+ .onlySelect(RenewalView::getUserId, RenewalView::getExpiryTime, RenewalView::getSkuId)
|
|
|
+ .build());
|
|
|
+ Set<Long> couponIds = new HashSet<>();
|
|
|
+
|
|
|
+ List<CouponUser> sendCouponUser = new ArrayList<>();
|
|
|
+
|
|
|
+ list.forEach(renew->{
|
|
|
+ Date expiryTime = renew.getExpiryTime();
|
|
|
+ Long skuId = renew.getSkuId();
|
|
|
+ Long userId = renew.getUserId();
|
|
|
+
|
|
|
+ //一个月车票将过期
|
|
|
+ if (expiryTime.before(DateUtil.offsetMonth(DateTime.now(), 1))) {
|
|
|
+ //续费分类下
|
|
|
+ //寻找对应续费的优惠券 发送
|
|
|
+ Coupon coupon = couponMapper.getRenewCouponBySkuId(skuId, couponIds);
|
|
|
+ if (coupon != null) {
|
|
|
+ CouponUser couponUser = new CouponUser();
|
|
|
+ couponUser.setUserId(userId);
|
|
|
+ couponUser.setCouponId(coupon.getId());
|
|
|
+ sendCouponUser.add(couponUser);
|
|
|
+
|
|
|
+ couponIds.add(coupon.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //有几张过期的年付车票 发对应几张续费优惠券
|
|
|
+ if (CollUtil.isNotEmpty(sendCouponUser)) {
|
|
|
+ sendCouponUser.forEach(send -> {
|
|
|
+ couponCommonService.sendCouponToUser(send.getUserId(), send.getCouponId(), null, null, null, CouponUser.Channel.wxCorp);
|
|
|
+ //跟进用户续费
|
|
|
+ groupsRelationExpiryRecordMapper.update(null, Wrappers.lambdaUpdate(GroupsRelationExpiryRecord.class)
|
|
|
+ .set(GroupsRelationExpiryRecord::getIsFollow, true)
|
|
|
+ .eq(GroupsRelationExpiryRecord::getUserId, send.getUserId())
|
|
|
+ .eq(GroupsRelationExpiryRecord::getIsFollow, false));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|