| | |
| | | import com.ks.lijin.service.LiJinExpendRecordService; |
| | | import com.ks.lijin.service.LiJinLinkService; |
| | | import com.ks.lijin.service.LijinCreateService; |
| | | import com.ks.vip.exception.LijinBalanceException; |
| | | import com.ks.vip.exception.OrderPayException; |
| | | import com.ks.vip.exception.VipOrderException; |
| | | import com.ks.vip.pojo.DO.*; |
| | | import com.ks.vip.pojo.DTO.PayWayInfoDTO; |
| | | import com.ks.vip.pojo.DTO.VipOrderDTO; |
| | | import com.ks.vip.pojo.Enums.PayWayEnum; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.service.*; |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.config.SystemConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.lijin.dto.TodayLijinCreatedInfo; |
| | | import com.yeshi.fanli.lijin.vo.UserLijinLevelInfoVO; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.util.account.UserUtil; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class UserLijinMnager { |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | private LijinCreateService lijinCreateService; |
| | | // @Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20904/com.ks.lijin.service.LijinCreateService") |
| | | // @Reference(version = "1.0", check = false, timeout = 30000) |
| | | // private LijinCreateService lijinCreateService; |
| | | |
| | | // @Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20902/com.ks.vip.service.VipCenterService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipCenterService vipCenterService; |
| | | |
| | | // @Reference(version = "1.0", check = false,url="dubbo://193.112.35.168:20902/com.ks.vip.service.VipCenterRecordService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipCenterRecordService vipCenterRecordService; |
| | | |
| | | // @Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20902/com.ks.vip.service.VipGradePotenceService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipGradePotenceService vipGradePotenceService; |
| | | |
| | | |
| | | // @Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20902/com.ks.vip.service.VipGradeService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipGradeService vipGradeService; |
| | | |
| | | // @Reference(version = "1.0", check = false,url="dubbo://193.112.35.168:20902/com.ks.vip.service.VipComboService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipComboService vipComboService; |
| | | |
| | | // @Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20904/com.ks.lijin.service.LiJinLinkService") |
| | | @Reference(version = "1.0", check = false) |
| | | private LiJinLinkService liJinLinkService; |
| | | |
| | | // @Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20904/com.ks.lijin.service.LiJinExpendRecordService") |
| | | @Reference(version = "1.0", check = false) |
| | | private LiJinExpendRecordService liJinExpendRecordService; |
| | | |
| | | // @Reference(version = "1.0", check = false,url="dubbo://193.112.35.168:20902/com.ks.vip.service.VipOrederService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipOrederService vipOrederService; |
| | | |
| | | // @Reference(version = "1.0", check = false,url="dubbo://193.112.35.168:20902/com.ks.vip.service.VipOrederPayService") |
| | | @Reference(version = "1.0", check = false) |
| | | private VipOrederPayService vipOrederPayService; |
| | | // @Reference(version = "1.0", check = false,url="dubbo://193.112.35.168:20902/com.ks.vip.service.VipOrederPayService") |
| | | @Reference(version = "1.0", check = false) |
| | | private LijinBalanceService lijinBalanceService; |
| | | @Reference(version = "1.0", check = false) |
| | | private LijinRecordService lijinRecordService; |
| | | |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | private String getUid(Long uid) { |
| | | if (uid == null) |
| | | return null; |
| | | return "tejia-" + uid; |
| | | |
| | | SystemEnum system = userInfoService.getUserSystem(uid); |
| | | if (system == null) |
| | | return null; |
| | | return systemConfigService.getValueCache(SystemConfigKeyEnum.thirdAppUidPrefix, system) + uid; |
| | | } |
| | | |
| | | public VIPEnum getVIPRank(Long uid) { |
| | | VIPEnum rank = null; |
| | | if (uid != null) |
| | | rank = vipCenterService.getVIPEnumByUid(getUid(uid)); |
| | | if (rank == null) |
| | | rank = vipGradeService.getDefaultGrade().getIdentity(); |
| | | return rank; |
| | | } |
| | | |
| | | |
| | | public VIPEnum getVIPRank(Long uid, Date date) { |
| | | VIPEnum rank = null; |
| | | if (uid != null) |
| | | rank = vipCenterService.getVIPEnumByUid(getUid(uid), date); |
| | | if (rank == null) |
| | | rank = vipGradeService.getDefaultGrade().getIdentity(); |
| | | return rank; |
| | |
| | | * @return |
| | | */ |
| | | public UserLijinLevelInfoVO getUserLevelInfo(Long uid, SystemEnum system) { |
| | | if (system == SystemEnum.yhqjx) { |
| | | if (system == SystemEnum.yhqjx || system == SystemEnum.hsb) { |
| | | VIPEnum rank = getVIPRank(uid); |
| | | UserLijinLevelInfoVO vo = new UserLijinLevelInfoVO(); |
| | | vo.setUserLevel(getVIPRank(uid).name()); |
| | | vo.setLoadingAdInfo(new UserLijinLevelInfoVO.ADInfo("gdt2", "9041686956722647")); |
| | | if (rank == getDefaultRank()) { |
| | | //当前为默认等级,可以升级 |
| | | vo.setUpgradeRights(new UserLijinLevelInfoVO.UpgradeRights("铂金会员免广告,礼金提高100%", configService.getValue(ConfigKeyEnum.lijinVIPLink, system))); |
| | | vo.setUpgradeRights(new UserLijinLevelInfoVO.UpgradeRights("铂金会员免广告,礼金红包提高216%", configService.getValue(ConfigKeyEnum.lijinVIPLink, system))); |
| | | } |
| | | return vo; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户的返利比例 |
| | | * |
| | | * @param uid |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public BigDecimal getUserFanliRate(Long uid, Date date) { |
| | | VIPEnum vipRank = getVIPRank(uid, date); |
| | | VipGradePotence potence = vipGradePotenceService.getPotenceByVipEnum(vipRank, date); |
| | | return potence.getRebatePercent(); |
| | | } |
| | | |
| | | /** |
| | | * 创建订单 |
| | | * |
| | | * @param uid |
| | | * @param cid |
| | | * @param payWay |
| | | * @return |
| | | */ |
| | | public PayWayInfoDTO createVIPOrder(Long uid, Long cid, PayWayEnum payWay, String ip) throws VipOrderException { |
| | | VipCombo vipCombo = vipComboService.selectByPrimaryKey(cid); |
| | | if (vipCombo == null) { |
| | | throw new VipOrderException(1, "套餐为空"); |
| | | } |
| | | String notifuUrl = "http://api.tejia.yeshitv.com/fanli/alipay/pay/lijinvip"; |
| | | String resturnUrl = "http://vip.tejia.yeshitv.com/pay_success.html"; |
| | | if (payWay == PayWayEnum.weChat) { |
| | | resturnUrl = "http://vip.tejia.yeshitv.com/pay_finish.html"; |
| | | notifuUrl = "http://api.tejia.yeshitv.com/fanli/wx/pay/lijinvip"; |
| | | } |
| | | |
| | | VipOrderDTO dto = new VipOrderDTO(); |
| | | dto.setUid(getUid(uid)); |
| | | dto.setComboId(cid); |
| | | dto.setPayAccount(null); |
| | | dto.setPayMoney(vipCombo.getDiscountPrice()); |
| | | dto.setPayWay(payWay); |
| | | dto.setThreeOrderId("tv" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHHmmssSSS") + uid); |
| | | return vipOrederPayService.addOrderWithPay(dto, notifuUrl, resturnUrl, ip); |
| | | } |
| | | |
| | | /** |
| | | * 获取支付宝的支付表单 |
| | | * |
| | | * @param formId |
| | | * @return |
| | | */ |
| | | public String getAlipayPayForm(String formId) { |
| | | return vipOrederPayService.getAlipayForm(formId); |
| | | } |
| | | |
| | | /** |
| | | * 检查是否支付 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public VipOrder checkPay(Long id) throws OrderPayException, VipOrderException { |
| | | return vipOrederPayService.checkOrderPayState(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据三方支付订单ID查询 |
| | | * |
| | | * @param threeOrderId |
| | | * @return |
| | | */ |
| | | public VipOrder selectVipOrderByThreeOrderId(String threeOrderId) { |
| | | return vipOrederService.selectByThreeOrderId(threeOrderId); |
| | | } |
| | | |
| | | |
| | | public String getWXPaySuccessOutOrderNo(String notifyContent) throws Exception { |
| | | return vipOrederPayService.getWXPaySuccessOutOrderNo(notifyContent); |
| | | } |
| | | |
| | | |
| | | public String getAlipayPaySuccessOutOrderNo(Map<String, String> params) throws Exception { |
| | | return vipOrederPayService.getAlipayPaySuccessOutOrderNo(params); |
| | | } |
| | | |
| | | public void addLijin(Long uid, BigDecimal money, String title, String category) throws LijinBalanceException { |
| | | lijinBalanceService.addLijin(getUid(uid), money, title, category, null); |
| | | } |
| | | |
| | | public List<UserLijinRecord> getLijinRecord(Long uid, Integer type, int page, int pageSize) { |
| | | return lijinRecordService.listRecord(getUid(uid), type, page, pageSize); |
| | | } |
| | | |
| | | public long countLijinRecord(Long uid, Integer type) { |
| | | return lijinRecordService.countRecord(getUid(uid), type); |
| | | } |
| | | |
| | | public UserLijinRecord getLijinRecord(Long uid, Integer type, String category) { |
| | | return lijinRecordService.getRecord(getUid(uid), type, category, null); |
| | | } |
| | | |
| | | /** |
| | | * 获取礼金余额 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public BigDecimal getLijinBalance(Long uid) { |
| | | return lijinBalanceService.getBalance(getUid(uid)); |
| | | } |
| | | |
| | | /** |
| | | * 获取使用中的礼金 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public BigDecimal getUsingLijin(Long uid) { |
| | | return lijinBalanceService.getUsingLijin(getUid(uid)); |
| | | } |
| | | |
| | | /** |
| | | * 初始化余额 |
| | | * |
| | | * @param uid |
| | | */ |
| | | public void initBalance(Long uid) { |
| | | lijinBalanceService.init(getUid(uid)); |
| | | } |
| | | |
| | | |
| | | } |