| | |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | |
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | // 券失效图片
|
| | | public final static String PIC_INVALID = "http://192.168.1.200/icon/mian_invalid.png";
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void insertUserCoupon(Long uid, String couponType,String source)throws UserSystemCouponException,Exception{
|
| | | |
| | | if (couponType == null || uid == null) {
|
| | | throw new UserSystemCouponException(1, "参数不正确");
|
| | | } |
| | | |
| | | SystemCoupon coupon= systemCouponService.getCouponByType(couponType);
|
| | | if (coupon == null) {
|
| | | throw new UserSystemCouponException(1, "券类型不正确");
|
| | | } |
| | | |
| | | int stateActivated = 1;
|
| | | if (coupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
|
| | | // 福利券状态
|
| | | long countSuccess = threeSaleSerivce.countSuccessFirstTeam(uid);
|
| | | // 没有下级队员 --待激活
|
| | | if (countSuccess == 0) {
|
| | | stateActivated = 0;
|
| | | }
|
| | | }
|
| | | |
| | | // 结束日期
|
| | | String endDay = DateUtil.plusDay(coupon.getExpiryDay(), new Date());
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date endTime = format.parse(endDay);
|
| | | |
| | | UserSystemCoupon userCoupon = new UserSystemCoupon();
|
| | | userCoupon.setUid(uid);
|
| | | userCoupon.setSource(source);
|
| | | userCoupon.setSystemCoupon(coupon);
|
| | | userCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userCoupon.setStateActivated(stateActivated);
|
| | | userCoupon.setStartTime(new Date());
|
| | | userCoupon.setEndTime(endTime);
|
| | | userCoupon.setCreateTime(new Date());
|
| | | userCoupon.setUpdateTime(new Date());
|
| | | // 插入数据库
|
| | | insertSelective(userCoupon);
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public List<UserSystemCouponVO> getUserCouponVOList(long start, int count, Long uid)
|
| | | throws UserSystemCouponException, Exception {
|
| | |
|
| | |
| | | }
|
| | |
|
| | | // 数据组织
|
| | | listDataFactory(listVO);
|
| | | listDataFactory(listVO, uid);
|
| | |
|
| | | return listVO;
|
| | | }
|
| | |
| | | *
|
| | | * @param listVO
|
| | | */
|
| | | public void listDataFactory(List<UserSystemCouponVO> listVO) throws Exception{
|
| | | public void listDataFactory(List<UserSystemCouponVO> listVO, Long uid) throws Exception{
|
| | |
|
| | | for (UserSystemCouponVO userCouponVO : listVO) {
|
| | |
|
| | |
| | | userCouponVO.setCouponEffect(systemCoupon.getEffect());
|
| | | userCouponVO.setCouponRule(systemCoupon.getRule());
|
| | |
|
| | | // 使用中状态 改变为已使用
|
| | | // 使用状态
|
| | | Integer state = userCouponVO.getState();
|
| | | if (UserSystemCoupon.STATE_IN_USE == state) {
|
| | | state = UserSystemCoupon.STATE_END_USE;
|
| | | userCouponVO.setState(state);
|
| | | }
|
| | |
|
| | | // 按钮跳转
|
| | |
|
| | | Map<String, Object> jumpBtn = null;
|
| | | |
| | | Integer stateActivated = userCouponVO.getStateActivated();
|
| | | |
| | | if (stateActivated == null || stateActivated == 0) {
|
| | | // 显示规则
|
| | | userCouponVO.setCouponRule(systemCoupon.getRemark());
|
| | | systemCoupon.setEffect("待激活");
|
| | | userCouponVO.setCouponEffect("待激活");
|
| | |
|
| | | // 状态未激活 -且未被使用
|
| | | if (UserSystemCoupon.STATE_CAN_USE == state) {
|
| | |
| | |
|
| | | jumpBtn = new HashMap<String, Object>();
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("url", configService.get("invite_activation_url"));
|
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | |
| | | // 邀请队员界面
|
| | | if (userInfoExtra != null && userInfoExtra.getInviteCode() != null
|
| | | && userInfoExtra.getInviteCode().trim().length() > 0) {
|
| | | // 邀请激活成功界面
|
| | | jumpLink.put("url", configService.get("invite_activation_success_url") + "?alert=true");
|
| | | } else {
|
| | | // 激活邀请码界面
|
| | | jumpLink.put("url", configService.get("invite_activation_url"));
|
| | | }
|
| | | |
| | | jumpBtn.put("params", jumpLink);
|
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite"));
|
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite_web"));
|
| | |
|
| | | } else if (stateActivated == 1) {
|
| | | // 显示规则
|
| | |
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("web"));
|
| | |
|
| | | } else if (CouponTypeEnum.rebatePercentCoupon == type) {
|
| | | // 返利奖励券
|
| | | // 返利奖励券- 跳转至订单到账界面
|
| | | jumpLink.put("state", 2);
|
| | |
|
| | | jumpBtn = new HashMap<String, Object>();
|
| | | jumpBtn.put("params", jumpLink);
|
| | | |
| | | // 跳转订单列表
|
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("orderList"));
|
| | | |
| | | }
|
| | | } else if (UserSystemCoupon.STATE_END_USE == state || UserSystemCoupon.STATE_OVERDUE == state) {
|
| | | userCouponVO.setCouponPicture(PIC_INVALID);
|
| | | |
| | | } else if (UserSystemCoupon.STATE_IN_USE == state) {
|
| | | // 使用中
|
| | | userCouponVO.setInUseExplain(configService.get("free_coupon_using-help"));
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | // 券失效图片替换
|
| | | if (UserSystemCoupon.STATE_END_USE == state || UserSystemCoupon.STATE_OVERDUE == state) {
|
| | | userCouponVO.setCouponPicture(PIC_INVALID);
|
| | | }
|
| | | |
| | | userCouponVO.setJumpBtn(jumpBtn);
|
| | |
|
| | | String couponTerm = "有效期:";
|
| | |
| | | differentDays = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | // 剩余天数
|
| | | Map<String, Object> remainDays = new HashMap<String, Object>();
|
| | | remainDays.put("content", "还剩" + differentDays + "天过期");
|
| | |
| | | return userRecordVO;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | }
|