From 0ef46975993c06e780ec4981d7535167673aa51d Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期一, 25 八月 2025 10:39:58 +0800 Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/gy_jifenshangcheng into dev --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TIntegralController.java | 113 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 75 insertions(+), 38 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TIntegralController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TIntegralController.java index db89a16..ffcfde3 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TIntegralController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TIntegralController.java @@ -14,15 +14,13 @@ import com.ruoyi.other.api.domain.IntegralRecord; import com.ruoyi.other.api.domain.ServicePay; import com.ruoyi.other.api.domain.TIntegralRule; +import com.ruoyi.other.api.dto.NativePayDTO; import com.ruoyi.other.query.IntegralListQuery; import com.ruoyi.other.service.TIntegralPayService; import com.ruoyi.other.service.TIntegralRecordService; import com.ruoyi.other.service.TIntegralRuleService; import com.ruoyi.other.service.TServicePayService; -import com.ruoyi.other.util.MyQrCodeUtil; -import com.ruoyi.other.util.ObsUploadUtil; -import com.ruoyi.other.util.QRCodeUtil; -import com.ruoyi.other.util.UUIDUtil; +import com.ruoyi.other.util.*; import com.ruoyi.other.util.pay.CreateLinkStringByGet1; import com.ruoyi.other.util.pay.HttpRequester; import com.ruoyi.other.util.pay.HttpRespons; @@ -42,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.mock.web.MockMultipartFile; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -122,13 +121,25 @@ ServicePay one = servicePayService.lambdaQuery().eq(ServicePay::getPayStatus, 2) .eq(ServicePay::getUserId, userid).orderByDesc(ServicePay::getCreateTime) .last("limit 1").one(); - if (one!=null){ + ServicePay servicePayBefore = servicePayService.lambdaQuery() + .eq(ServicePay::getUserId, userid) + .eq(ServicePay::getPayStatus,2) + .eq(ServicePay::getDelFlag,0) + .orderByDesc(ServicePay::getCreateTime) + .last("limit 1") + .one(); + if (servicePayBefore==null){ workPlatformVO.setServiceStatus(1); - workPlatformVO.setEndTime(one.getEndTime()); + } else if (servicePayBefore.getEndTime().isBefore(LocalDateTime.now())) { + workPlatformVO.setServiceStatus(2); + workPlatformVO.setEndTime(servicePayBefore.getEndTime()); + }else{ - workPlatformVO.setServiceStatus(0); - workPlatformVO.setEndTime(null); + workPlatformVO.setServiceStatus(3); + workPlatformVO.setEndTime(servicePayBefore.getEndTime()); + } + return R.ok(workPlatformVO); @@ -146,7 +157,12 @@ integralVO.setIntegral(integral); return R.ok(integralVO); } - + @ApiOperation(tags = {"2.0-积分钱包"}, value = "获取积分充值比例") + @PostMapping(value = "/getPointPercent") + public R getPointPercent() { + SysConfig data1 = sysConfigClient.getInfo(8L).getData(); + return R.ok(data1.getConfigValue()); + } @ApiOperation(tags = {"2.0-积分钱包"}, value = "查询支付结果 true成功 false失败") @PostMapping(value = "/queryPayStatus") public R buy(@RequestParam Integer id) { @@ -157,15 +173,25 @@ return R.ok(false); } } - + @Resource + private WeChatUtil weChatUtil; @PostMapping("/nativePay") @ApiOperation(tags = {"2.0-积分钱包"}, value = "获取支付二维码") - public R nativePay(@RequestParam("amount") String amount) throws Exception { - BigDecimal bigDecimal = new BigDecimal(amount); - BigDecimal money = bigDecimal.setScale(2, RoundingMode.HALF_UP); - Long userid = tokenService.getLoginUser().getUserid(); - R<SysUser> sysUser = sysUserClient.getSysUser(userid); - SysUser data = sysUser.getData(); + public R nativePay(@RequestBody @Validated NativePayDTO dto) throws Exception { + + R<SysUser> sysUserR = sysUserClient.queryUserByPhone(dto.getPhone()); + SysUser data = sysUserR.getData(); + //使用jscode获取微信openid + Map<String, Object> map = weChatUtil.code2Session(dto.getJsCode()); + Integer errcode = Integer.valueOf(map.get("errcode").toString()); + if(0 != errcode){ + return R.fail(map.get("msg").toString()); + } + String openid = map.get("openid").toString(); + data.setOpenId(openid); + BigDecimal amount = dto.getAmount(); + BigDecimal money = amount.setScale(2, RoundingMode.HALF_UP); + List<Site> sites = siteClient.getSiteAll().getData(); Site site = sites.stream().filter(e -> e.getId().equals(data.getSiteId())).findFirst().orElse(null); if (site==null){ @@ -173,15 +199,19 @@ } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); - ServicePay servicePay = new ServicePay(); - servicePay.setUserId(data.getUserId()); - servicePay.setAmount(site.getAnnualServiceFee()); - servicePay.setCode(code); - servicePay.setPayStatus(1); - servicePay.setPayType(1); - servicePay.setDelFlag(0); - servicePay.setCreateTime(LocalDateTime.now()); - servicePayService.save(servicePay); + IntegralPay integralPay = new IntegralPay(); + integralPay.setUserId(data.getUserId()); + SysConfig data1 = sysConfigClient.getInfo(8L).getData(); + BigDecimal bigDecimal = amount.multiply(new BigDecimal(data1.getConfigValue())).setScale(2, RoundingMode.HALF_DOWN); + integralPay.setIntegralCount(bigDecimal.intValue()); + integralPay.setAmount(amount); + integralPay.setCode(code); + integralPay.setPayStatus(1); + integralPay.setDelFlag(0); + integralPay.setCreateTime(LocalDateTime.now()); + + + integralPayService.save(integralPay); // return wechatPayService.unifiedOrderApplet(servicePay.getId()+"",code, site.getAnnualServiceFee()+"", "服务费缴纳",data.getOpenId(), "/other/wx/serviceCallback"); @@ -264,6 +294,7 @@ } System.out.println("接收返回参数:" + response.toString()); + sysUserClient.updateSysUser(data); return R.ok(response.toString()); } @Autowired @@ -282,15 +313,19 @@ } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); - ServicePay servicePay = new ServicePay(); - servicePay.setUserId(data.getUserId()); - servicePay.setAmount(site.getAnnualServiceFee()); - servicePay.setCode(code); - servicePay.setPayStatus(1); - servicePay.setPayType(1); - servicePay.setDelFlag(0); - servicePay.setCreateTime(LocalDateTime.now()); - servicePayService.save(servicePay); + IntegralPay integralPay = new IntegralPay(); + integralPay.setUserId(data.getUserId()); + SysConfig data1 = sysConfigClient.getInfo(8L).getData(); + BigDecimal bigDecimal = amount.multiply(new BigDecimal(data1.getConfigValue())).setScale(2, RoundingMode.HALF_DOWN); + integralPay.setIntegralCount(bigDecimal.intValue()); + integralPay.setAmount(amount); + integralPay.setCode(code); + integralPay.setPayStatus(1); + integralPay.setDelFlag(0); + integralPay.setCreateTime(LocalDateTime.now()); + + + integralPayService.save(integralPay); // return wechatPayService.unifiedOrderApplet(servicePay.getId()+"",code, site.getAnnualServiceFee()+"", "服务费缴纳",data.getOpenId(), "/other/wx/serviceCallback"); @@ -513,17 +548,17 @@ Long userid = tokenService.getLoginUser().getUserid(); SysUser data = sysUserClient.getSysUser(userid).getData(); - if (data != null && data.getSiteId() != null) { + if (data != null ) { if (data.getRoleType() == 1) { // 平台 SysConfig data1 = sysConfigClient.getInfo(8L).getData(); sysConfigClient.update(data1); TIntegralRule tIntegralRule = new TIntegralRule(); - tIntegralRule.setChargeCredit(data1.getConfigValue()); + tIntegralRule.setChargeCredit("{\"num1\":"+data1.getConfigValue()+"}"); tIntegralRule.setContent(data1.getRemark()); tIntegralRule.setSiteId(0); return R.ok(tIntegralRule); - } else if (data.getRoleType() == 3){ + } else if (data.getRoleType() == 2){ TIntegralRule res = integralRuleService.lambdaQuery().eq(TIntegralRule::getSiteId, data.getSiteId()).one(); return R.ok(res); }else{ @@ -550,7 +585,9 @@ if (data.getRoleType() == 1) { SysConfig data1 = sysConfigClient.getInfo(8L).getData(); - data1.setConfigValue(dto.getChargeCredit()); + JSONObject jsonObject = JSONObject.parseObject(dto.getChargeCredit()); + Integer num1 = jsonObject.getInteger("num1"); + data1.setConfigValue(num1.toString()); data1.setRemark(dto.getContent()); sysConfigClient.update(data1); } else { -- Gitblit v1.7.1