| | |
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.taobao.TLJFreeBuyGoods;
|
| | |
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.redpack.TaoLiJinWinDetailVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class UserTaoLiJinNewbiesServiceImpl implements UserTaoLiJinNewbiesService {
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigTaoLiJinService configTaoLiJinService;
|
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
| | | if (uid == null || uid <= 0)
|
| | | return null; // 未登录弹出
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null)
|
| | | return null;
|
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null || userInfoExtra.getFirstLoginTime() == null)
|
| | | return null;
|
| | |
| | | detail.setTitle(TaoLiJinDetailTypeEnum.add.getDesc());
|
| | | detail.setType(TaoLiJinDetailTypeEnum.add);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setRemark("新人红包");
|
| | | userTaoLiJinDetailService.insertSelective(detail);
|
| | |
|
| | | |
| | | Map<String,String> map = new HashMap<String,String>();
|
| | | map.put("url", configTaoLiJinService.getValueByKey("new_user_free_buy_list"));
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("url", configTaoLiJinService.getValueByKey("new_user_free_buy_list"));
|
| | |
|
| | | TaoLiJinWinDetailVO winDetailVO = new TaoLiJinWinDetailVO();
|
| | | winDetailVO.setTitle("新人红包");
|
| | |
| | | winDetailVO.setMoney(money.toString());
|
| | | winDetailVO.setDesc("已领取:" + balance + "元");
|
| | | winDetailVO.setTips(configTaoLiJinService.getValueByKey("new_user_win_tips"));
|
| | | winDetailVO.setParams(map.toString());
|
| | | winDetailVO.setParams(json.toString());
|
| | | winDetailVO.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | winDetailVO.setLogo(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | winDetailVO.setLogoLight(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | winDetailVO.setLogoLight(userInfo.getPortrait());
|
| | | return winDetailVO;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | // 验证是否有券
|
| | | if (goods == null || goods.getCouponAmount() == null ||
|
| | | goods.getCouponAmount().compareTo(new BigDecimal(0)) == 0) {
|
| | | goods.getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | tljFreeBuyGoodsService.deleteByGoodsId(goods.getId());
|
| | | tljFreeBuyGoodsService.deleteByGoodsId(goods.getAuctionId());
|
| | | }
|
| | | });
|
| | | throw new UserTaoLiJinNewbiesException(1, "该商品非免单商品");
|
| | |
| | |
|
| | | // 验证券后价 是否在 1-2元
|
| | | BigDecimal money = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | if (money.compareTo(new BigDecimal(1.0)) < 0 && money.compareTo(new BigDecimal(2.0)) > 0) {
|
| | | if (money.compareTo(new BigDecimal(1.0)) < 0 || money.compareTo(new BigDecimal(2.0)) > 0) {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | tljFreeBuyGoodsService.deleteByGoodsId(goods.getId());
|
| | | tljFreeBuyGoodsService.deleteByGoodsId(goods.getAuctionId());
|
| | | }
|
| | | });
|
| | | throw new UserTaoLiJinNewbiesException(1, "该商品非免单商品");
|
| | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null || userInfoExtra.getFirstLoginTime() == null)
|
| | | throw new UserTaoLiJinNewbiesException(1001, "你不是“新用户”无法使用新人红包0元购买。");
|
| | | |
| | | |
| | | // 验证是否激活
|
| | | if (StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | throw new UserTaoLiJinNewbiesException(1002, "邀请码未激活,无法使用新人红包0元购买。");
|
| | | |
| | | // 验证是否已超出新用户定义
|
| | | try {
|
| | | int days = DateUtil.daysBetween2(userInfoExtra.getFirstLoginTime(), new Date());
|
| | |
| | | } catch (ParseException e1) {
|
| | | throw new UserTaoLiJinNewbiesException(1, "日期信息计算失败");
|
| | | }
|
| | | |
| | | |
| | | // 验证余额
|
| | | UserTaoLiJinNewbies taoLiJinNewbies = userTaoLiJinNewbiesMapper.selectForUpdate(uid);
|
| | | if (taoLiJinNewbies == null || taoLiJinNewbies.getMoney() == null ||
|
| | |
| | | detail.setTitle(TaoLiJinDetailTypeEnum.reduce.getDesc());
|
| | | detail.setType(TaoLiJinDetailTypeEnum.reduce);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setRemark("新人免单使用红包");
|
| | | userTaoLiJinDetailService.insertSelective(detail);
|
| | |
|
| | | // 创建淘礼金链接
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | private String createTaoLiJin(Long auctionId, BigDecimal perface, int totalNum, String pid) throws UserTaoLiJinNewbiesException {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | |
| | | return userTaoLiJinNewbiesMapper.selectByPrimaryKey(uid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long count(String key) {
|
| | | return userTaoLiJinNewbiesMapper.count(key);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<UserTaoLiJinNewbies> query(int page, int count, String key,Integer order) {
|
| | | return userTaoLiJinNewbiesMapper.query((page -1)* count, count, key, order);
|
| | | }
|
| | | }
|