diff --git a/src/main/java/com/sqx/config/SwaggerConfig.java b/src/main/java/com/sqx/config/SwaggerConfig.java index a9043dce..8cf4bfee 100644 --- a/src/main/java/com/sqx/config/SwaggerConfig.java +++ b/src/main/java/com/sqx/config/SwaggerConfig.java @@ -1,6 +1,7 @@ package com.sqx.config; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -21,9 +22,13 @@ import static com.google.common.collect.Lists.newArrayList; @EnableSwagger2 public class SwaggerConfig implements WebMvcConfigurer { + @Value("${swagger.enabled}") + private boolean enabled; + @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) + .enable(enabled) .apiInfo(apiInfo()) .select() //加了ApiOperation注解的类,才生成接口文档 diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java b/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java index 96895f23..19ff76ea 100644 --- a/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java +++ b/src/main/java/com/sqx/modules/app/controller/app/AppLoginController.java @@ -144,7 +144,7 @@ public class AppLoginController { @RequestMapping(value = "/registerCode", method = RequestMethod.POST) @ApiOperation("app或h5注册或登录") @ResponseBody -// @Debounce(interval = 2500, value = "phone") + @Debounce(interval = 2500, value = "#phone") public Result registerCode(@RequestParam String phone,String msg,String platform,Integer sysPhone, String password,String inviterCode,String wxId,String qdCode) { return userService.registerCode(phone,msg,platform,sysPhone,password,inviterCode,wxId,qdCode); diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java index 13bd79fb..ba435901 100644 --- a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java +++ b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java @@ -50,6 +50,8 @@ import com.sqx.modules.file.utils.Md5Utils; import com.sqx.modules.invite.service.InviteService; import com.sqx.modules.message.entity.MessageInfo; import com.sqx.modules.message.service.MessageService; +import com.sqx.modules.sys.entity.SysUserEntity; +import com.sqx.modules.sys.service.SysUserService; import com.sqx.modules.utils.HttpClientUtil; import com.sqx.modules.utils.InvitationCodeUtil; import com.sqx.modules.utils.MD5Util; @@ -110,6 +112,8 @@ public class UserServiceImpl extends ServiceImpl implements private CommonInfoService commonRepository; @Autowired private DiscSpinningService discSpinningService; + @Autowired + private SysUserService sysUserService; private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true); @Override @@ -896,12 +900,9 @@ public class UserServiceImpl extends ServiceImpl implements if (StringUtils.isEmpty(msg)) { return Result.error("验证码不能为空!"); } - Msg msg1 = null; - if (!"147258".equals(msg)) { - msg1 = msgDao.findByPhoneAndCode(phone, msg); - if (msg1 == null) { - return Result.error("验证码不正确!"); - } + Msg msg1 = msgDao.findByPhoneAndCode(phone, msg); + if (msg1 == null) { + return Result.error("验证码不正确!"); } userInfo = new UserEntity(); UserEntity userEntity = null; @@ -921,6 +922,11 @@ public class UserServiceImpl extends ServiceImpl implements } if (StringUtils.isEmpty(qdCode)) { qdCode = userEntity.getQdCode(); + } else { + SysUserEntity sysUserEntity = sysUserService.selectSysUserByQdCode(qdCode); + if (sysUserEntity == null) { + return Result.error("请使用正确的渠道码!"); + } } userInfo.setQdCode(qdCode); userInfo.setPhone(phone); diff --git a/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java b/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java new file mode 100644 index 00000000..179eeb96 --- /dev/null +++ b/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java @@ -0,0 +1,51 @@ +package com.sqx.modules.discSpinning.controller; + +import com.sqx.common.utils.Constant; +import com.sqx.common.utils.PageUtils; +import com.sqx.common.utils.Result; +import com.sqx.modules.pay.entity.CashOut; +import com.sqx.modules.pay.service.CashOutService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * 提现审核 + * + * @author tankaikai + * @since 2024-12-26 14:39 + */ +@RestController +@RequestMapping("/cashOutAudit") +@AllArgsConstructor +@Api(value = "提现审核", tags = {"提现审核"}) +public class CashOutController { + + @Resource + private CashOutService cashOutService; + + @GetMapping("/page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + }) + public Result page(@ApiIgnore @RequestParam Map params) { + PageUtils page = cashOutService.auditPage(params); + return Result.success().put("page", page); + } + + @PostMapping("/audit") + @ApiOperation("审核") + public Result audit(@RequestBody CashOut cashOut) { + cashOutService.audit(cashOut); + return Result.success(); + } +} diff --git a/src/main/java/com/sqx/modules/pay/entity/CashOut.java b/src/main/java/com/sqx/modules/pay/entity/CashOut.java index 47e81002..3c45ed65 100644 --- a/src/main/java/com/sqx/modules/pay/entity/CashOut.java +++ b/src/main/java/com/sqx/modules/pay/entity/CashOut.java @@ -74,7 +74,7 @@ public class CashOut implements Serializable { private String orderNumber; /** - * 状态 0待转账 1成功 -1退款 2失败 + * 状态 0待转账 1成功 -1退款 2失败 3-待人工审核 */ private Integer state; @@ -107,4 +107,9 @@ public class CashOut implements Serializable { @TableField(exist = false) private String sysUserName; + /** + * 是否同意提现 0不同意 1同意 + */ + @TableField(exist = false) + private Integer isAgree; } diff --git a/src/main/java/com/sqx/modules/pay/service/CashOutService.java b/src/main/java/com/sqx/modules/pay/service/CashOutService.java index 03898cd0..ef2ad8bb 100644 --- a/src/main/java/com/sqx/modules/pay/service/CashOutService.java +++ b/src/main/java/com/sqx/modules/pay/service/CashOutService.java @@ -9,6 +9,7 @@ import com.sqx.modules.utils.excel.ExcelData; import java.util.Date; import java.util.List; +import java.util.Map; public interface CashOutService { @@ -49,4 +50,13 @@ public interface CashOutService { */ Result withdraw(Long userId, Double money, String msg, boolean isSys); + /** + * 提现审核分页查询 + * + * @param params + * @return + */ + PageUtils auditPage(Map params); + + void audit(CashOut cashOut); } diff --git a/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java index e65d3980..92111d31 100644 --- a/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java +++ b/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java @@ -1,10 +1,15 @@ package com.sqx.modules.pay.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapProxy; import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.exception.SqxException; +import com.sqx.common.utils.Constant; import com.sqx.common.utils.PageUtils; import com.sqx.common.utils.Result; import com.sqx.modules.app.dao.MsgDao; @@ -17,7 +22,6 @@ import com.sqx.modules.app.service.UserMoneyService; import com.sqx.modules.app.service.UserService; import com.sqx.modules.common.entity.CommonInfo; import com.sqx.modules.common.service.CommonInfoService; -import com.sqx.modules.course.entity.CourseCollect; import com.sqx.modules.invite.entity.InviteMoney; import com.sqx.modules.invite.service.InviteMoneyService; import com.sqx.modules.message.dao.MessageInfoDao; @@ -45,10 +49,7 @@ import weixin.popular.support.TokenManager; import javax.websocket.SendResult; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; +import java.util.*; /** * 提现申请记录 @@ -511,4 +512,75 @@ public class CashOutServiceImpl extends ServiceImpl impleme return Result.success("提现成功,将在三个工作日内到账,请耐心等待!"); } + @Override + public PageUtils auditPage(Map params) { + MapProxy proxy = MapProxy.create(params); + CashOut cashOut = BeanUtil.toBean(params, CashOut.class); + //cashOut.setState(3); + long pageNum = proxy.getLong(Constant.PAGE, 1L); + long pageSize = proxy.getLong(Constant.LIMIT, 10L); + IPage page = baseMapper.selectCashOutPage(new Page<>(pageNum, pageSize), cashOut); + return new PageUtils(page); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void audit(CashOut cashOut) { + long id = cashOut.getId(); + Integer isAgree = cashOut.getIsAgree(); + if (isAgree == null) { + throw new SqxException("请选择同意或者拒绝!"); + } + if (isAgree == 0 && StrUtil.isBlank(cashOut.getRefund())) { + throw new SqxException("请输入拒绝原因!"); + } + CashOut entity = baseMapper.selectById(id); + if (entity == null) { + throw new SqxException("提现申请不存在!"); + } + if(entity.getState() != 3){ + throw new SqxException("提现申请状态无效,请刷新后重试!"); + } + if (isAgree == 1) { + entity.setState(0); + } else { + entity.setState(2); + entity.setRefund(cashOut.getRefund()); + } + UserEntity userEntity = userService.selectUserById(entity.getUserId()); + if(userEntity == null){ + throw new SqxException("提现用户信息不存在!"); + } + if (isAgree == 0) { + baseMapper.updateById(entity); + UserMoneyDetails userMoneyDetails = new UserMoneyDetails( + entity.getUserId(), null, null, "[提现退款]", 4, 1, 2, + new BigDecimal(entity.getMoney()), "提现失败,自动退款" + entity.getMoney() + "元", 1); + userMoneyDetailsService.save(userMoneyDetails); + //归还余额 钱 + userMoneyService.updateAmount(1, entity.getUserId(), Convert.toDouble(entity.getMoney())); + return; + } + if (StrUtil.isBlank(entity.getOrderNumber())) { + String outOrderNo = AliPayOrderUtil.createOrderId(); + entity.setOrderNumber(outOrderNo); + } + // 执行提现操作 + BaseResp baseResp = WuyouPay.extractOrder(entity.getOrderNumber(), entity.getMoney(), entity.getZhifubao(), entity.getZhifubaoName()); + if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) { + entity.setState(1); + } else if (StringUtils.isNotBlank(baseResp.getErrorMsg())) { + entity.setState(2); + if (baseResp.getErrorMsg().contains("收款人账户号出款属性不匹配")) { + entity.setRefund("提现失败,请检查支付宝账号与收款人姓名后,重试。"); + } else { + entity.setRefund(baseResp.getErrorMsg()); + } + } else if (StringUtils.isNotBlank(baseResp.getMsg())) { + entity.setState(2); + entity.setRefund("提现失败,请检查支付宝账号与收款人姓名后,重试。"); + } + baseMapper.updateById(entity); + } + } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 778396ae..75158203 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -33,7 +33,8 @@ spring: config: multi-statement-allow: true - +swagger: + enabled: true pay: h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId= orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 281bcec6..6e735fc3 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -32,7 +32,8 @@ spring: wall: config: multi-statement-allow: true - +swagger: + enabled: false pay: h5BaseUrl: https://dj-h5.hnsiyao.cn/me/detail/detail?allId= orderNotifyUrl: https://dj-api.hnsiyao.cn/czg/app/wuyou/notify