提交 86550cee 作者: 张小凤

payment(add)

上级 18b7ef67
......@@ -82,11 +82,16 @@
<artifactId>fastjson</artifactId>
<version>2.0.32</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
......
package com.mmc.payment.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
/**
* @Author small
* @Date 2023/5/25 17:45
* @Version 1.0
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时
factory.setConnectTimeout(15000);
factory.setReadTimeout(5000);
return factory;
}
}
......@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
@Api(tags = { "消耗-现金-接口" })
@RestController
@RequestMapping("/repocash/")
public class RepoCashController extends BaseController {
public class RepoCashController {
@Autowired
private RepoCashService repoCashService;
......@@ -44,20 +44,22 @@ public class RepoCashController extends BaseController {
return ResultBody.success();
}
@ApiOperation(value = "现金-充值")
@ApiOperation(value = "v1.0.1-NO现金-充值")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@RepeatSubmit
@PostMapping("reqCash")
public ResultBody reqCash(HttpServletRequest request, @RequestBody RepoCashVO param) {
return repoCashService.reqCash(this.getCurrentAccount(request), param);
return repoCashService.reqCash(null, param);
//repoCashService.reqCash(this.getCurrentAccount(request), param);
}
@ApiOperation(value = "现金-手动扣除")
@ApiOperation(value = "v1.0.1-NO现金-手动扣除")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@RepeatSubmit
@PostMapping("dedCash")
public ResultBody dedCash(HttpServletRequest request, @RequestBody RepoCashVO param) {
return repoCashService.dedCash(this.getCurrentAccount(request), param);
//repoCashService.dedCash(this.getCurrentAccount(request), param)
return repoCashService.dedCash(null, param);
}
@ApiOperation(value = "feign-查询退款金额")
......
package com.mmc.payment.dao;
import com.mmc.payment.entity.RepoCashDO;
import com.mmc.payment.entity.RepoWalletDO;
import com.mmc.payment.model.qo.RepoCashQO;
import org.apache.ibatis.annotations.Mapper;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -22,4 +24,8 @@ public interface RepoCashDao {
List<RepoCashDO> listPagePFRepoCash(RepoCashQO param);
int countPagePFRepoCash(RepoCashQO param);
RepoWalletDO getRepoWalletInfo(Integer repoAccountId);
void updateRepoWalletAmt(Integer repoAccountId, BigDecimal chageAmt);
}
package com.mmc.payment.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/5/25 17:50
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class UserAccountSimpleDTO implements Serializable {
private static final long serialVersionUID = 3451336520607073343L;
@ApiModelProperty(value = "用户id")
private Integer id;
@ApiModelProperty(value = "用户类型")
private Integer accountType;
@ApiModelProperty(value = "用户uid")
private String uid;
@ApiModelProperty(value = "手机号")
private String phoneNum;
@ApiModelProperty(value = "用户名称")
private String userName;
@ApiModelProperty(value = "用户昵称")
private String nickName;
@ApiModelProperty(value = "用户头像")
private String userImg;
@ApiModelProperty(value = "用户性别:0未知、1男、2女")
private Integer userSex;
@ApiModelProperty(value = "用户邮箱")
private String email;
@ApiModelProperty(value = "用户来源,0自然流、1海报、2抖音、3公众号、4社群、5招投标、6官网")
private Integer source;
@ApiModelProperty(value = "用户可用状态:0禁用、1可用")
private Integer accountStatus;
@ApiModelProperty(value = "账号类型:0后台管理账号 ; 100云享飞-客户端;")
private Integer portType;
@ApiModelProperty(value = "企业认证状态, 0未通过,1通过")
private Integer companyAuthStatus;
}
package com.mmc.payment.service.Impl;
import com.alibaba.fastjson.JSON;
import com.mmc.payment.common.*;
import com.mmc.payment.config.RepoCashMethod;
import com.mmc.payment.dao.RepoCashDao;
import com.mmc.payment.entity.RepoCashDO;
import com.mmc.payment.entity.RepoWalletDO;
import com.mmc.payment.model.dto.BaseAccountDTO;
import com.mmc.payment.model.dto.RepoAccountDTO;
import com.mmc.payment.model.dto.RepoCashDTO;
import com.mmc.payment.model.dto.UserAccountDTO;
import com.mmc.payment.model.dto.*;
import com.mmc.payment.model.qo.RepoCashQO;
import com.mmc.payment.model.qo.UserAccountQO;
import com.mmc.payment.model.vo.RepoCashVO;
import com.mmc.payment.service.RepoCashService;
import io.jsonwebtoken.lang.Collections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.util.ArrayList;
......@@ -35,6 +35,9 @@ public class RepoCashServiceImpl implements RepoCashService {
@Autowired
private RepoCashDao repoCashDao;
@Autowired
private RestTemplate restTemplate;
/* @Autowired
private RepoWalletDao repoWalletDao;*/
......@@ -64,7 +67,12 @@ public class RepoCashServiceImpl implements RepoCashService {
}).collect(Collectors.toList());
UserAccountQO uq = UserAccountQO.builder().userIds(userIds).build();
List<UserAccountDTO> users = null;
//userServletClient.feignListUserAccountById(uq);
// userServletClient.feignListUserAccountById(uq);
// 远程调用
ResponseEntity<String> response =
restTemplate.getForEntity("http://localhost:35150/userapp/user-account/feignGetUserSimpleInfo?userAccountId=1"+ userIds,String.class);
String body = response.getBody();
Map<Integer, UserAccountDTO> mapUser = users.stream()
.collect(Collectors.toMap(UserAccountDTO::getId, ud -> ud, (k1, k2) -> k2));
data.forEach(d -> {
......@@ -91,30 +99,33 @@ public class RepoCashServiceImpl implements RepoCashService {
// 密码认证
ResultBody body =null;
//userServletClient.feignAuthUserPwd(cuser.getId(), cash.getAuthPwd());
if (!ResultEnum.SUCCESS.getResultCode().equals(body.getCode())) {
/*if (!ResultEnum.SUCCESS.getResultCode().equals(body.getCode())) {
return body;
}
}*/
// 用户信息
RepoAccountDTO account = null;
//RepoAccountDTO account = null;
//repoServletClient.feignAccountSimpleInfo(cash.getRepoAccountId());
ResponseEntity<String> response =
restTemplate.getForEntity("http://localhost:35150/userapp/user-account/feignGetUserSimpleInfo?userAccountId=1",String.class);
String body1 = response.getBody();
UserAccountSimpleDTO account = JSON.parseObject(body1, UserAccountSimpleDTO.class);
if (account == null) {
return ResultBody.error(ResultEnum.FEIGN_REPOUSER_SERVLET_ERROR);
}
RepoWalletDO wallet = null;
//repoWalletDao.getRepoWalletInfo(cash.getRepoAccountId());
RepoWalletDO wallet = repoCashDao.getRepoWalletInfo(cash.getRepoAccountId());
if (wallet == null) {
return ResultBody.error(ResultEnum.WALLET_NOT_FIND_ERROR);
}
// 扣除的金额不能大于余额
// if (cash.getAmtPaid().compareTo(wallet.getCashAmt()) > 0) {
// return ResultBody.error(ResultEnum.WALLET_CASH_NOT_ENOUGH_ERROR);
// }
if (cash.getAmtPaid().compareTo(wallet.getCashAmt()) > 0) {
return ResultBody.error(ResultEnum.WALLET_CASH_NOT_ENOUGH_ERROR);
}
Date cdate = new Date();
RepoCashDO rc = new RepoCashDO();
rc.setRepoAccountId(account.getId());
rc.setUid(account.getUid());
rc.setAccountName(account.getAccountName());
rc.setAccountName(account.getUserName());
rc.setPayNo(CodeUtil.createRepoCashNo());
rc.setPayMethod(RepoCashMethod.REG.getCode());
rc.setAmtPaid(cash.getAmtPaid());
......@@ -125,9 +136,11 @@ public class RepoCashServiceImpl implements RepoCashService {
rc.setVoucher(voucher);
rc.setRemark(cash.getRemark());
rc.setCreateTime(cdate);
rc.setCreateUser(cuser.getId());
//rc.setCreateUser(cuser.getId());
rc.setCreateUser(1);
repoCashDao.insertRepoCash(rc);
// repoWalletDao.updateRepoWalletAmt(account.getId(), rc.getAmtPaid());
repoCashDao.updateRepoWalletAmt(account.getId(), rc.getAmtPaid());
return ResultBody.success();
}
......@@ -140,18 +153,22 @@ public class RepoCashServiceImpl implements RepoCashService {
// 密码认证
ResultBody body =null;
//userServletClient.feignAuthUserPwd(cuser.getId(), cash.getAuthPwd());
if (!ResultEnum.SUCCESS.getResultCode().equals(body.getCode())) {
/*if (!ResultEnum.SUCCESS.getResultCode().equals(body.getCode())) {
return body;
}
}*/
// 用户信息
RepoAccountDTO account =null;
// RepoAccountDTO account =null;
//repoServletClient.feignAccountSimpleInfo(cash.getRepoAccountId());
ResponseEntity<String> response =
restTemplate.getForEntity("http://localhost:35150/userapp/user-account/feignGetUserSimpleInfo?userAccountId=1",String.class);
String body1 = response.getBody();
UserAccountSimpleDTO account = JSON.parseObject(body1, UserAccountSimpleDTO.class);
if (account == null) {
return ResultBody.error(ResultEnum.FEIGN_REPOUSER_SERVLET_ERROR);
}
RepoWalletDO wallet =null;
//repoWalletDao.getRepoWalletInfo(cash.getRepoAccountId());
RepoWalletDO wallet =repoCashDao.getRepoWalletInfo(cash.getRepoAccountId());
if (wallet == null) {
return ResultBody.error(ResultEnum.WALLET_NOT_FIND_ERROR);
}
......@@ -163,7 +180,7 @@ public class RepoCashServiceImpl implements RepoCashService {
RepoCashDO rc = new RepoCashDO();
rc.setRepoAccountId(account.getId());
rc.setUid(account.getUid());
rc.setAccountName(account.getAccountName());
rc.setAccountName(account.getUserName());
rc.setPayNo(CodeUtil.createRepoCashNo());
rc.setPayMethod(RepoCashMethod.HANDLER.getCode());
rc.setAmtPaid(cash.getAmtPaid().multiply(BigDecimal.valueOf(-1)));
......@@ -175,9 +192,10 @@ public class RepoCashServiceImpl implements RepoCashService {
rc.setVoucher(voucher);
rc.setRemark(cash.getRemark());
rc.setCreateTime(cdate);
rc.setCreateUser(cuser.getId());
// rc.setCreateUser(cuser.getId());
rc.setCreateUser(1);
repoCashDao.insertRepoCash(rc);
//repoWalletDao.updateRepoWalletAmt(account.getId(), rc.getAmtPaid());
repoCashDao.updateRepoWalletAmt(account.getId(), rc.getAmtPaid());
return ResultBody.success();
}
......
......@@ -2,14 +2,14 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.default:3306/iuav_pms?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://mysql.default:3306/iuav_payment?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: tmj
password: MMC@2022&MYSQL
redis:
database: 3
database: 1
host: r-wz9ke310fs684hacn1pd.redis.rds.aliyuncs.com
port: 6379
password: MMC@2022&REDIS
port: 6379
jedis:
pool:
max-active: 2
......
......@@ -2,12 +2,12 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-wz9dd796t4j1giz6t2o.mysql.rds.aliyuncs.com:3306/iuav_pms?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-wz9dd796t4j1giz6t2o.mysql.rds.aliyuncs.com:3306/iuav_payment?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: tmj
password: MMC@2022&MYSQL
redis:
database: 3
host: r-wz9ke310fs684hacn1.redis.rds.aliyuncs.com
database: 1
host: r-wz9ke310fs684hacn1pd.redis.rds.aliyuncs.com
port: 6379
password: MMC@2022&REDIS
jedis:
......
......@@ -2,11 +2,11 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.default:3306/iuav_pms?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://mysql.default:3306/iuav_payment?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: tmj
password: MMC@2022&MYSQL
redis:
database: 3
database: 1
host: r-wz9ke310fs684hacn1pd.redis.rds.aliyuncs.com
port: 6379
password: MMC@2022&REDIS
......
......@@ -4,7 +4,20 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.payment.dao.RepoCashDao">
<resultMap id="repoWalletResultMap"
type="com.mmc.payment.entity.RepoWalletDO">
<id property="id" column="id" />
<result property="repoAccountId" column="repo_account_id" />
<result property="cashAmt" column="cash_amt" />
<result property="cashPaid" column="cash_paid" />
<result property="cashFreeze" column="cash_freeze" />
<result property="rcdRebateAmt" column="rcd_rebate_amt" />
<result property="rebateWdl" column="rebate_wdl" />
<result property="rebateFreeze" column="rebate_freeze" />
<result property="remark" column="remark" />
<result property="updateTime" column="create_time" />
<result property="createTime" column="update_time" />
</resultMap>
<resultMap id="repoCashResultMap"
type="com.mmc.payment.entity.RepoCashDO">
<id property="id" column="id" />
......@@ -123,4 +136,19 @@
</if>
</where>
</select>
<select id="getRepoWalletInfo" resultMap="repoWalletResultMap">
select
w.id,w.repo_account_id,w.cash_amt,w.cash_freeze,
w.cash_paid,w.rcd_rebate_amt,w.rebate_wdl,w.rebate_freeze,w.create_time,w.update_time
from repo_wallet w
where
w.repo_account_id = #{repoAccountId}
</select>
<update id="updateRepoWalletAmt">
update repo_wallet
set cash_amt = cash_amt + #{chageAmt}
where repo_account_id = #{repoAccountId}
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论