|
@@ -9,6 +9,8 @@ import cn.com.ty.lift.ud.appmenu.mapper.entity.Appmenu;
|
|
|
import cn.com.ty.lift.ud.appmenu.service.IAppuserMenuService;
|
|
|
import cn.com.ty.lift.ud.common.RandomizingID;
|
|
|
import cn.com.ty.lift.ud.company.service.ICompanyService;
|
|
|
+import cn.com.ty.lift.ud.coupon.mapper.entity.Coupon;
|
|
|
+import cn.com.ty.lift.ud.coupon.service.ICouponService;
|
|
|
import cn.com.ty.lift.ud.dataBank.mapper.entity.LiftBrandEntity;
|
|
|
import cn.com.ty.lift.ud.dataBank.mapper.entity.LiftCertificateEntity;
|
|
|
import cn.com.ty.lift.ud.dataBank.service.ILiftBrandService;
|
|
@@ -41,10 +43,7 @@ import cn.com.ty.lift.ud.userInfo.mapper.entity.*;
|
|
|
import cn.com.ty.lift.ud.userInfo.service.IUserInfoService;
|
|
|
import cn.com.ty.lift.ud.userRebate.mapper.entity.UserRebateEntity;
|
|
|
import cn.com.ty.lift.ud.userRebate.service.IUserRebateService;
|
|
|
-import cn.com.ty.lift.ud.utils.BaiduDistance;
|
|
|
-import cn.com.ty.lift.ud.utils.PasswordUtils;
|
|
|
-import cn.com.ty.lift.ud.utils.PingYinUtil;
|
|
|
-import cn.com.ty.lift.ud.utils.QrCodeUtil;
|
|
|
+import cn.com.ty.lift.ud.utils.*;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import cn.com.xwy.util.collection.ListUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -104,6 +103,9 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfoEnt
|
|
|
@Autowired
|
|
|
private IUserCouponService iUserCouponService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICouponService couponService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ILiftBrandService iLiftBrandService;
|
|
|
|
|
@@ -116,12 +118,21 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfoEnt
|
|
|
@Autowired
|
|
|
private JmsMessagingTemplate jmsMessagingTemplate;
|
|
|
|
|
|
- private @Autowired
|
|
|
- IAppuserMenuService appUserMenuService;
|
|
|
+ @Autowired
|
|
|
+ private IAppuserMenuService appUserMenuService;
|
|
|
|
|
|
@Autowired
|
|
|
private ApplyExpertMapper applyExpertMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IVipFeeSettingService vipFeeSettingService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserRebateService iUserRebateService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserBillService iUserBillService;
|
|
|
+
|
|
|
@Override
|
|
|
public UserInfoEntity getByUserId(Long id) {
|
|
|
UserInfoEntity userInfo = userInfoMapper.getUserInfo(id);
|
|
@@ -175,15 +186,6 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfoEnt
|
|
|
return userInfo;
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private IVipFeeSettingService vipFeeSettingService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IUserRebateService iUserRebateService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IUserBillService iUserBillService;
|
|
|
-
|
|
|
/**
|
|
|
* 获取个人信息
|
|
|
*
|
|
@@ -665,11 +667,32 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfoEnt
|
|
|
|
|
|
@Override
|
|
|
public RestResponse batchSendRedEnvelope(List<String> userList, Long redEncelopId) {
|
|
|
+ Optional<Coupon> couponOptional = Optional.ofNullable(
|
|
|
+ couponService.getOne(new QueryWrapper<Coupon>()
|
|
|
+ .eq("type", 2)
|
|
|
+ .eq("id", redEncelopId)));
|
|
|
+ if (!couponOptional.isPresent()){
|
|
|
+ return RestResponse.fail( "当前红包不存在,请重新选择");
|
|
|
+ } else {
|
|
|
+ Coupon coupon = couponOptional.get();
|
|
|
+
|
|
|
+ int issuedRedPacket = iUserCouponService.count(new QueryWrapper<UserCoupon>()
|
|
|
+ .eq("type", 2)
|
|
|
+ .eq("coupon_id", redEncelopId));
|
|
|
+ int redPacketNum = issuedRedPacket + userList.size();
|
|
|
+ if (redPacketNum > coupon.getNum()){
|
|
|
+ String returnStr = String.format("红包总个数{%d},已发红包{%d},可发红包{%d}",
|
|
|
+ coupon.getNum(), issuedRedPacket, coupon.getNum() - issuedRedPacket);
|
|
|
+ return RestResponse.fail( returnStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for (String id : userList) {
|
|
|
UserCoupon uc = new UserCoupon();
|
|
|
uc.setUserId(Long.parseLong(id));
|
|
|
uc.setCouponId(redEncelopId);
|
|
|
uc.setUsedFlag(1);
|
|
|
+ uc.setCreateBy(CurrentUserInfo.userInfo().getName());
|
|
|
iUserCouponService.save(uc);
|
|
|
}
|
|
|
return RestResponse.success(null, "发放成功");
|