| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.account.entity.RechargeRecords; |
| | | import com.dsh.account.entity.TAppUser; |
| | | import com.dsh.account.entity.TStudent; |
| | | import com.dsh.account.entity.VipPayment; |
| | | import com.dsh.account.entity.*; |
| | | import com.dsh.account.enums.RechargeRecordEnum; |
| | | import com.dsh.account.feignclient.activity.MerChandiseClient; |
| | | import com.dsh.account.feignclient.activity.MerChandiseStoreClient; |
| | | import com.dsh.account.feignclient.activity.UserConponClient; |
| | | import com.dsh.account.feignclient.activity.model.CommodityRequest; |
| | | import com.dsh.account.feignclient.activity.model.PointsMerchandise; |
| | | import com.dsh.account.feignclient.activity.model.ProductDetailRequest; |
| | | import com.dsh.account.feignclient.activity.model.*; |
| | | import com.dsh.account.feignclient.competition.DeductionCompetitionsClient; |
| | | import com.dsh.account.feignclient.competition.model.PaymentCompetition; |
| | | import com.dsh.account.feignclient.course.CoursePackageClient; |
| | |
| | | import com.dsh.account.feignclient.other.ImgConfigClient; |
| | | import com.dsh.account.feignclient.other.RechargeConfigClient; |
| | | import com.dsh.account.feignclient.other.StoreClient; |
| | | import com.dsh.account.feignclient.other.model.Store; |
| | | import com.dsh.account.feignclient.other.model.TImgConfig; |
| | | import com.dsh.account.mapper.RechargeRecordsMapper; |
| | | import com.dsh.account.mapper.TAppUserMapper; |
| | | import com.dsh.account.mapper.TStudentMapper; |
| | | import com.dsh.account.mapper.VipPaymentMapper; |
| | | import com.dsh.account.feignclient.other.model.*; |
| | | import com.dsh.account.mapper.*; |
| | | import com.dsh.account.model.AddAppUserVo; |
| | | import com.dsh.account.model.JoinPlayPaiVo; |
| | | import com.dsh.account.model.LoginSMSCodeVo; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Resource |
| | | private DeductionCompetitionsClient deducClient; |
| | | |
| | | @Resource |
| | | private UserIntegralChangesMapper uicMapper; |
| | | |
| | | @Resource |
| | | private MerChandiseStoreClient mcsClient; |
| | | |
| | | @Override |
| | | public ClassInfoVo queryUserOfStus(Integer id,String latitude,String longitude) { |
| | |
| | | return mcClient.getGoodDetailsWithId(detailsVo); |
| | | } |
| | | |
| | | @Override |
| | | public StuAndStoreResponse queryAppUserDefaultStuAndStore(Integer userIdFormRedis,Integer pointsMerId, String lat, String lon,Integer isCourse) { |
| | | StuAndStoreResponse response = new StuAndStoreResponse(); |
| | | if (isCourse == 1){ |
| | | List<TStudent> tStudents = tsmapper.selectList(new QueryWrapper<TStudent>() |
| | | .eq("appUserId",userIdFormRedis) |
| | | .eq("state",1) |
| | | .eq("isDefault",1)); |
| | | if (tStudents.size() > 0 ){ |
| | | response.setStuId(tStudents.get(0).getId()); |
| | | response.setStuName(tStudents.get(0).getName()); |
| | | response.setStuPhone(tStudents.get(0).getPhone()); |
| | | response.setStuAge(DateUtil.age(tStudents.get(0).getBirthday())); |
| | | } |
| | | return response; |
| | | }else { |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerId); |
| | | if (pointsMerchandise.getType() == 4){ |
| | | List<Integer> couponStoreIds = ucponClient.getCouponStoreIds(pointsMerId); |
| | | StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(couponStoreIds.get(0)); |
| | | if(ToolUtil.isNotEmpty(courseOfStore)){ |
| | | response.setStoreId(couponStoreIds.get(0)); |
| | | response.setStoreName(courseOfStore.getStoreName()); |
| | | } |
| | | }else { |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerId); |
| | | StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(integers.get(0)); |
| | | if(ToolUtil.isNotEmpty(courseOfStore)){ |
| | | response.setStoreId(integers.get(0)); |
| | | response.setStoreName(courseOfStore.getStoreName()); |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil productRedemptionOperation(Integer userIdFormRedis, Integer goodId, Integer goodsType,Integer nums,Integer exchangeType,Integer payType) { |
| | | PointsMerchandise merchandise = mcClient.selectPointsMerchandiseById(goodId); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (int i = 0; i < nums; i++) { |
| | | UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise(); |
| | | pointsMerchandise.setPointsMerchandiseId(goodId); |
| | | pointsMerchandise.setUserId(userIdFormRedis); |
| | | pointsMerchandise.setCode(code); |
| | | mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | } |
| | | |
| | | // 扣减积分 |
| | | TAppUser tAppUser = this.baseMapper.selectById(userIdFormRedis); |
| | | |
| | | |
| | | // 积分变更记录 |
| | | UserIntegralChanges userIntegralChanges = new UserIntegralChanges(); |
| | | userIntegralChanges.setAppUserId(userIdFormRedis); |
| | | userIntegralChanges.setOldIntegral(tAppUser.getIntegral()); |
| | | userIntegralChanges.setType(2); |
| | | tAppUser.setIntegral(null == tAppUser.getIntegral() ? merchandise.getIntegral() : tAppUser.getIntegral() +merchandise.getIntegral()); |
| | | userIntegralChanges.setNewIntegral(tAppUser.getIntegral()); |
| | | userIntegralChanges.setInsertTime(new Date()); |
| | | uicMapper.insert(userIntegralChanges); |
| | | |
| | | this.baseMapper.updateById(tAppUser); |
| | | // 现金支付 |
| | | if (exchangeType == 1){ |
| | | // 积分兑换 |
| | | switch (goodsType){ |
| | | case 2: |
| | | for (int i = 0; i < nums; i++) { |
| | | TCoursePackagePayment packagePayment = new TCoursePackagePayment(); |
| | | // packagePayment.setAppUserId(); |
| | | // TODO: 2023/7/14 |
| | | paymentClient.savePaymentCoursePackage(packagePayment); |
| | | } |
| | | break; |
| | | case 4: |
| | | for (int i = 0; i < nums; i++) { |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(goodId); |
| | | coupon.setUserId(userIdFormRedis); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }else { |
| | | switch (payType){ |
| | | case 1: |
| | | return WechatPayment(merchandise.getCash(),code); |
| | | case 2: |
| | | return AlipayPayment(merchandise.getCash(),code); |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private ResultUtil AlipayPayment(BigDecimal cash, String code) { |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | private ResultUtil WechatPayment(BigDecimal cash, String code) { |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber,Integer payType) { |
| | | List<UserPointsMerchandise> userPointsMerchandises = mcClient.queryUserPointMerchaseByCode(code); |
| | | if (userPointsMerchandises.size() > 1){ |
| | | for (int i = 0; i < userPointsMerchandises.size(); i++) { |
| | | userPointsMerchandises.get(i).setOrderNumber(orderNumber+ "-" + (i+1)); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandises.get(i)); |
| | | |
| | | Integer pointsMerchandiseId = userPointsMerchandises.get(i).getPointsMerchandiseId(); |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerchandiseId); |
| | | switch (pointsMerchandise.getType()){ |
| | | case 2: |
| | | TCoursePackagePayment packagePayment = new TCoursePackagePayment(); |
| | | |
| | | // packagePayment.setAppUserId(); |
| | | |
| | | paymentClient.savePaymentCoursePackage(packagePayment); |
| | | break; |
| | | case 4: |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(userPointsMerchandises.get(0).getPointsMerchandiseId()); |
| | | coupon.setUserId(userPointsMerchandises.get(0).getUserId()); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | }else { |
| | | userPointsMerchandises.get(0).setOrderNumber(orderNumber); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandises.get(0)); |
| | | Integer pointsMerchandiseId = userPointsMerchandises.get(0).getPointsMerchandiseId(); |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerchandiseId); |
| | | switch (pointsMerchandise.getType()){ |
| | | case 2: |
| | | TCoursePackagePayment packagePayment = new TCoursePackagePayment(); |
| | | |
| | | // packagePayment.setAppUserId(); |
| | | |
| | | paymentClient.savePaymentCoursePackage(packagePayment); |
| | | break; |
| | | case 4: |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(userPointsMerchandises.get(0).getPointsMerchandiseId()); |
| | | coupon.setUserId(userPointsMerchandises.get(0).getUserId()); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | @Override |
| | | public List<StoreResponse> queryStoresOfExchange(Integer goodsType,Integer pointsMerId) { |
| | | List<StoreResponse> responses = new ArrayList<>(); |
| | | if (goodsType == 4){ |
| | | List<Integer> couponStoreIds = ucponClient.getCouponStoreIds(pointsMerId); |
| | | for (Integer couponStoreId : couponStoreIds) { |
| | | StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(couponStoreId); |
| | | if(ToolUtil.isNotEmpty(courseOfStore)){ |
| | | StoreResponse response = new StoreResponse(); |
| | | response.setStoreId(couponStoreId); |
| | | response.setStoreName(courseOfStore.getStoreName()); |
| | | responses.add(response); |
| | | } |
| | | } |
| | | }else { |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerId); |
| | | for (Integer integer : integers) { |
| | | StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(integer); |
| | | if(ToolUtil.isNotEmpty(courseOfStore)){ |
| | | StoreResponse response = new StoreResponse(); |
| | | response.setStoreId(integer); |
| | | response.setStoreName(courseOfStore.getStoreName()); |
| | | responses.add(response); |
| | | } |
| | | } |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | |
| | | } |