提交 ba450561 作者: 张小凤

payment(add)

上级 7257442b
......@@ -19,11 +19,6 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
......@@ -76,22 +71,12 @@
<version>3.0.0</version>
<!--<scope>compile</scope>-->
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<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.common;
import com.alibaba.fastjson.JSONObject;
import com.mmc.payment.config.AuthHandler;
import com.mmc.payment.exception.BizException;
import com.mmc.payment.jwt.JwtConstant;
import com.mmc.payment.model.dto.BaseAccountDTO;
import com.mmc.payment.model.dto.CurrentUserDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import javax.servlet.http.HttpServletRequest;
......@@ -18,6 +22,8 @@ public abstract class BaseController {
@Autowired
private AuthHandler authHandler;
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 获取当前用户
*
......@@ -35,7 +41,12 @@ public abstract class BaseController {
* 获取当前登录账号信息
*/
public BaseAccountDTO getCurrentAccount(HttpServletRequest request) {
String token = request.getHeader(JwtConstant.TOKENKEY);
return authHandler.getCurrentAccount(token);
String token = request.getHeader("token");
String json = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(json)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
}
BaseAccountDTO baseAccountDTO= JSONObject.parseObject(json, BaseAccountDTO.class);
return baseAccountDTO;
}
}
......@@ -395,7 +395,9 @@ public enum ResultEnum implements BaseErrorInfoInterface {
HELP_FAIL_ERROR("2009", "不能给自己助力哦!"),
ALREADY_BINDING_ERROR("2010", "优惠券已被绑定"),
ALREADY_DIVIDE_ERROR("2011", "订单已分成"),
DIVIDE_OBJ_NOT_EXIST("2012", "先点击确认添加分成对象");
DIVIDE_OBJ_NOT_EXIST("2012", "先点击确认添加分成对象"),
THE_REQUEST_IS_NOT_AUTHENTICATED("2013","请求未经过鉴权"),
THE_TOKEN_IS_INVALID("2014","token失效") ;;
/**
* 错误码
......
package com.mmc.payment.common;
import lombok.Data;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/5/29 10:38
* @Version 1.0
*/
@Data
public class Tenant implements Serializable {
/**
* 用户id
*/
private Integer userId;
/**
* 所在机构id
*/
private Integer tenantId;
/**
* 用户名称
*/
private String userName;
/**
* 管理机构id集合
*/
private String tenantIds;
/**
* 菜单路由路径集合
*/
private String token;
/**
* 角色id
*/
private Integer roleId;
/**
* 角色类型,1超管 2其他角色
*/
private Integer roleType;
public Tenant(String userName) {
this.userId = userId;
this.tenantId = tenantId;
this.userName = userName;
this.tenantIds = tenantIds;
this.token = token;
this.roleId = roleId;
this.roleType = roleType;
}
/**
* userid相同,认为是同个用户
*
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof Tenant) {
Tenant tenant = (Tenant) o;
return getUserId().equals(tenant.getUserId());
} else {
return false;
}
}
@Override
public int hashCode() {
int result = 17;
result = 31 * result + getUserId().hashCode();
return result;
}
}
package com.mmc.payment.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @Author small
* @Date 2023/5/29 10:39
* @Version 1.0
*/
@Data
@ConfigurationProperties(prefix = "audience")
@Component
public class Audience {
private String clientId;
private String base64Secret;
private String name;
private long expiresSecond;
}
package com.mmc.payment.config;
import com.mmc.payment.common.Tenant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
/**
* @Author small
* @Date 2023/5/29 10:38
* @Version 1.0
*/
@Slf4j
public class TenantContext {
private static ThreadLocal<Tenant> tenantHolder = new ThreadLocal<>();
public static void setTenant(Tenant tenant) {
tenantHolder.set(tenant);
}
public static Tenant getTenant() {
return tenantHolder.get();
}
public static Integer getUserId() {
return getTenant().getUserId();
}
public static Integer getTenantId() {
return getTenant().getTenantId();
}
public static Integer getRoleId() {
return getTenant().getRoleId();
}
public static boolean exists() {
return getTenant() != null;
}
public static void clear() {
tenantHolder.remove();
}
public static Tenant buildTenant( String accountNo ) {
if (StringUtils.isBlank(accountNo)) {
log.error("登录信息[accountNo]获取异常");
return null;
}
return new Tenant(accountNo);
}
/**
* valid tenantId is correct
*/
private static boolean validNumeric(String number) {
return StringUtils.isNotEmpty(number) && StringUtils.isNumeric(number);
}
}
......@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
......@@ -21,72 +22,77 @@ import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
/**
* @Author small
* @Date 2023/5/24 9:53
* @Version 1.0
* @Author small @Date 2023/5/24 9:53 @Version 1.0
*/
@Api(tags = { "消耗-现金-接口" })
@Api(tags = {"现金管理"})
@RestController
@RequestMapping("/repocash/")
public class RepoCashController {
public class RepoCashController extends BaseController {
@Autowired
private RepoCashService repoCashService;
@Autowired private RepoCashService repoCashService;
@Autowired private StringRedisTemplate stringRedisTemplate;
@ApiOperation(value = "支付订单-充值扣款")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = PayCashResultDTO.class) })
@ApiIgnore
@PostMapping("PayCashOrder")
public PayCashResultDTO feignPayCashOrder(@RequestBody RepoOrderPayVO orderPay) {
return repoCashService.payCashOrder(orderPay);
}
@ApiOperation(value = "web-订单支付")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = PayCashResultDTO.class)})
@PostMapping("orderPayment")
public PayCashResultDTO orderPayment(HttpServletRequest request, @RequestParam String orderNo) {
return repoCashService.orderPayment(this.getCurrentAccount(request), orderNo);
}
@ApiIgnore
@ApiOperation(value = "当前用户剩余的余额")
@GetMapping("RemainingBalance")
public BigDecimal RemainingBalance(@RequestParam(value = "repoAccountId",required = true) Integer repoAccountId) {
return repoCashService.RemainingBalance(repoAccountId);
}
@ApiOperation(value = "支付订单-充值扣款")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = PayCashResultDTO.class)})
@ApiIgnore
@PostMapping("PayCashOrder")
public PayCashResultDTO feignPayCashOrder(@RequestBody RepoOrderPayVO orderPay) {
return repoCashService.payCashOrder(orderPay);
}
@ApiOperation(value = "余额变更-分页-列表")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = RepoCashDTO.class) })
@PostMapping("listPageCash")
public ResultBody listPageCash(@RequestBody RepoCashQO param) {
return ResultBody.success(repoCashService.listPageRepoCash(param));
}
@ApiOperation(value = "当前用户剩余的余额")
@GetMapping("RemainingBalance")
public BigDecimal RemainingBalance(
@RequestParam(value = "repoAccountId", required = true) Integer repoAccountId) {
@ApiOperation(value = "余额变更-修改备注")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("updateCashRemark")
public ResultBody updateCashRemark(@RequestParam Integer id, @RequestParam() String remark) {
repoCashService.updateCashRemark(id, remark);
return ResultBody.success();
}
String s = stringRedisTemplate.opsForValue().get("R2023052814538712");
return repoCashService.RemainingBalance(repoAccountId);
}
@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(null, param);
//repoCashService.reqCash(this.getCurrentAccount(request), param);
}
@ApiOperation(value = "余额变更-分页-列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = RepoCashDTO.class)})
@PostMapping("listPageCash")
public ResultBody listPageCash(@RequestBody RepoCashQO param) {
return ResultBody.success(repoCashService.listPageRepoCash(param));
}
@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) {
//repoCashService.dedCash(this.getCurrentAccount(request), param)
return repoCashService.dedCash(null, param);
}
@ApiOperation(value = "余额变更-修改备注")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("updateCashRemark")
public ResultBody updateCashRemark(@RequestParam Integer id, @RequestParam() String remark) {
repoCashService.updateCashRemark(id, remark);
return ResultBody.success();
}
@ApiOperation(value = "feign-查询退款金额")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = RepoCashDTO.class) })
@GetMapping("feignRefundInfo")
public RepoCashDTO feignRefundInfo(@RequestParam String refundNo) {
return repoCashService.getRefundInfo(refundNo);
}
@ApiOperation(value = "v1.0.1Yes-现金-充值")
@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);
}
@ApiOperation(value = "v1.0.1-Yes现金-手动扣除")
@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);
}
@ApiIgnore
@ApiOperation(value = "查询退款金额")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = RepoCashDTO.class)})
@GetMapping("feignRefundInfo")
public RepoCashDTO feignRefundInfo(@RequestParam String refundNo) {
return repoCashService.getRefundInfo(refundNo);
}
}
......@@ -9,27 +9,27 @@ import java.math.BigDecimal;
import java.util.List;
/**
* @Author small
* @Date 2023/5/24 10:10
* @Version 1.0
* @Author small @Date 2023/5/24 10:10 @Version 1.0
*/
@Mapper
public interface RepoCashDao {
RepoCashDO getRefundCashInfo(String refundNo);
RepoCashDO getRefundCashInfo(String refundNo);
void insertRepoCash(RepoCashDO rc);
void insertRepoCash(RepoCashDO rc);
void updateCashRemark(Integer id, String remark);
void updateCashRemark(Integer id, String remark);
List<RepoCashDO> listPagePFRepoCash(RepoCashQO param);
List<RepoCashDO> listPagePFRepoCash(RepoCashQO param);
int countPagePFRepoCash(RepoCashQO param);
int countPagePFRepoCash(RepoCashQO param);
RepoWalletDO getRepoWalletInfo(Integer repoAccountId);
RepoWalletDO getRepoWalletInfo(Integer repoAccountId);
void updateRepoWalletAmt(Integer repoAccountId, BigDecimal chageAmt);
void updateRepoWalletAmt(Integer repoAccountId, BigDecimal chageAmt);
BigDecimal RemainingBalance(Integer repoAccountId);
BigDecimal RemainingBalance(Integer repoAccountId);
void updateWalletAmt(Integer repoAccountId, BigDecimal addAmt, BigDecimal addPaid);
void updateWalletAmt(Integer repoAccountId, BigDecimal addAmt, BigDecimal addPaid);
void orderPayment(RepoCashDO repoCashDO);
}
package com.mmc.payment.entity;
import com.mmc.payment.model.dto.KdnExpDTO;
import com.mmc.payment.model.dto.OrderReceiptDTO;
import com.mmc.payment.model.dto.OrderRefundDTO;
import com.mmc.payment.model.dto.OrderVcuDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Author small @Date 2023/5/29 13:55 @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
// @ApiModel(value = "com.mmc.csf.model.dto.OrderInfoDTO", description = "云仓订单DTO")
public class OrderInfoDO implements Serializable {
private static final long serialVersionUID = 1572467108563651846L;
@ApiModelProperty(value = "ID")
private Integer id;
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "商品ID")
private Integer wareInfoId;
@ApiModelProperty(value = "商品编号")
private String wareNo;
@ApiModelProperty(value = "商品标题")
private String wareTitle;
@ApiModelProperty(value = "商品图片")
private String wareImg;
@ApiModelProperty(value = "套餐(sku)ID")
private Integer skuInfoId;
@ApiModelProperty(value = "套餐(sku)名称")
private String skuTitle;
@ApiModelProperty(value = "购买用户ID")
private Integer repoAccountId;
@ApiModelProperty(value = "用户UID")
private String uid;
@ApiModelProperty(value = "买家name")
private String buyerName;
@ApiModelProperty(value = "买家电话")
private String buyerPhone;
@ApiModelProperty(value = "单价")
private BigDecimal unitPrice;
@ApiModelProperty(value = "购买的商品数量")
private Integer wareNum;
@ApiModelProperty(value = "应付款金额")
private BigDecimal shouldPay;
@ApiModelProperty(value = "实收款金额")
private BigDecimal actualPay;
@ApiModelProperty(value = "订单类型:0租赁 100购买")
private Integer orderType;
@ApiModelProperty(value = "押金")
private BigDecimal deposit;
@ApiModelProperty(value = "租金总金额")
private BigDecimal rentPrice;
@ApiModelProperty(value = "租约开始日")
private Date startDate;
@ApiModelProperty(value = "租约结束日")
private Date endDate;
@ApiModelProperty(value = "付款天数")
private Integer payDay;
@ApiModelProperty(value = "交易状态:查订单状态字典")
private String tranStatus;
@ApiModelProperty(value = "减库方式 0:买家拍下减库存 1:卖家付款减库存")
private Integer exWare;
@ApiModelProperty(value = "用户备注")
private String remark;
@ApiModelProperty(value = "平台人员备注")
private String pfRemark;
@ApiModelProperty(value = "关闭原因")
private String shutReason;
@ApiModelProperty(value = "交易编号")
private String payNo;
@ApiModelProperty(value = "支付时间")
private Date payTime;
@ApiModelProperty(value = "发货时间")
private Date sendWareTime;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "物流信息/收货地址信息")
private OrderReceiptDTO receipt;
@ApiModelProperty(value = "退款单详情信息,无则为null")
private OrderRefundDTO orderRefund;
@ApiModelProperty(value = "发货-物流动态,无则为null")
private KdnExpDTO express;
@ApiModelProperty(value = "退货-物流动态,无则为null")
private KdnExpDTO refundExpress;
@ApiModelProperty(value = "质检详情,无则为null")
private List<OrderVcuDTO> vcus;
@ApiModelProperty(value = "归还时间")
private Date returnTime;
@ApiModelProperty(value = "优惠券id", example = "221")
private Integer couponId;
@ApiModelProperty(value = "规格id", example = "1")
private Integer specsId;
@ApiModelProperty(value = "余额", example = "4")
private BigDecimal balance;
}
package com.mmc.payment.filter;
/**
* @Author small
* @Date 2023/5/29 10:36
* @Version 1.0
*/
import javax.servlet.Filter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** 登录认证 */
public interface AuthFilter extends Filter {
/** 拦截前 */
public boolean before(HttpServletRequest request, HttpServletResponse response);
/** 通过拦截后 */
public boolean after();
}
package com.mmc.payment.filter;
import com.alibaba.fastjson2.JSON;
import com.mmc.payment.common.ResultBody;
import com.mmc.payment.common.ResultEnum;
import com.mmc.payment.common.Tenant;
import com.mmc.payment.config.Audience;
import com.mmc.payment.config.TenantContext;
import com.mmc.payment.model.dto.UserAccountDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @Author small
* @Date 2023/5/29 10:36
* @Version 1.0
*/
@Slf4j
@Component
@WebFilter(filterName = "AuthSignatureFilter", urlPatterns = "/*")
public class AuthSignatureFilter implements AuthFilter {
@Autowired
private Audience audience;
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 无需登录白名单
*/
private static final String[] IGNORE_URLS = {"/payment/swagger/swagger-resources","/payment/swagger/v2/api-docs","/payment/swagger/doc.html"};
/*无需加密狗无需登录白名单*/
private static final String[] USE_KEY = {"/crm/account/loginByUsbKey"};
/**
* 请求方式预请求方式值
*/
private static final String REQUEST_METHOD_OPTIONS_VALUE = "OPTIONS";
public static final String SWAGGER_URL_PREFIX = "/payment/swagger";
@Override
public void init(FilterConfig filterConfig) {
log.info(" filter name is 'AuthSignatureFilter' init success");
}
/**
* 过滤器前置处理
*
* @param request
* @param response
* @return
*/
@Override
public boolean before(HttpServletRequest request, HttpServletResponse response) {
String url = request.getRequestURI();
// 忽略以下url请求,白名单路径以及swagger路径
if (!ArrayUtils.contains(IGNORE_URLS, url)
&& !ArrayUtils.contains(USE_KEY, url) && !url.startsWith("/payment/webjars") && !url.startsWith(SWAGGER_URL_PREFIX)) {
if (REQUEST_METHOD_OPTIONS_VALUE.equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
return false;
} else {
String token = request.getHeader("token");
if (null==token){
response(response, ResultBody.error(ResultEnum.THE_REQUEST_IS_NOT_AUTHENTICATED));
return false;
}
String s = stringRedisTemplate.opsForValue().get(token);
if (null==s){
response(response,ResultBody.error(ResultEnum.THE_TOKEN_IS_INVALID));
return false;
}
UserAccountDTO userAccountDTO = JSON.parseObject(s, UserAccountDTO.class);
try {
Tenant tenant = TenantContext.buildTenant(userAccountDTO.getAccountNo());
if (tenant!=null){
TenantContext.setTenant(tenant);
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return true;
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
final HttpServletRequest request = (HttpServletRequest) req;
final HttpServletResponse response = (HttpServletResponse) res;
if (!before(request, response)) {
return;
}
chain.doFilter(req, res);
after();
}
/**
* 过滤器后置处理
*
* @return
*/
@Override
public boolean after() {
TenantContext.clear(); // 上下文清理
return true;
}
private static final String APPLICATION_JSON_UTF8 = "application/json;charset=UTF-8";
public static void response(HttpServletResponse response, ResultBody resultBody) {
response.setContentType(APPLICATION_JSON_UTF8);
try {
response
.getWriter()
.write(JSON.toJSONString(ResultBody.error(resultBody.getCode(), resultBody.getMessage())));
} catch (IOException e) {
log.error(e.getMessage());
}
}
private static String toString(Object obj) {
if (null == obj) {
return "";
}
return obj.toString();
}
@Override
public void destroy() {
}
}
package com.mmc.payment.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -10,59 +9,34 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/5/23 19:15
* @Version 1.0
* @Author small @Date 2023/5/23 19:15 @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.dto.BaseAccountDTO", description = "登录信息DTO")
// @ApiModel(value = "com.mmc.csf.model.dto.BaseAccountDTO", description = "登录信息DTO")
public class BaseAccountDTO implements Serializable {
private static final long serialVersionUID = -2979712090903806216L;
private Integer id;
private String uid;
private String accountPhone;
private String accountNo;
private String accountName;
private String tokenPort;
@ApiModelProperty(value = "角色ID")
private Integer roleId;
@ApiModelProperty(value = "是否为管理角色:0否 1是")
private Integer admin;// 是否为管理角色
@ApiModelProperty(value = "是否为运营角色:0否 1是")
private Integer operate;
@ApiModelProperty(value = "是否PMC发货专员:0否 1是")
private Integer pmc;
@ApiModelProperty(value = "单位信息")
private CompanyCacheDTO companyInfo;// 单位信息
private static final long serialVersionUID = -2979712090903806216L;
@ApiModelProperty(value = "token")
private String token;
@ApiModelProperty(value = "账号id")
private Integer userAccountId;
public BaseAccountDTO(RepoAccountDTO account) {
this.id = account.getId();
this.accountName = account.getAccountName();
this.uid = account.getUid();
this.accountPhone = account.getPhoneNum();
}
@ApiModelProperty(value = "账号")
private String accountNo;
@ApiModelProperty(value = "账号uid")
private String uid;
@ApiModelProperty(value = "手机号")
private String phoneNum;
/**
* 是否为科比特超级管理员单位(是:无单位资源限制 否:只能看当前和下级单位的资源)
* @return
*/
public boolean isManage() {
if(this.getCompanyInfo()==null){
return false;
}
if(this.getCompanyInfo().getManage()==null){
return false;
}
return this.getCompanyInfo().getManage() == 1;
}
@ApiModelProperty(value = "用户名称")
private String userName;
@ApiModelProperty(value = "用户昵称")
private String nickName;
}
......@@ -3,7 +3,6 @@ package com.mmc.payment.model.vo;
import com.mmc.payment.common.Create;
import com.mmc.payment.common.Refund;
import com.mmc.payment.common.Share;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -16,34 +15,49 @@ import java.math.BigDecimal;
import java.util.List;
/**
* @Author small
* @Date 2023/5/24 10:04
* @Version 1.0
* @Author small @Date 2023/5/24 10:04 @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.vo.RepoCashVO", description = "现金变更VO")
// @ApiModel(value = "com.mmc.csf.model.vo.RepoCashVO", description = "现金变更VO")
public class RepoCashVO implements Serializable {
private static final long serialVersionUID = 1828354753495845609L;
@ApiModelProperty(value = "用户ID")
@NotNull(message = "用户ID不能为空", groups = { Create.class })
private Integer repoAccountId;
@ApiModelProperty(value = "订单ID")
@NotNull(message = "orderRefundId不能为空", groups = { Refund.class })
private Integer orderRefundId;
@ApiModelProperty(value = "返租订单ID")
@NotNull(message = "shareOrderId不能为空", groups = { Share.class })
private Integer shareOrderId;
@ApiModelProperty(value = "变动金额")
@NotNull(message = "变动金额不能为空", groups = { Create.class, Refund.class })
private BigDecimal amtPaid;
@ApiModelProperty(value = "凭证图片集合")
private List<String> voucher;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "操作人员密码")
@NotNull(message = "变动金额不能为空", groups = { Refund.class, Share.class })
private String authPwd;
private static final long serialVersionUID = 1828354753495845609L;
/* @ApiModelProperty(value = "用户ID")
@NotNull(
message = "用户ID不能为空",
groups = {Create.class})
private Integer repoAccountId;*/
/* @ApiModelProperty(value = "订单ID")
@NotNull(
message = "orderRefundId不能为空",
groups = {Refund.class})
private Integer orderRefundId;
@ApiModelProperty(value = "返租订单ID")
@NotNull(
message = "shareOrderId不能为空",
groups = {Share.class})
private Integer shareOrderId;*/
@ApiModelProperty(value = "变动金额")
@NotNull(
message = "变动金额不能为空",
groups = {Create.class, Refund.class})
private BigDecimal amtPaid;
@ApiModelProperty(value = "凭证图片集合")
private List<String> voucher;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "操作人员密码")
@NotNull(
message = "变动金额不能为空",
groups = {Refund.class, Share.class})
private String authPwd;
}
......@@ -17,54 +17,60 @@ import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author small
* @Date 2023/5/23 19:12
* @Version 1.0
* @Author small @Date 2023/5/23 19:12 @Version 1.0
*/
@Service
public class RepoAccountServiceImpl implements RepoAccountService {
@Autowired
private RepoAccountDao repoAccountDao;
@Override
public PageResult listPagePayManager(RepoAccountQO param, BaseAccountDTO cuser) {
if(!cuser.isManage()){
param.setCompanys(cuser.getCompanyInfo().getCompanys());
}
int count = repoAccountDao.countPagePayManager(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<RepoAccountDTO> data = repoAccountDao.listPagePayManager(param).stream().map(d -> {
d.buildName();
return d.buildRepoAccountDTO();
}).collect(Collectors.toList());
List<Integer> accountIds = data.stream().map(RepoAccountDTO::getId).collect(Collectors.toList());
param.setAccountIds(accountIds);
// List<RepoWalletDTO> wallets = repoPayServletClient.feignListWalletInfo(param);
List<RepoWalletDTO> wallets = listWalletInfo(param);
Map<Integer, RepoWalletDTO> mapWallet = wallets.stream()
.collect(Collectors.toMap(RepoWalletDTO::getRepoAccountId, wallet -> wallet, (k1, k2) -> k2));
for (RepoAccountDTO ac : data) {
if (mapWallet.containsKey(ac.getId())) {
ac.setCashAmt(mapWallet.get(ac.getId()).getCashAmt());
ac.setRemark(mapWallet.get(ac.getId()).getRemark());
}
}
return PageResult.buildPage(pageNo, param.getPageSize(), count, data);
}
@Autowired private RepoAccountDao repoAccountDao;
public List<RepoWalletDTO> listWalletInfo(RepoAccountQO param) {
if (CollectionUtils.isEmpty(param.getAccountIds())) {
return java.util.Collections.emptyList();
}
List<RepoWalletDO> wallets = repoAccountDao.listWalletInfo(param);
return wallets.stream().map(d -> {
return d.buildRepoWalletDTO();
}).collect(Collectors.toList());
@Override
public PageResult listPagePayManager(RepoAccountQO param, BaseAccountDTO cuser) {
/*if(!cuser.isManage()){
param.setCompanys(cuser.getCompanyInfo().getCompanys());
}*/
int count = repoAccountDao.countPagePayManager(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<RepoAccountDTO> data =
repoAccountDao.listPagePayManager(param).stream()
.map(
d -> {
d.buildName();
return d.buildRepoAccountDTO();
})
.collect(Collectors.toList());
List<Integer> accountIds =
data.stream().map(RepoAccountDTO::getId).collect(Collectors.toList());
param.setAccountIds(accountIds);
// List<RepoWalletDTO> wallets = repoPayServletClient.feignListWalletInfo(param);
List<RepoWalletDTO> wallets = listWalletInfo(param);
Map<Integer, RepoWalletDTO> mapWallet =
wallets.stream()
.collect(
Collectors.toMap(
RepoWalletDTO::getRepoAccountId, wallet -> wallet, (k1, k2) -> k2));
for (RepoAccountDTO ac : data) {
if (mapWallet.containsKey(ac.getId())) {
ac.setCashAmt(mapWallet.get(ac.getId()).getCashAmt());
ac.setRemark(mapWallet.get(ac.getId()).getRemark());
}
}
return PageResult.buildPage(pageNo, param.getPageSize(), count, data);
}
public List<RepoWalletDTO> listWalletInfo(RepoAccountQO param) {
if (CollectionUtils.isEmpty(param.getAccountIds())) {
return java.util.Collections.emptyList();
}
List<RepoWalletDO> wallets = repoAccountDao.listWalletInfo(param);
return wallets.stream()
.map(
d -> {
return d.buildRepoWalletDTO();
})
.collect(Collectors.toList());
}
}
......@@ -12,28 +12,28 @@ import com.mmc.payment.model.vo.RepoOrderPayVO;
import java.math.BigDecimal;
/**
* @Author small
* @Date 2023/5/24 10:06
* @Version 1.0
* @Author small @Date 2023/5/24 10:06 @Version 1.0
*/
public interface RepoCashService {
PageResult listPageRepoCash(RepoCashQO param);
PageResult listPageRepoCash(RepoCashQO param);
void updateCashRemark(Integer id, String remark);
void updateCashRemark(Integer id, String remark);
/**
* 充值
*
* @param cash
* @return
*/
ResultBody reqCash(BaseAccountDTO cuser, RepoCashVO cash);
/**
* 充值
*
* @param cash
* @return
*/
ResultBody reqCash(BaseAccountDTO cuser, RepoCashVO cash);
ResultBody dedCash(BaseAccountDTO cuser, RepoCashVO cash);
ResultBody dedCash(BaseAccountDTO cuser, RepoCashVO cash);
RepoCashDTO getRefundInfo(String refundNo);
RepoCashDTO getRefundInfo(String refundNo);
BigDecimal RemainingBalance(Integer uid);
BigDecimal RemainingBalance(Integer uid);
PayCashResultDTO payCashOrder(RepoOrderPayVO orderPay);
PayCashResultDTO orderPayment(BaseAccountDTO currentAccount, String orderNo);
PayCashResultDTO payCashOrder(RepoOrderPayVO orderPay);
}
......@@ -34,3 +34,7 @@ mount:
directory: D:@javaVolume@
userapp:
url: http://localhost:35150/userapp/
......@@ -6,43 +6,43 @@
<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" />
<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" />
<result property="repoAccountId" column="repo_account_id" />
<result property="uid" column="uid" />
<result property="accountName" column="account_name" />
<result property="orderInfoId" column="order_info_id" />
<result property="orderNo" column="order_no" />
<result property="skuInfoId" column="sku_info_id" />
<result property="skuTitle" column="sku_title" />
<result property="wareInfoId" column="ware_info_id" />
<result property="wareNo" column="ware_no" />
<result property="wareTitle" column="ware_title" />
<result property="payNo" column="pay_no" />
<result property="payMethod" column="pay_method" />
<result property="amtPaid" column="amt_paid" />
<result property="cashAmt" column="cash_amt" />
<result property="payTime" column="pay_time" />
<result property="voucher" column="voucher" />
<result property="refundNo" column="refund_no" />
<result property="remark" column="remark" />
<result property="updateTime" column="update_time" />
<result property="updateUser" column="update_user" />
<result property="createTime" column="create_time" />
<result property="createUser" column="create_user" />
<id property="id" column="id"/>
<result property="repoAccountId" column="repo_account_id"/>
<result property="uid" column="uid"/>
<result property="accountName" column="account_name"/>
<result property="orderInfoId" column="order_info_id"/>
<result property="orderNo" column="order_no"/>
<result property="skuInfoId" column="sku_info_id"/>
<result property="skuTitle" column="sku_title"/>
<result property="wareInfoId" column="ware_info_id"/>
<result property="wareNo" column="ware_no"/>
<result property="wareTitle" column="ware_title"/>
<result property="payNo" column="pay_no"/>
<result property="payMethod" column="pay_method"/>
<result property="amtPaid" column="amt_paid"/>
<result property="cashAmt" column="cash_amt"/>
<result property="payTime" column="pay_time"/>
<result property="voucher" column="voucher"/>
<result property="refundNo" column="refund_no"/>
<result property="remark" column="remark"/>
<result property="updateTime" column="update_time"/>
<result property="updateUser" column="update_user"/>
<result property="createTime" column="create_time"/>
<result property="createUser" column="create_user"/>
</resultMap>
<select id="getRefundCashInfo" resultMap="repoCashResultMap"
parameterType="Integer">
......@@ -59,17 +59,13 @@
<insert id="insertRepoCash" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.payment.entity.RepoCashDO">
insert into repo_cash
(
repo_account_id,uid,account_name,order_info_id,order_no,sku_info_id,sku_title,
ware_info_id,ware_no,ware_title,pay_no,pay_method,amt_paid,cash_amt,pay_time,remark,
voucher,refund_no,update_time,update_user,create_time,create_user
)
values
(
#{repoAccountId},#{uid},#{accountName},#{orderInfoId},#{orderNo},#{skuInfoId},#{skuTitle},
#{wareInfoId},#{wareNo},#{wareTitle},#{payNo},#{payMethod},#{amtPaid},#{cashAmt},#{payTime},#{remark},
#{voucher},#{refundNo},#{updateTime},#{updateUser},#{createTime},#{createUser}
)
(repo_account_id, uid, account_name, order_info_id, order_no, sku_info_id, sku_title,
ware_info_id, ware_no, ware_title, pay_no, pay_method, amt_paid, cash_amt, pay_time, remark,
voucher, refund_no, update_time, update_user, create_time, create_user)
values (#{repoAccountId}, #{uid}, #{accountName}, #{orderInfoId}, #{orderNo}, #{skuInfoId}, #{skuTitle},
#{wareInfoId}, #{wareNo}, #{wareTitle}, #{payNo}, #{payMethod}, #{amtPaid}, #{cashAmt}, #{payTime},
#{remark},
#{voucher}, #{refundNo}, #{updateTime}, #{updateUser}, #{createTime}, #{createUser})
</insert>
<update id="updateCashRemark">
......@@ -138,12 +134,18 @@
</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
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}
where w.repo_account_id = #{repoAccountId}
</select>
<update id="updateRepoWalletAmt">
......@@ -153,14 +155,29 @@
</update>
<select id="RemainingBalance" resultType="java.math.BigDecimal">
select cash_amt from repo_wallet where repo_account_id=#{repoAccountId}
select cash_amt
from repo_wallet
where repo_account_id = #{repoAccountId}
</select>
<update id="updateWalletAmt">
update repo_wallet
set cash_amt = cash_amt + #{addAmt},
set cash_amt = cash_amt + #{addAmt},
cash_paid = cash_paid + #{addPaid}
where repo_account_id = #{repoAccountId}
</update>
<insert id="orderPayment" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.payment.entity.RepoCashDO">
insert into repo_cash
(repo_account_id, uid, account_name, order_info_id, order_no, sku_info_id, sku_title,
ware_info_id, ware_no, ware_title, pay_no, pay_method, amt_paid, cash_amt, pay_time, remark,
voucher, refund_no, update_time, update_user, create_time, create_user)
values (#{repoAccountId}, #{uid}, #{accountName}, #{orderInfoId}, #{orderNo}, #{skuInfoId}, #{skuTitle},
#{wareInfoId}, #{wareNo}, #{wareTitle}, #{payNo}, #{payMethod}, #{amtPaid}, #{cashAmt}, #{payTime},
#{remark},
#{voucher}, #{refundNo}, #{updateTime}, #{updateUser}, #{createTime}, #{createUser})
</insert>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论