| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPInfoMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | |
|
| | | @Service
|
| | | public class UserVIPInfoServiceImpl implements UserVIPInfoService {
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoMapper userVIPInfoMapper;
|
| | | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | | |
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | | |
| | |
|
| | | @Override
|
| | | public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException {
|
| | |
| | | return map;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public boolean verifyConform(Long uid) {
|
| | | if (uid == null || uid <= 0)
|
| | | return false;
|
| | | |
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra == null) |
| | | return false;
|
| | | |
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
|
| | | executeDate = format.parse(limtDate);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (executeDate == null)
|
| | | return false;
|
| | | |
| | | // 1、直接粉丝(从 2020 年 1 月 1 日起直接粉丝产生有效订单)
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | | long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, executeDate.getTime(), payMoney);
|
| | | if (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime()) {
|
| | | long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user"));
|
| | | if (teamNum < limitNum)
|
| | | return false;
|
| | | } else {
|
| | | long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user"));
|
| | | if (teamNum < limitNum)
|
| | | return false;
|
| | | }
|
| | | |
| | | // 2、累计自购返利≥100 元(从注册板栗快省起);
|
| | | BigDecimal fanMoney = new BigDecimal(userVipConfigService.getValueByKey("require_fan_money"));
|
| | | BigDecimal purchase = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | | if (purchase.compareTo(fanMoney) < 0)
|
| | | return false;
|
| | | |
| | | // 3、累计金币≥10000 枚(从注册板栗快省起);
|
| | | BigDecimal goldCoin = integralDetailService.getCumulativeMoney(uid);
|
| | | BigDecimal limitGoldCoin = new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin"));
|
| | | if (goldCoin.compareTo(limitGoldCoin) < 0)
|
| | | return false;
|
| | | |
| | | // 4、使用红包≥1 次
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | long useHongBao = banLiShopOrderService.countByUidAndState(uid, list);
|
| | | long limitHongBao = Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy"));
|
| | | if (useHongBao < limitHongBao)
|
| | | return false;
|
| | | |
| | | // 符合条件
|
| | | return true;
|
| | | }
|
| | | }
|