Merge remote-tracking branch 'origin/master'
| | |
| | | @Data |
| | | @ApiModel("管理后台发放优惠券DTO") |
| | | public class GrantCouponDto { |
| | | @ApiModelProperty("类型 1按用户标签 2按用户所在地 3自定义发放") |
| | | private Integer type; |
| | | @ApiModelProperty("用户ids 逗号分隔") |
| | | private String userIds; |
| | | @ApiModelProperty("优惠券id") |
| | |
| | | private Integer waysToObtain; |
| | | @ApiModelProperty("结束时间 前端忽略") |
| | | private LocalDateTime endTime; |
| | | @ApiModelProperty("标签ids") |
| | | private String tags; |
| | | |
| | | @ApiModelProperty("市code 多个逗号分割") |
| | | private String cityCode; |
| | | @ApiModelProperty("省code 多个逗号分割") |
| | | private String provinceCode; |
| | | } |
| | |
| | | com.ruoyi.account.api.factory.AppUserCarFallbackFactory |
| | | com.ruoyi.account.api.factory.AppUserIntegralChangeFallbackFactory |
| | | com.ruoyi.account.api.factory.AppUserAddressFallbackFactory |
| | | com.ruoyi.account.api.factory.AppUserVipDetailFallbackFactory |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | |
| | | package com.ruoyi.order.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.order.api.query.TActivityStatisticsQuery; |
| | | import com.ruoyi.order.api.vo.TActivityVO; |
| | | import com.ruoyi.order.api.vo.ExchangeDto; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<Long> getExchangeById(Integer goodsIds, Long userId) { |
| | | public R<Long> getExchangeById(Integer goodsIds, Long userId,Integer goodType) { |
| | | return R.fail("根据订单数" + cause.getMessage()); |
| | | } |
| | | |
| | |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.order.api.factory.OrderFallbackFactory; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.order.api.vo.ExchangeDto; |
| | | import com.ruoyi.order.api.query.TActivityStatisticsQuery; |
| | | import com.ruoyi.order.api.vo.TActivityVO; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | public R<List<String>> getCodeByOrderId(String goodsIds); |
| | | //查询已兑换的订单数 |
| | | @PostMapping("/t-exchange-order/getById") |
| | | public R<Long> getExchangeById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId); |
| | | public R<Long> getExchangeById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId,@RequestParam("goodType") Integer goodType); |
| | | |
| | | @PostMapping("/t-exchange-order/create") |
| | | public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto); |
| | | |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | @ApiModelProperty(value = "销量") |
| | | @TableField(exist = false) |
| | | private Integer salesCount; |
| | | @ApiModelProperty(value = "1商品2优惠卷") |
| | | @TableField(exist = false) |
| | | private Integer goodType; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.other.api.dto; |
| | | package com.ruoyi.common.core.dto; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | @ApiModelProperty(hidden = true) |
| | | Long userId; |
| | | |
| | | @ApiModelProperty("1商品2优惠卷") |
| | | Integer goodType; |
| | | @ApiModelProperty(hidden = true) |
| | | Integer point; |
| | | |
| | | |
| | | } |
| | |
| | | public void ack() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void close(String outTradeNo) { |
| | | |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | com.ruoyi.payment.api.factory.ChargingOrderFallbackFactory |
| | | com.ruoyi.payment.api.factory.WxPaymentFallbackFactory |
New file |
| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Random; |
| | | |
| | | public class OrderCodeUtil { |
| | | |
| | | public static String getOrderCode(String code){ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| | | String formattedDate = now.format(formatter); |
| | | |
| | | // 四位随机数 |
| | | Random random = new Random(); |
| | | int randomNumber = random.nextInt(9999); // 生成0-9998之间的随机数 |
| | | String formattedRandomNumber = String.format("%04d", randomNumber); // 补齐到4位 |
| | | |
| | | // 拼接日期和随机数 |
| | | return code+formattedDate + formattedRandomNumber; |
| | | } |
| | | public static void main(String[] args) { |
| | | // 测试方法 |
| | | System.out.println(getOrderCode("DH")); |
| | | } |
| | | } |
| | |
| | | roleInfoVo.setMenus(menusId); |
| | | roleInfoVo.setRemark(role.getRemark()); |
| | | List<Integer> siteIds = roleSiteClient.getSiteIds(role.getRoleId()).getData(); |
| | | if(null != siteIds && siteIds.size() > 0){ |
| | | List<Site> sites = siteClient.getSiteByIds(siteIds).getData(); |
| | | List<String> siteNames = sites.stream().map(Site::getName).collect(Collectors.toList()); |
| | | roleInfoVo.setSiteNames(siteNames); |
| | | roleInfoVo.setSiteIds(siteIds); |
| | | } |
| | | return AjaxResult.success(roleInfoVo); |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.account.ali.pojo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "支付宝小程序登录") |
| | | public class AppletUserLogin implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "auth_code") |
| | | @NotBlank(message = "auth_code不能为空") |
| | | private String code; |
| | | |
| | | @ApiModelProperty(value = "获取用户信息加密串") |
| | | @NotBlank(message = "获取用户信息加密串不能为空") |
| | | private String token; |
| | | |
| | | } |
| | |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.request.AlipaySystemOauthTokenRequest; |
| | | import com.alipay.api.request.AlipayUserInfoShareRequest; |
| | | import com.alipay.api.request.AlipayUserUserinfoShareRequest; |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.ruoyi.account.ali.Constant.AliConstant; |
| | | import com.ruoyi.account.ali.model.AliProperties; |
| | |
| | | * 支付宝小程序授权获取手机号 |
| | | * @return |
| | | */ |
| | | public AlipayUserUserinfoShareResponse getUserInfo(String accessToken) { |
| | | public AlipayUserInfoShareResponse getUserInfo(String accessToken) { |
| | | try { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(new AliAppletTools(aliProperties).getAlipayConfig(AliConstant.LOGIN_SERVER_URL)); |
| | | //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.user.userinfo.share |
| | | AlipayUserUserinfoShareRequest request = new AlipayUserUserinfoShareRequest(); |
| | | AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest(); |
| | | //授权类接口执行API调用时需要带上accessToken |
| | | return alipayClient.execute(request,accessToken); |
| | | } catch (AlipayApiException e) { |
| | |
| | | import com.alipay.api.diagnosis.DiagnosisUtils; |
| | | import com.alipay.api.request.AlipaySystemOauthTokenRequest; |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.ali.Constant.AliConstant; |
| | | import com.ruoyi.account.ali.model.AliProperties; |
| | | import com.ruoyi.account.ali.pojo.AppletUserLogin; |
| | | import com.ruoyi.account.ali.tools.AliAppletTools; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @ApiOperation(value = "通过code获得openid",tags = {"支付宝小程序登录"}) |
| | | @GetMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestParam(name = "code")@ApiParam(value = "code", required = true) String code){ |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", code); |
| | | @PostMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserLogin appletUserLogin){ |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", appletUserLogin.getCode()); |
| | | // 登录 |
| | | AlipaySystemOauthTokenResponse response = new AliAppletTools(aliProperties).login(code); |
| | | AlipaySystemOauthTokenResponse response = new AliAppletTools(aliProperties).login(appletUserLogin.getCode()); |
| | | if (response.isSuccess()) { |
| | | // 获取用户信息 |
| | | AlipayUserUserinfoShareResponse userInfo = new AliAppletTools(aliProperties).getUserInfo(response.getAccessToken()); |
| | | AlipayUserInfoShareResponse userInfo = new AliAppletTools(aliProperties).getUserInfo(appletUserLogin.getToken()); |
| | | log.info("获取支付宝用户信息:{}", userInfo); |
| | | // 用户信息封装 |
| | | return AjaxResult.ok(appUserService.aliLogin(response,userInfo)); |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.account.api.dto.CouponListDto; |
| | | import com.ruoyi.account.api.dto.GrantCouponDto; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.account.api.model.TAppUserTag; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.service.TAppUserTagService; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class TAppCouponController { |
| | | @Autowired |
| | | private TAppCouponService tAppCouponService; |
| | | @Resource |
| | | private OtherClient otherClient; |
| | | |
| | | @Autowired |
| | | private TAppUserCarService appUserCarService; |
| | |
| | | return R.ok(tAppCouponService.pagelist(couponId)); |
| | | } |
| | | |
| | | @Autowired |
| | | private TAppUserTagService appUserTagService; |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | |
| | | /** |
| | | * 后台远程调用 给用户发放优惠券 |
| | | */ |
| | | @PostMapping("/grantCoupon") |
| | | public R grantCoupon(@RequestBody GrantCouponDto dto){ |
| | | List<TAppCoupon> res = new ArrayList<>(); |
| | | switch (dto.getType()){ |
| | | case 1: |
| | | // 根据标签ids 查询用户ids |
| | | List<Long> collect = appUserTagService.list(new QueryWrapper<TAppUserTag>() |
| | | .in("user_tag_id", Arrays.asList(dto.getTags().split(",")))) |
| | | .stream().map(TAppUserTag::getAppUserId).collect(Collectors.toList()); |
| | | for (Long l : collect) { |
| | | TAppCoupon tAppCoupon = new TAppCoupon(); |
| | | tAppCoupon.setAppUserId(l); |
| | | tAppCoupon.setCouponId(dto.getCouponId()); |
| | | tAppCoupon.setEndTime(dto.getEndTime()); |
| | | tAppCoupon.setWaysToObtain(dto.getWaysToObtain()); |
| | | tAppCoupon.setStatus(1); |
| | | res.add(tAppCoupon); |
| | | } |
| | | tAppCouponService.saveBatch(res); |
| | | break; |
| | | case 2: |
| | | // 根据市codes 查询用户ids |
| | | List<Long> collect1 = appUserService.list(new QueryWrapper<TAppUser>() |
| | | .in("city_code", Arrays.asList(dto.getCityCode().split(",")))) |
| | | .stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | for (Long l : collect1) { |
| | | TAppCoupon tAppCoupon = new TAppCoupon(); |
| | | tAppCoupon.setAppUserId(l); |
| | | tAppCoupon.setCouponId(dto.getCouponId()); |
| | | tAppCoupon.setEndTime(dto.getEndTime()); |
| | | tAppCoupon.setWaysToObtain(dto.getWaysToObtain()); |
| | | tAppCoupon.setStatus(1); |
| | | res.add(tAppCoupon); |
| | | } |
| | | tAppCouponService.saveBatch(res); |
| | | break; |
| | | case 3: |
| | | for (String s : dto.getUserIds().split(",")) { |
| | | TAppCoupon tAppCoupon = new TAppCoupon(); |
| | | tAppCoupon.setAppUserId(Long.valueOf(s)); |
| | |
| | | res.add(tAppCoupon); |
| | | } |
| | | tAppCouponService.saveBatch(res); |
| | | break; |
| | | } |
| | | |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | if (userListQueryDto.getUserTagId() != null){ |
| | | String[] split = userListQueryDto.getUserTagId().split(","); |
| | | userIds = appUserTagService.lambdaQuery().in(TAppUserTag::getUserTagId, Arrays.asList(split)).list().stream().map(TAppUserTag::getAppUserId).collect(Collectors.toList()); |
| | | if (userIds.isEmpty()){ |
| | | userIds.add(-1L); |
| | | } |
| | | } |
| | | //列表查询 |
| | | Page<TAppUser> page = appUserService.lambdaQuery() |
| | |
| | | //拿到最新的tagId |
| | | TAppUserTag one = appUserTagService.lambdaQuery().eq(TAppUserTag::getAppUserId, appUser.getId()).orderByDesc(TAppUserTag::getCreateTime).last("limit 1").one(); |
| | | //设置最新的tagName |
| | | if (one!=null){ |
| | | R<TUserTag> byIdTag = otherClient.getByIdTag(one.getUserTagId()); |
| | | if (byIdTag.getData()!=null) { |
| | | appUser.setTagName(byIdTag.getData().getName()); |
| | | } |
| | | } |
| | | //匹配vipMap的值 |
| | | appUser.setVipName(vipMap.getData().get(appUser.getVipId())); |
| | | //累计充电次数 |
| | |
| | | String openid = body.getOpenid(); |
| | | String sessionKey = body.getSessionKey(); |
| | | // 用户信息解密 数据验签 |
| | | if (StringUtils.isNotBlank(data.getSignature())) { |
| | | WxUtils.verifySignature(data.getRawData(), sessionKey, data.getSignature()); |
| | | } |
| | | // if (StringUtils.isNotBlank(data.getSignature())) { |
| | | // WxUtils.verifySignature(data.getRawData(), sessionKey, data.getSignature()); |
| | | // } |
| | | AppletUserDecodeData appletUserDecodeData = WxUtils.encryptedData(data.getEncryptedData(), sessionKey, data.getIv()); |
| | | appletUserDecodeData.setOpenId(openid); |
| | | return AjaxResult.ok(appUserService.wxLogin(appletUserDecodeData)); |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | |
| | | * @param userInfo |
| | | * @return |
| | | */ |
| | | Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response,AlipayUserUserinfoShareResponse userInfo); |
| | | Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserInfoShareResponse userInfo); |
| | | |
| | | /** |
| | | * 封装用户信息和token |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserUserinfoShareResponse userInfo) { |
| | | public Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserInfoShareResponse userInfo) { |
| | | // 通过手机号查询用户,是否已存在手动导入用户,包含微信用户 |
| | | TAppUser appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getPhone, userInfo.getMobile()) |
| | |
| | | |
| | | import com.ruoyi.account.api.model.TAppUserIntegralChange; |
| | | import com.ruoyi.account.service.TAppUserIntegralChangeService; |
| | | import com.ruoyi.common.core.utils.OrderCodeUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | public void addDetail(Integer old,Integer now,Integer type,Long userId,String extension,String code){ |
| | | |
| | | TAppUserIntegralChange tAppUserIntegralChange= new TAppUserIntegralChange(); |
| | | tAppUserIntegralChange.setCode(code); |
| | | tAppUserIntegralChange.setCode(OrderCodeUtil.getOrderCode("DH")); |
| | | tAppUserIntegralChange.setAppUserId(userId); |
| | | tAppUserIntegralChange.setChangeType(type); |
| | | tAppUserIntegralChange.setHistoricalIntegral(old); |
| | |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>3.3.0</version> |
| | | <type>pom</type> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | package com.ruoyi.chargingPile.controller; |
| | | |
| | | |
| | | import com.alibaba.excel.EasyExcelFactory; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.builder.ExcelWriterBuilder; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.chargingPile.api.dto.ApplyChargingQuery; |
| | | import com.ruoyi.chargingPile.api.dto.ApplyChargingRemarkDto; |
| | | import com.ruoyi.chargingPile.api.model.TApplyChargingPile; |
| | | import com.ruoyi.chargingPile.dto.TApplyChargingPileExportDto; |
| | | import com.ruoyi.chargingPile.service.TApplyChargingPileService; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.codec.CharEncoding; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URL; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiOperation(tags = {"后台-申请表单-申请建桩"},value = "导出") |
| | | @PutMapping(value = "/export") |
| | | public R export() { |
| | | public R export(HttpServletResponse response) { |
| | | try { |
| | | response.setCharacterEncoding(Constants.UTF8); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-disposition"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + |
| | | URLEncoder.encode("申请建桩数据", CharEncoding.UTF_8) + ".xlsx"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | return R.fail("excel导出失败!"); |
| | | } |
| | | try { |
| | | List<TApplyChargingPile> list = applyChargingPileService.lambdaQuery().last("limit 1").list(); |
| | | |
| | | List<TApplyChargingPileExportDto> exportDtos =new ArrayList<>(); |
| | | for (TApplyChargingPile tApplyChargingPile : list) { |
| | | TApplyChargingPileExportDto applyChargingPileExportDto = new TApplyChargingPileExportDto(); |
| | | BeanUtils.copyProperties(tApplyChargingPile,applyChargingPileExportDto); |
| | | applyChargingPileExportDto.setLandlordFrontIdCard(new URL(tApplyChargingPile.getLandlordFrontIdCard())); |
| | | applyChargingPileExportDto.setLandlordBackIdCard(new URL(tApplyChargingPile.getLandlordBackIdCard())); |
| | | applyChargingPileExportDto.setAgentBackIdCard(new URL(tApplyChargingPile.getAgentBackIdCard())); |
| | | applyChargingPileExportDto.setAgentFrontIdCard(new URL(tApplyChargingPile.getAgentFrontIdCard())); |
| | | List<URL> urls = new ArrayList<>(); |
| | | urls.add(new URL("https://img-blog.csdnimg.cn/direct/c11088e1790049a5b84a0fda21a271b1.png")); |
| | | urls.add(new URL("https://img-blog.csdnimg.cn/direct/c11088e1790049a5b84a0fda21a271b1.png")); |
| | | urls.add(new URL("https://img-blog.csdnimg.cn/direct/c11088e1790049a5b84a0fda21a271b1.png")); |
| | | applyChargingPileExportDto.setUrls(urls); |
| | | exportDtos.add(applyChargingPileExportDto); |
| | | |
| | | } |
| | | |
| | | // excel模板封装 |
| | | ExcelWriterBuilder excelWriterBuilder = EasyExcelFactory.write(response.getOutputStream()); |
| | | InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/" +"充电桩申请记录" + ".xlsx"); |
| | | // 自动释放资源 |
| | | try (ExcelWriter excelWriter = excelWriterBuilder.withTemplate(stream).build()) { |
| | | WriteSheet writeSheet = EasyExcelFactory.writerSheet().build(); |
| | | excelWriter.fill(exportDtos, writeSheet); |
| | | excelWriter.finish(); |
| | | } catch (Exception e) { |
| | | return R.fail("excel导出失败!"); |
| | | } |
| | | } catch (IOException e) { |
| | | return R.fail("excel导出失败!"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.chargingPile.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.annotation.Excel; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.math.BigDecimal; |
| | | import java.net.URL; |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | |
| | | public class TApplyChargingPileExportDto extends BasePojo { |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | | private Long appUserId; |
| | | |
| | | @ApiModelProperty(value = "用电地址") |
| | | @NotBlank(message = "用电地址不能为空") |
| | | @TableField("address") |
| | | private String address; |
| | | |
| | | @ApiModelProperty(value = "申请容量") |
| | | @TableField("capacity") |
| | | private BigDecimal capacity; |
| | | |
| | | @ApiModelProperty(value = "用电时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @TableField("consumption_time") |
| | | private LocalDate consumptionTime; |
| | | |
| | | @ApiModelProperty(value = "户主经办(0=关,1=开)") |
| | | @TableField("landlord_handling") |
| | | private Integer landlordHandling; |
| | | |
| | | @ApiModelProperty(value = "户名") |
| | | @TableField("landlord_name") |
| | | private String landlordName; |
| | | |
| | | @ApiModelProperty(value = "户主身份证号码") |
| | | @TableField("landlord_id_card") |
| | | private String landlordIdCard; |
| | | |
| | | @ApiModelProperty(value = "户主手机号") |
| | | @TableField("landlord_phone") |
| | | private String landlordPhone; |
| | | |
| | | @ApiModelProperty(value = "户主身份证正面") |
| | | @TableField("landlord_front_id_card") |
| | | private URL landlordFrontIdCard; |
| | | |
| | | @ApiModelProperty(value = "户主身份证反面") |
| | | @TableField("landlord_back_id_card") |
| | | private URL landlordBackIdCard; |
| | | |
| | | @ApiModelProperty(value = "产权证明") |
| | | @TableField("title_certificate") |
| | | private String titleCertificate; |
| | | |
| | | @ApiModelProperty(value = "营业执照") |
| | | @TableField("business_license") |
| | | private String businessLicense; |
| | | |
| | | @ApiModelProperty(value = "充电桩用户(0=关,1=开)") |
| | | @TableField("charging_pile_user") |
| | | private Integer chargingPileUser; |
| | | |
| | | @ApiModelProperty(value = "固定车位产权") |
| | | @TableField("fixed_parking_property_rights") |
| | | private String fixedParkingPropertyRights; |
| | | |
| | | @ApiModelProperty(value = "施工证明") |
| | | @TableField("construction_certificate") |
| | | private String constructionCertificate; |
| | | |
| | | @ApiModelProperty(value = "经办人姓名") |
| | | @TableField("agent_name") |
| | | private String agentName; |
| | | |
| | | @ApiModelProperty(value = "经办人身份证号") |
| | | @TableField("agent_id_card") |
| | | private String agentIdCard; |
| | | |
| | | @ApiModelProperty(value = "经办人手机号") |
| | | @TableField("agent_phone") |
| | | private String agentPhone; |
| | | |
| | | @ApiModelProperty(value = "经办人身份证正面") |
| | | @TableField("agent_front_id_card") |
| | | private URL agentFrontIdCard; |
| | | |
| | | @ApiModelProperty(value = "经办人身份证背面") |
| | | @TableField("agent_back_id_card") |
| | | private URL agentBackIdCard; |
| | | |
| | | @ApiModelProperty(value = "是否有充电桩(0=否,1=是)") |
| | | @TableField("charging_pile") |
| | | private Integer chargingPile; |
| | | |
| | | @ApiModelProperty(value = "补充资料") |
| | | @TableField("further_information") |
| | | private String furtherInformation; |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | @TableField("remark") |
| | | private String remark; |
| | | private List<URL> urls; |
| | | } |
| | |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TOrderEvaluate; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.query.TChargingCountQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.dto.GetMyChargingOrderList; |
| | |
| | | @ResponseBody |
| | | @PostMapping(value = "/chargingOrder") |
| | | @ApiOperation(value = "充电桩订单列表", tags = {"管理后台-订单管理"}) |
| | | public AjaxResult<PageInfo<ChargingOrderVO>> chargingOrder(@RequestBody OrderEvaluateVo dto){ |
| | | return AjaxResult.success(); |
| | | public AjaxResult<PageInfo<ChargingOrderVO>> chargingOrder(@RequestBody ChargingOrderQuery dto){ |
| | | PageInfo<ChargingOrderVO> res = chargingOrderService.chargingOrder(dto); |
| | | return AjaxResult.success(res); |
| | | } |
| | | |
| | | |
| | |
| | | import com.ruoyi.order.dto.ExchangeOrderGoodsInfo; |
| | | import com.ruoyi.order.dto.GetMyExchangeOrder; |
| | | import com.ruoyi.order.dto.MyExchangeOrderList; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import com.ruoyi.order.service.TExchangeOrderService; |
| | | import com.ruoyi.order.service.TShoppingOrderService; |
| | | import com.ruoyi.order.service.TVipOrderService; |
| | | import com.ruoyi.other.api.dto.ExchangeDto; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.common.core.utils.OrderCodeUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | |
| | | |
| | | @PostMapping("/getById") |
| | | public R<Long> getById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId){ |
| | | public R<Long> getById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId,@RequestParam("goodType") Integer goodType){ |
| | | if (goodType==1){ |
| | | return R.ok(exchangeOrderService.lambdaQuery().eq(TExchangeOrder::getGoodsId,goodId).eq(TExchangeOrder::getAppUserId,userId).ne(TExchangeOrder::getStatus,4).count()); |
| | | }else { |
| | | return R.ok(exchangeOrderService.lambdaQuery().eq(TExchangeOrder::getCouponId,goodId).eq(TExchangeOrder::getAppUserId,userId).ne(TExchangeOrder::getStatus,4).count()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/create") |
| | | public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto){ |
| | | TExchangeOrder tExchangeOrder = new TExchangeOrder(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = "DH" + Math.random() * 1000 + sdf.format(new Date()); |
| | | tExchangeOrder.setCode(code); |
| | | tExchangeOrder.setCode(OrderCodeUtil.getOrderCode("DH")); |
| | | tExchangeOrder.setAppUserId(exchangeDto.getUserId()); |
| | | tExchangeOrder.setOrderType(0); |
| | | tExchangeOrder.setGoodsId(0); |
| | | tExchangeOrder.setCouponId(0); |
| | | tExchangeOrder.setPurchaseQuantity(0); |
| | | tExchangeOrder.setAppUserAddressId(0L); |
| | | tExchangeOrder.setPoints(0); |
| | | tExchangeOrder.setOrderType(exchangeDto.getGoodType()); |
| | | if (exchangeDto.getGoodType()==1) { |
| | | tExchangeOrder.setGoodsId(exchangeDto.getGoodId()); |
| | | }else { |
| | | tExchangeOrder.setCouponId(exchangeDto.getGoodId()); |
| | | } |
| | | tExchangeOrder.setPurchaseQuantity(1); |
| | | tExchangeOrder.setAppUserAddressId(Long.valueOf(exchangeDto.getAddressId())); |
| | | tExchangeOrder.setPoints(exchangeDto.getPoint()); |
| | | tExchangeOrder.setRemark(""); |
| | | if (exchangeDto.getGoodType()==1){ |
| | | tExchangeOrder.setStatus(0); |
| | | tExchangeOrder.setExpressCompany(""); |
| | | tExchangeOrder.setExpressNumber(""); |
| | | tExchangeOrder.setConsignerId(0); |
| | | tExchangeOrder.setConsignerTime(LocalDateTime.now()); |
| | | tExchangeOrder.setReceivingTime(LocalDateTime.now()); |
| | | tExchangeOrder.setCancellationTime(LocalDateTime.now()); |
| | | tExchangeOrder.setCancellationId(0); |
| | | }else { |
| | | tExchangeOrder.setStatus(3); |
| | | } |
| | | tExchangeOrder.setCreateTime(LocalDateTime.now()); |
| | | tExchangeOrder.setDelFlag(false); |
| | | exchangeOrderService.save(tExchangeOrder); |
| | | return R.ok(); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.order.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.dto.GetNoInvoicedOrder; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | */ |
| | | List<TChargingOrder> getNoInvoicedOrder(@Param("appUserId") Long appUserId, @Param("month") String month, |
| | | @Param("pageCurr") Integer pageCurr, @Param("pageSize") Integer pageSize); |
| | | |
| | | List<ChargingOrderVO> chargingOrder(@Param("pageInfo") PageInfo<ChargingOrderVO> pageInfo, ChargingOrderQuery dto, String startTime1, String startTime2, String endTime1, String endTime11); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.dto.*; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | AjaxResult stopCharging(String id); |
| | | |
| | | PageInfo<ChargingOrderVO> chargingOrder(ChargingOrderQuery dto); |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.dto.*; |
| | | import com.ruoyi.order.mapper.TChargingOrderMapper; |
| | | import com.ruoyi.order.service.TChargingOrderAccountingStrategyService; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.payment.api.feignClient.WxPaymentClient; |
| | | import com.ruoyi.payment.api.vo.NotifyV3PayDecodeRespBody; |
| | | import com.ruoyi.payment.api.vo.PaymentOrder; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | // todo 待完善 |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<ChargingOrderVO> chargingOrder(ChargingOrderQuery dto) { |
| | | String startTime1 = null; |
| | | String startTime2 = null; |
| | | String endTime1 = null; |
| | | String endTime2 = null; |
| | | |
| | | if (StringUtils.hasLength(dto.getStartTime())){ |
| | | String[] split = dto.getStartTime().split(" - "); |
| | | startTime1 = split[0]; |
| | | startTime2 = split[1]; |
| | | } |
| | | if (StringUtils.hasLength(dto.getEndTime())){ |
| | | String[] split = dto.getEndTime().split(" - "); |
| | | endTime1 = split[0]; |
| | | endTime2 = split[1]; |
| | | } |
| | | PageInfo<ChargingOrderVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<ChargingOrderVO> list = this.baseMapper.chargingOrder(pageInfo,dto,startTime1,startTime2,endTime1,endTime2); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.account.api.dto.GrantCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppCouponClient; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.Region; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | | import com.ruoyi.other.query.CouponQuery; |
| | | import com.ruoyi.other.service.IRegionService; |
| | | import com.ruoyi.other.service.TActivityService; |
| | | import com.ruoyi.other.service.TCouponService; |
| | | import com.ruoyi.other.service.TGoodsService; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | @ApiOperation(tags = {"管理后台-优惠券管理"},value = "发放优惠券") |
| | | @GetMapping(value = "/grantCoupon") |
| | | @PostMapping(value = "/grantCoupon") |
| | | public AjaxResult grantCoupon(@RequestBody GrantCouponDto dto) { |
| | | TCoupon byId = tCouponService.getById(dto.getCouponId()); |
| | | Integer waysToObtain = byId.getWaysToObtain(); |
| | |
| | | dto.setEndTime(LocalDateTime.now().plusDays(byId.getDays())); |
| | | break; |
| | | } |
| | | if (StringUtils.hasLength(dto.getProvinceCode())){ |
| | | for (String s : dto.getProvinceCode().split(",")) { |
| | | Region code = regionService.getOne(new QueryWrapper<Region>() |
| | | .eq("code", s)); |
| | | List<String> collect = regionService.list(new QueryWrapper<Region>() |
| | | .eq("parent_id", code.getId())).stream().map(Region::getCode).collect(Collectors.toList()); |
| | | StringBuilder temp = new StringBuilder(); |
| | | for (String string : collect) { |
| | | temp.append(string).append(","); |
| | | } |
| | | if (StringUtils.hasLength(dto.getCityCode())){ |
| | | String s1 = dto.getCityCode() + "," + temp; |
| | | // 去除最后一位字符 |
| | | dto.setCityCode(s1.substring(0, s1.length() - 1)); |
| | | }else{ |
| | | String substring = temp.substring(0, temp.length() - 1); |
| | | dto.setCityCode(substring); |
| | | } |
| | | } |
| | | |
| | | } |
| | | appCouponClient.grantCoupon(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(tags = {"管理后台-优惠券管理"},value = "优惠券列表分页查询") |
| | | @PostMapping(value = "/pageList") |
| | | public AjaxResult<PageInfo<TCoupon>> pageList(@RequestBody CouponQuery dto) { |
| | | return AjaxResult.ok(tCouponService.pageList(dto)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 小程序远程调用 获取优惠券信息 |
| | |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据id获取优惠券信息 |
| | | * @param id |
| | |
| | | TCoupon coupon = tCouponService.getById(id); |
| | | return R.ok(coupon); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.other.controller; |
| | | import java.time.LocalDateTime; |
| | | |
| | | |
| | | import com.ruoyi.account.api.dto.GrantCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppCouponClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | | import com.ruoyi.order.api.vo.ExchangeDto; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | | import com.ruoyi.other.service.TActivityService; |
| | | import com.ruoyi.other.service.TAdvertisingService; |
| | | import com.ruoyi.other.service.TCouponService; |
| | | import com.ruoyi.other.service.TGoodsService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private AppCouponClient appCouponClient; |
| | | @Resource |
| | | private TCouponService couponService; |
| | | |
| | | |
| | | |
| | |
| | | @ApiOperation(tags = {"小程序-兑换商城"},value = "兑换商品") |
| | | @PostMapping(value = "/app/shop") |
| | | public AjaxResult<PageInfo<TGoods>> shop(@RequestBody ExchangeDto exchangeDto) { |
| | | //查询当前商品信息 |
| | | TGoods good = goodsService.getById(exchangeDto.getGoodId()); |
| | | |
| | | //检查当前用户积分是否够 |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Integer point = 0; |
| | | |
| | | if (exchangeDto.getGoodType()==1) { |
| | | //查询当前商品信息 |
| | | TGoods good = goodsService.getById(exchangeDto.getGoodId()); |
| | | point = good.getRedeemPoints(); |
| | | //检查当前用户是否到达兑换上限 |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); |
| | | if (good.getLimitExchangeTimes() != -1 && count >= good.getLimitExchangeTimes()) { |
| | | return AjaxResult.error("当前用户已到达兑换上限"); |
| | | } |
| | | TAppUser user = appUserClient.getUserById(userId).getData(); |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | | } |
| | | //检查当前用户是否到达兑换上限 |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId).getData(); |
| | | if (good.getLimitExchangeTimes()!=-1&&count>=good.getLimitExchangeTimes()){ |
| | | }else { |
| | | TCoupon coupon = couponService.getById(exchangeDto.getGoodId()); |
| | | point = coupon.getRedeemPoints(); |
| | | |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换上限"); |
| | | } |
| | | } |
| | | exchangeDto.setPoint(point); |
| | | //生成积分兑换成功的订单 |
| | | // orderClient.exchangeCreate(exchangeDto); |
| | | |
| | | orderClient.exchangeCreate(exchangeDto); |
| | | if (exchangeDto.getGoodType()==2) { |
| | | //如果是优惠卷,赠送优惠卷给用户 |
| | | |
| | | |
| | | |
| | | |
| | | GrantCouponDto grantCouponDto = new GrantCouponDto(); |
| | | grantCouponDto.setUserIds(userId.toString()); |
| | | grantCouponDto.setCouponId(exchangeDto.getGoodId()); |
| | | grantCouponDto.setWaysToObtain(1); |
| | | grantCouponDto.setEndTime(LocalDateTime.now()); |
| | | appCouponClient.grantCoupon(grantCouponDto); |
| | | } |
| | | //生成消耗积分的记录 |
| | | |
| | | |
| | | |
| | | return AjaxResult.success(); |
| | | |
| | | |
| | |
| | | /** |
| | | * 根据id获取商品信息 |
| | | * @param id |
| | | * @return1 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getGoodsById/{id}") |
| | | public R<TGoods> getGoodsById(@PathVariable Integer id){ |