CouponFontServiceImpl.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. package com.cyksj.service.coupon.impl;
  2. import cn.hutool.core.date.DateTime;
  3. import cn.hutool.core.date.DateUtil;
  4. import cn.hutool.core.lang.Assert;
  5. import cn.hutool.core.util.StrUtil;
  6. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import com.cyksj.common.constant.Constant;
  9. import com.cyksj.common.exception.BusinessRuntimeException;
  10. import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
  11. import com.cyksj.common.util.Jsons;
  12. import com.cyksj.enums.GatewayApiCode;
  13. import com.cyksj.mapper.OrderDonMapper;
  14. import com.cyksj.mapper.UserMapper;
  15. import com.cyksj.mapper.channel.ChannelPopularizeMapper;
  16. import com.cyksj.mapper.manage.coupon.*;
  17. import com.cyksj.model.entity.*;
  18. import com.cyksj.model.request.ChannelPopularizeCouponReq;
  19. import com.cyksj.model.request.CouponCollectReq;
  20. import com.cyksj.model.views.*;
  21. import com.cyksj.service.coupon.CouponFontService;
  22. import com.ejlchina.searcher.BeanSearcher;
  23. import com.ejlchina.searcher.param.Operator;
  24. import com.ejlchina.searcher.util.MapUtils;
  25. import lombok.RequiredArgsConstructor;
  26. import lombok.extern.slf4j.Slf4j;
  27. import org.springframework.dao.DuplicateKeyException;
  28. import org.springframework.stereotype.Service;
  29. import org.springframework.transaction.annotation.Transactional;
  30. import java.math.BigDecimal;
  31. import java.util.*;
  32. /*
  33. *项目名: netflix
  34. *文件名: CouponFontServiceImpl
  35. *创建者: JavaZou
  36. *创建时间:2022/11/18 13:34
  37. */
  38. @Service
  39. @RequiredArgsConstructor
  40. @Slf4j
  41. public class CouponFontServiceImpl implements CouponFontService {
  42. private final CouponMapper couponMapper;
  43. private final CouponActiveMapper couponActiveMapper;
  44. private final CouponUserMapper couponUserMapper;
  45. private final BeanSearcher beanSearcher;
  46. private final CouponSkuMapper couponSkuMapper;
  47. private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
  48. private final CouponRecommendMapper recommendMapper;
  49. private final ChannelPopularizeMapper channelPopularizeMapper;
  50. private final UserMapper userMapper;
  51. private final OrderDonMapper orderDonMapper;
  52. @Override
  53. @Transactional(rollbackFor = Throwable.class)
  54. public void collectCoupon(CouponCollectReq couponCollectReq, Long userId) {
  55. if (couponCollectReq == null || couponCollectReq.getCouponId() == null || couponCollectReq.getCouponActiveId() == null) {
  56. throw BusinessRuntimeException.getInstance("缺少优惠券领取参数");
  57. }
  58. // Inventory is protected by subRemainNum's compare-and-update predicate.
  59. CouponActive couponActive = couponActiveMapper.selectById(couponCollectReq.getCouponActiveId());
  60. if (couponActive == null || !java.util.Objects.equals(couponActive.getCouponId(), couponCollectReq.getCouponId())
  61. || !Boolean.TRUE.equals(couponActive.getStatus()) || !Boolean.TRUE.equals(couponActive.getExpiryStatus())) {
  62. throw BusinessRuntimeException.getInstance("该发放优惠券不存在");
  63. }
  64. collectCommonCheck(couponActive.getCouponId(), userId);
  65. if (couponActive.getRemainNum() == null || couponActive.getRemainNum() <= 0) {
  66. throw BusinessRuntimeException.getInstance("该优惠券已领取完");
  67. }
  68. receiveCouponUser(couponCollectReq.getCouponId(), userId, CouponUser.Channel.center);
  69. if (couponActive != null) {
  70. //发放优惠券记录剩余数量
  71. Integer remainNum = couponActive.getRemainNum();
  72. Integer update = couponActiveMapper.subRemainNum(couponActive.getId(), remainNum);
  73. if (update != 1) {
  74. throw BusinessRuntimeException.getInstance("系统繁忙,请稍后再试..");
  75. }
  76. }
  77. }
  78. @Override
  79. @Transactional(rollbackFor = Throwable.class)
  80. public void collectRecommendCoupon(CouponCollectReq couponCollectReq, Long userId) {
  81. collectCommonCheck(couponCollectReq.getCouponId(), userId);
  82. CouponRecommend couponRecommend = recommendMapper.selectOne(Wrappers.lambdaQuery(CouponRecommend.class).eq(CouponRecommend::getCouponId, couponCollectReq.getCouponId()).last("limit 1"));
  83. if (couponRecommend == null || !couponRecommend.getDeleted() || !couponRecommend.getStatus()) {
  84. return;
  85. }
  86. Date upTime = couponRecommend.getUpTime();
  87. Date downTime = couponRecommend.getDownTime();
  88. if (upTime != null && upTime.after(DateTime.now())) {
  89. return;
  90. }
  91. if (downTime != null && downTime.before(DateTime.now())) {
  92. return;
  93. }
  94. receiveCouponUser(couponCollectReq.getCouponId(), userId, CouponUser.Channel.recommend);
  95. }
  96. @Override
  97. @Transactional(rollbackFor = Throwable.class)
  98. public void collectWholeRecommendCoupon(Long userId) {
  99. CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
  100. Boolean isNewUser = true;
  101. if (couponNewUserView != null) {
  102. isNewUser = false;
  103. }
  104. //查询所有可领取的推荐优惠券
  105. List<CouponAvailableRecommendView> couponAvailableRecommendViews = recommendMapper.getRecommendCouponList(userId, isNewUser);
  106. couponAvailableRecommendViews.stream().forEach(data -> {
  107. //领取优惠券
  108. CouponUser couponUser = new CouponUser();
  109. couponUser.setUserId(userId);
  110. couponUser.setCouponId(data.getCouponId());
  111. //推荐渠道
  112. couponUser.setChannel(CouponUser.Channel.recommend);
  113. couponUser.setStatus(CouponUser.Status.unused);
  114. couponUser.setRecommendId(data.getRecommendId());
  115. //优惠券有效时间
  116. this.updateCouponUserValidTime(data.getCouponId(), couponUser);
  117. try {
  118. couponUserMapper.insert(couponUser);
  119. } catch (DuplicateKeyException e) {
  120. //插入失败继续插入 不影响
  121. log.info("用户:{}一键领取推荐优惠券{}插入数据错误", userId, data.getCouponId());
  122. }
  123. });
  124. }
  125. @Override
  126. public Page<CouponUserView> getAvailableCouponList(Long skuId, Long couponId, Long userId, Boolean isRenew, Long start, Long limit) {
  127. DateTime now = DateTime.now();
  128. Long goodsId = null;
  129. //实物还是虚物
  130. GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getSkuId, skuId).op(Operator.Equal).build());
  131. if (goodsDonSkuView == null) {
  132. return new Page<>();
  133. }
  134. BigDecimal skuMoney = goodsDonSkuView.getMoney();
  135. if (goodsDonSkuView.getType() == 2) {
  136. goodsId = goodsDonSkuView.getGoodsId();
  137. }
  138. Page<CouponUserView> availableCouponList = couponUserMapper.getAvailableCouponList(skuId, skuMoney, couponId, goodsId, userId, isRenew, new Page<>(start, limit));
  139. Optional.ofNullable(availableCouponList).ifPresent(page->{
  140. page.getRecords().stream().forEach(data->{
  141. String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
  142. data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
  143. List<CouponSkuView> couponSkus = couponSkuMapper.getGoodsSkuByCouponId(data.getCouponId());
  144. try {
  145. data.setGoodsSkuIds(Jsons.toJson(couponSkus));
  146. } catch (Exception e) {
  147. }
  148. if (!data.getIsAvailable()) {
  149. data.setReason(String.format("仅限%s", data.getGoodsSkuStr()));
  150. if (data.getUseScope() == Coupon.UseScope.renew) {
  151. data.setReason(String.format("%s续费时可使用", data.getReason()));
  152. } else if (data.getUseScope() == Coupon.UseScope.orders) {
  153. data.setReason(String.format("%s下单时可使用", data.getReason()));
  154. }
  155. }
  156. if (goodsDonSkuView.getType() == 2 && data.getType() == Coupon.Type.reduce) {
  157. if (data.getIsAvailable() && skuMoney.compareTo(data.getReduceCondition()) < 0) {
  158. data.setIsAvailable(false);
  159. data.setReason(String.format("满%s可用", data.getReduceCondition().divide(BigDecimal.valueOf(100))));
  160. }
  161. }
  162. if (isRenew != null && isRenew && data.getUseScope() == Coupon.UseScope.orders) {
  163. data.setReason("仅下单可使用");
  164. }
  165. //为了重新校验
  166. data.setCouponUserStatus(CouponUser.Status.unused);
  167. this.setCouponUserStatus(data, now);
  168. });
  169. });
  170. if (goodsDonSkuView.getType() == 2) {
  171. availableCouponList.getRecords().sort(Comparator.comparing(CouponUserView::getIsAvailable).reversed());
  172. }
  173. return availableCouponList;
  174. }
  175. /**
  176. * 设置用户优惠券状态
  177. */
  178. @Override
  179. public void setCouponUserStatus(CouponUserView data, DateTime now) {
  180. Boolean isFlag = false;
  181. if (data.getCouponUserStatus() == CouponUser.Status.unused) {
  182. if (data.getExpiryStatus() != null && !data.getExpiryStatus()) {
  183. data.setCouponUserStatus(CouponUser.Status.invalid);
  184. data.setIsAvailable(false);
  185. data.setReason("该优惠券已失效");
  186. isFlag = true;
  187. } else if (now.isAfter(data.getValidEndTime())) {
  188. data.setCouponUserStatus(CouponUser.Status.expired);
  189. data.setIsAvailable(false);
  190. data.setReason("该优惠券已过期");
  191. isFlag = true;
  192. } else if (now.isBefore(data.getValidStartTime())) {
  193. data.setCouponUserStatus(CouponUser.Status.notEffective);
  194. data.setIsAvailable(false);
  195. data.setReason("该优惠券未生效");
  196. isFlag = true;
  197. }
  198. }
  199. if (isFlag) {
  200. TASK_EXECUTOR.execute(() -> {
  201. if (data.getCouponUserStatus() != CouponUser.Status.notEffective) {
  202. CouponUser couponUser = new CouponUser();
  203. couponUser.setId(data.getId());
  204. couponUser.setStatus(data.getCouponUserStatus());
  205. couponUserMapper.updateById(couponUser);
  206. }
  207. });
  208. }
  209. }
  210. @Override
  211. public Integer collectRecommendCouponNum(Long userId, Boolean isNewUser) {
  212. List<CouponAvailableRecommendView> recommendCouponList = Optional.ofNullable(recommendMapper.getRecommendCouponList(userId, isNewUser)).orElse(new ArrayList<>());
  213. return recommendCouponList.size();
  214. }
  215. public void collectCommonCheck(Long couponId, Long userId) {
  216. Coupon coupon = couponMapper.selectById(couponId);
  217. if (coupon == null || !Boolean.TRUE.equals(coupon.getDeleted())) {
  218. throw BusinessRuntimeException.getInstance("该优惠券不存在");
  219. }
  220. if (Boolean.TRUE.equals(coupon.getIsValidTime()) &&
  221. (coupon.getValidEndTime() == null || !coupon.getValidEndTime().after(new Date()))) {
  222. throw BusinessRuntimeException.getInstance("该优惠券已失效");
  223. }
  224. //是否可领取
  225. if (coupon.getScope() == Coupon.Scope.newUser) {
  226. //注册后从没产生过虚拟订单的用户,产生过退款后也不是新用户
  227. CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
  228. if (couponNewUserView != null) {
  229. throw BusinessRuntimeException.getInstance("该优惠券只能新用户才能领取");
  230. }
  231. }
  232. CouponUser couponUser = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponId));
  233. if (couponUser != null) {
  234. if (couponUser.getChannel() == CouponUser.Channel.exCode) {
  235. throw BusinessRuntimeException.getInstance("您已兑换过该优惠券..");
  236. }
  237. throw BusinessRuntimeException.getInstance("您已领取该优惠券..");
  238. }
  239. }
  240. @Override
  241. public void updateCouponUserValidTime(Long couponId, CouponUser couponUser) {
  242. Coupon entity = couponMapper.getCouponById(couponId);
  243. Optional.ofNullable(entity).ifPresent(coupon -> {
  244. if (coupon.getIsValidTime()) {
  245. couponUser.setValidStartTime(coupon.getValidStartTime());
  246. couponUser.setValidEndTime(coupon.getValidEndTime());
  247. return;
  248. }
  249. couponUser.setValidStartTime(DateTime.now());
  250. if (coupon.getValidHours() > 0) {
  251. couponUser.setValidEndTime(DateUtil.offsetHour(couponUser.getValidStartTime(), coupon.getValidHours()));
  252. return;
  253. }
  254. couponUser.setValidEndTime(DateUtil.offsetDay(couponUser.getValidStartTime(), coupon.getValidDays()));
  255. });
  256. }
  257. @Override
  258. public void updateOrderDonCouponStatus(OrderDon orderDon) {
  259. log.info("订单:{}退款,优惠券返还start...", orderDon.getId());
  260. CouponUser couponUser = couponUserMapper.selectById(orderDon.getCouponUserId());
  261. if (CouponUser.Channel.exCode == couponUser.getChannel()) {
  262. //兑换码兑换的优惠券退款时,直接删除
  263. couponUserMapper.deleteById(couponUser.getId());
  264. } else {
  265. CouponUserView couponUserView = beanSearcher.searchFirst(CouponUserView.class, MapUtils.builder()
  266. .field(CouponUserView::getCouponId, couponUser.getCouponId()).op(Operator.Equal)
  267. .field(CouponUserView::getUserId, orderDon.getUserId()).op(Operator.Equal)
  268. .build());
  269. if (couponUserView == null) {
  270. return;
  271. }
  272. couponUserView.setCouponUserStatus(CouponUser.Status.unused);
  273. this.setCouponUserStatus(couponUserView, DateTime.now());
  274. couponUser.setStatus(couponUserView.getCouponUserStatus());
  275. couponUserMapper.updateById(couponUser);
  276. }
  277. log.info("订单:{}退款,优惠券返还end...", orderDon.getId());
  278. }
  279. @Override
  280. public void receiveChannelPopularizeCoupon(ChannelPopularizeCouponReq req) {
  281. Long userId = req.getUserId();
  282. Long popularizeId = req.getPopularizeId();
  283. Long couponId = req.getCouponId();
  284. ChannelPopularize channelPopularize = checkPopularizeChannelCoupon(userId, popularizeId);
  285. String couponIds = channelPopularize.getCouponIds();
  286. List<Long> couponIdList = null;
  287. try {
  288. couponIdList = Jsons.parseList(couponIds, Long.class);
  289. if (!couponIdList.contains(couponId)) {
  290. throw BusinessRuntimeException.getInstance("链接未关联该优惠券");
  291. }
  292. } catch (Exception e) {
  293. throw BusinessRuntimeException.getInstance("链接未关联该优惠券");
  294. }
  295. //优惠券领取状态校验
  296. collectCommonCheck(couponId, userId);
  297. //领取优惠券
  298. receiveCouponUser(couponId, userId, CouponUser.Channel.channel_popularize);
  299. }
  300. @Override
  301. public void collectAllChannelCoupons(long userId, Long popularizeId) {
  302. ChannelPopularize channelPopularize = checkPopularizeChannelCoupon(userId, popularizeId);
  303. String couponIds = channelPopularize.getCouponIds();
  304. List<Long> couponIdList = null;
  305. try {
  306. couponIdList = Jsons.parseList(couponIds, Long.class);
  307. } catch (Exception e) {
  308. throw BusinessRuntimeException.getInstance("链接未关联优惠券");
  309. }
  310. //一键领取优惠券
  311. couponIdList.forEach(couponId -> {
  312. try {
  313. receiveCouponUser(couponId, userId, CouponUser.Channel.channel_popularize);
  314. } catch (Exception e) {
  315. }
  316. });
  317. }
  318. public ChannelPopularize checkPopularizeChannelCoupon(Long userId, Long popularizeId) {
  319. //是否是该渠道来源新用户
  320. User user = userMapper.selectById(userId);
  321. if (user == null) {
  322. throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_USER_NO_FIND);
  323. }
  324. if (!user.getPopularizeId().equals(popularizeId)) {
  325. throw BusinessRuntimeException.getInstance("渠道推广新用户才能领取该优惠券");
  326. }
  327. //渠道链接是否存在
  328. ChannelPopularize channelPopularize = channelPopularizeMapper.selectById(popularizeId);
  329. Assert.notNull(channelPopularize, "链接不存在");
  330. //是否关联该优惠券
  331. String couponIds = channelPopularize.getCouponIds();
  332. if (StrUtil.isEmpty(couponIds)) {
  333. throw BusinessRuntimeException.getInstance("链接未关联优惠券");
  334. }
  335. return channelPopularize;
  336. }
  337. /**
  338. * 领取优惠券
  339. */
  340. public void receiveCouponUser(Long couponId, Long userId, CouponUser.Channel channel) {
  341. CouponUser couponUser = new CouponUser();
  342. couponUser.setUserId(userId);
  343. couponUser.setCouponId(couponId);
  344. couponUser.setChannel(channel);
  345. couponUser.setStatus(CouponUser.Status.unused);
  346. //优惠券有效时间
  347. this.updateCouponUserValidTime(couponId, couponUser);
  348. try {
  349. couponUserMapper.insert(couponUser);
  350. } catch (DuplicateKeyException e) {
  351. throw BusinessRuntimeException.getInstance("您已领取该优惠券,请勿重复领取");
  352. }
  353. }
  354. @Override
  355. public CouponUserView getNewUserWelfareCoupons(long userId,Long couponId) {
  356. return couponUserMapper.getNewUserWelfareCouponsByUserId(userId, couponId);
  357. }
  358. @Override
  359. public CouponUserView getCouponDetailById(long userId, Long couponId) {
  360. CouponUserView couponUserView = couponUserMapper.getCouponDetailById(userId, couponId);
  361. if (couponUserView != null) {
  362. String str = couponSkuMapper.selectGoodsSkuStr(couponUserView.getCouponId());
  363. couponUserView.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
  364. }
  365. return couponUserView;
  366. }
  367. @Override
  368. @Transactional(rollbackFor = Throwable.class)
  369. public CouponUserView receiveCoupon(long userId, Long couponId, CouponUser.Channel channel) {
  370. if (couponId == null || couponId <= 0) throw BusinessRuntimeException.getInstance("优惠券不存在");
  371. Coupon coupon = couponMapper.selectById(couponId);
  372. if (coupon == null) throw BusinessRuntimeException.getInstance("优惠券不存在");
  373. if (channel == CouponUser.Channel.manual) {
  374. // Public callers may only claim coupons explicitly published to the center.
  375. CouponActive active = couponActiveMapper.selectOne(Wrappers.lambdaQuery(CouponActive.class)
  376. .eq(CouponActive::getCouponId, couponId).eq(CouponActive::getStatus, true)
  377. .eq(CouponActive::getExpiryStatus, true).gt(CouponActive::getRemainNum, 0)
  378. .orderByAsc(CouponActive::getId).last("LIMIT 1"));
  379. if (active == null) throw BusinessRuntimeException.getInstance("该优惠券未开放领取");
  380. CouponCollectReq req = new CouponCollectReq();
  381. req.setCouponId(couponId);
  382. req.setCouponActiveId(active.getId());
  383. collectCoupon(req, userId);
  384. } else {
  385. collectCommonCheck(couponId, userId);
  386. receiveCouponUser(couponId, userId, channel);
  387. }
  388. return getCouponDetailById(userId, couponId);
  389. }
  390. @Override
  391. public List<CouponView> getGoodsUserActivityCoupons(long userId) throws Exception {
  392. UserActivityDistributeDetailView goodsActivity = getGoodsActivity();
  393. if (goodsActivity == null) {
  394. return null;
  395. }
  396. String couponIds = goodsActivity.getCouponIds();
  397. List<Long> couponIdList = Jsons.parseList(couponIds, Long.class);
  398. //是否领取过
  399. Integer selectCount = couponUserMapper.selectCount(Wrappers.lambdaQuery(CouponUser.class).in(CouponUser::getCouponId, couponIdList).eq(CouponUser::getUserId, userId));
  400. if (selectCount == couponIdList.size()) {
  401. return null;
  402. }
  403. //未领取
  404. //是否购买过
  405. List<Long> skuIdList = couponMapper.getCouponSkuIds(couponIdList);
  406. Integer orderCount = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).in(OrderDon::getSkuId, skuIdList));
  407. if (orderCount == 0) {
  408. return null;
  409. }
  410. List<CouponView> couponViews = beanSearcher.searchAll(CouponView.class, MapUtils.builder().field(CouponView::getCouponId, couponIdList).op(Operator.InList).orderBy(CouponView::getCouponId).build());
  411. return couponViews;
  412. }
  413. @Override
  414. public void collectAllGoodsActivityCoupons(long userId) throws Exception {
  415. UserActivityDistributeDetailView goodsActivity = getGoodsActivity();
  416. if (goodsActivity != null) {
  417. String couponIds = goodsActivity.getCouponIds();
  418. List<Long> couponIdList = Jsons.parseList(couponIds, Long.class);
  419. //是否领取过
  420. Integer selectCount = couponUserMapper.selectCount(Wrappers.lambdaQuery(CouponUser.class).in(CouponUser::getCouponId, couponIdList).eq(CouponUser::getUserId, userId));
  421. if (selectCount != couponIdList.size()) {
  422. //未领取
  423. //是否购买过
  424. List<Long> skuIdList = couponMapper.getCouponSkuIds(couponIdList);
  425. Integer orderCount = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).in(OrderDon::getSkuId, skuIdList));
  426. if (orderCount != 0) {
  427. //一键领取优惠券
  428. couponIdList.forEach(couponId -> {
  429. try {
  430. receiveCouponUser(couponId, userId, CouponUser.Channel.ptfq);
  431. } catch (Exception e) {
  432. }
  433. });
  434. }
  435. }
  436. }
  437. }
  438. public UserActivityDistributeDetailView getGoodsActivity() {
  439. String dateStr = DateTime.now().toString();
  440. String time = String.format(" and (ua.start_time is null or (ua.start_time < '%s' and ua.end_time > '%s'))", dateStr, dateStr);
  441. UserActivityDistributeDetailView goodsActivity = beanSearcher.searchFirst(UserActivityDistributeDetailView.class, MapUtils.builder()
  442. .field(UserActivityDistributeDetailView::getType, 3)
  443. .put("time", time)
  444. .build());
  445. return goodsActivity;
  446. }
  447. }