提交 7b011ce4 作者: 刘明祎-运维用途

Merge branch 'develop'

流水线 #7524 已通过 于阶段
in 2 分 24 秒
...@@ -16,6 +16,7 @@ import io.swagger.annotations.*; ...@@ -16,6 +16,7 @@ import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -75,6 +76,14 @@ public class UserPointsController extends BaseController { ...@@ -75,6 +76,14 @@ public class UserPointsController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/changeUserPoints") @GetMapping("/changeUserPoints")
public ResultBody changeUserPoints(HttpServletRequest request,@RequestParam("id") Integer id) { public ResultBody changeUserPoints(HttpServletRequest request,@RequestParam("id") Integer id) {
return userPointsService.changeUserPoints(this.getUserLoginInfoFromRedis(request).getUserAccountId(), id); return userPointsService.changeUserPoints(this.getUserLoginInfoFromRedis(request).getUserAccountId(), id,0,null);
}
@ApiOperation(value = "远程调用——积分变动接口")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/feignChangeUserPoints")
@ApiIgnore
public ResultBody feignChangeUserPoints(HttpServletRequest request,@RequestParam("id") int changePoint,String reason) {
return userPointsService.changeUserPoints(this.getUserLoginInfoFromRedis(request).getUserAccountId(), null,changePoint,reason);
} }
} }
...@@ -2,6 +2,7 @@ package com.mmc.iuav.user.controller.wallet; ...@@ -2,6 +2,7 @@ package com.mmc.iuav.user.controller.wallet;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.controller.BaseController; import com.mmc.iuav.user.controller.BaseController;
import com.mmc.iuav.user.entity.wallet.CurriculumOrderLogVO;
import com.mmc.iuav.user.entity.wallet.UserBillingDetailVO; import com.mmc.iuav.user.entity.wallet.UserBillingDetailVO;
import com.mmc.iuav.user.model.dto.wallet.PayWalletDTO; import com.mmc.iuav.user.model.dto.wallet.PayWalletDTO;
import com.mmc.iuav.user.model.qo.wallet.WalletFlowQO; import com.mmc.iuav.user.model.qo.wallet.WalletFlowQO;
...@@ -94,4 +95,11 @@ public class PayWalletController extends BaseController { ...@@ -94,4 +95,11 @@ public class PayWalletController extends BaseController {
public ResultBody payUavWallet(@RequestBody PayUavWalletVO payUavWalletVO) { public ResultBody payUavWallet(@RequestBody PayUavWalletVO payUavWalletVO) {
return payWalletService.payUavWallet(payUavWalletVO); return payWalletService.payUavWallet(payUavWalletVO);
} }
@ApiOperation(value = "feign——课程订单钱包流水记录")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("feignCurriculumOrderLog")
public ResultBody feignCurriculumOrderLog(HttpServletRequest request,@RequestBody CurriculumOrderLogVO param) {
return payWalletService.feignCurriculumOrderLog(this.getUserLoginInfoFromRedis(request).getUserAccountId(),param);
}
} }
package com.mmc.iuav.user.entity.wallet;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author Admin
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CurriculumOrderLogVO {
private Integer userAccountId;
@ApiModelProperty(value = "云享金消耗金额")
private BigDecimal cashAmtPaid;
@ApiModelProperty(value = "佣金消耗金额")
private BigDecimal salaryAmtPaid;
@ApiModelProperty(value = "订单编号")
private String orderNo;
public PayLogDO buildPayLog() {
return PayLogDO.builder().userAccountId(this.userAccountId)
.cashAmtPaid(this.cashAmtPaid != null ? this.cashAmtPaid.negate() : BigDecimal.ZERO)
.salaryAmtPaid(this.salaryAmtPaid != null ? this.salaryAmtPaid.negate() : BigDecimal.ZERO)
.payNo(this.orderNo)
.build();
}
}
\ No newline at end of file
package com.mmc.iuav.user.entity.wallet; package com.mmc.iuav.user.entity.wallet;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -17,6 +18,7 @@ import java.util.Date; ...@@ -17,6 +18,7 @@ import java.util.Date;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder
public class PayLogDO implements Serializable { public class PayLogDO implements Serializable {
private static final long serialVersionUID = 752682324297846133L; private static final long serialVersionUID = 752682324297846133L;
......
...@@ -25,10 +25,13 @@ public interface UserPointsService { ...@@ -25,10 +25,13 @@ public interface UserPointsService {
/** /**
* 改变用户积分, * 改变用户积分,一种是前端传用户userid和扣除积分的pointChangeTypeId(数据库查找变动积分多少和积分变更原因)
* 另一种是供别的服务使用 直接传入用户userid和变动多少积分changePoint和变动原因
* @param userId 用户id * @param userId 用户id
* @param pointChangeTypeId 根据这个id去user_points_change_type表中查找需要修改多少积分 * @param pointChangeTypeId 根据这个id去user_points_change_type表中查找需要修改多少积分和原因
* @param changePoint 修改多少积分
* @return {@link ResultBody} * @return {@link ResultBody}
*/ */
ResultBody changeUserPoints(Integer userId,Integer pointChangeTypeId); ResultBody changeUserPoints(Integer userId,Integer pointChangeTypeId,int changePoint,String reason);
} }
...@@ -114,21 +114,25 @@ public class UserPointsServiceImpl implements UserPointsService { ...@@ -114,21 +114,25 @@ public class UserPointsServiceImpl implements UserPointsService {
} }
@Override @Override
public ResultBody changeUserPoints(Integer userId, Integer pointChangeTypeId) { public ResultBody changeUserPoints(Integer userId, Integer pointChangeTypeId,int changePoint,String reason) {
//先根据积分变动id pointChangeTypeId 去找到积分变动类型信息 //先根据积分变动id pointChangeTypeId 去找到积分变动类型信息
UserPointChangeTypeDO userPointChangeTypeDO = userPointsDetailsDao.selectChangePoint(pointChangeTypeId); if(pointChangeTypeId != null) {
if(userPointChangeTypeDO == null) { UserPointChangeTypeDO userPointChangeTypeDO = userPointsDetailsDao.selectChangePoint(pointChangeTypeId);
return ResultBody.error("扣除积分类型不存在"); if (userPointChangeTypeDO == null) {
return ResultBody.error("扣除积分类型不存在");
}
//用户更改完积分后如果小于0就代表积分不够 大于0就去修改数据库用户总积分
//改变的积分
changePoint = userPointChangeTypeDO.getChangePoint();
//改变积分的原因
reason = userPointChangeTypeDO.getPointSource();
} }
UserPointsDO userPointsDO = userPointsDao.selectUserPoints(userId); UserPointsDO userPointsDO = userPointsDao.selectUserPoints(userId);
if(userPointsDO == null) { if (userPointsDO == null) {
userPointsDO.setUserAccountId(userId); userPointsDO.setUserAccountId(userId);
userPointsDO.setTotalPoints(0); userPointsDO.setTotalPoints(0);
userPointsDao.insertPoints(userPointsDO); userPointsDao.insertPoints(userPointsDO);
} }
//用户更改完积分后如果小于0就代表积分不够 大于0就去修改数据库用户总积分
//改变的积分
Integer changePoint = userPointChangeTypeDO.getChangePoint();
//改变后的用户总积分 //改变后的用户总积分
Integer userNowPoints = userPointsDO.getTotalPoints() + changePoint; Integer userNowPoints = userPointsDO.getTotalPoints() + changePoint;
if(userNowPoints < 0) { if(userNowPoints < 0) {
...@@ -136,8 +140,9 @@ public class UserPointsServiceImpl implements UserPointsService { ...@@ -136,8 +140,9 @@ public class UserPointsServiceImpl implements UserPointsService {
} }
userPointsDO.setTotalPoints(userNowPoints); userPointsDO.setTotalPoints(userNowPoints);
userPointsDao.updatePoints(userPointsDO); userPointsDao.updatePoints(userPointsDO);
//添加一条积分变动记录 //添加一条积分变动记录
UserPointsDetails userPointsDetails = new UserPointsDetails(userId,changePoint,userPointChangeTypeDO.getPointSource()); UserPointsDetails userPointsDetails = new UserPointsDetails(userId,changePoint,reason);
userPointsDetailsDao.insertPointsDetails(userPointsDetails); userPointsDetailsDao.insertPointsDetails(userPointsDetails);
return ResultBody.success(); return ResultBody.success();
} }
......
package com.mmc.iuav.user.service.wallet; package com.mmc.iuav.user.service.wallet;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.entity.wallet.CurriculumOrderLogVO;
import com.mmc.iuav.user.model.qo.wallet.WalletFlowQO; import com.mmc.iuav.user.model.qo.wallet.WalletFlowQO;
import com.mmc.iuav.user.model.vo.wallet.PayUavWalletVO; import com.mmc.iuav.user.model.vo.wallet.PayUavWalletVO;
import com.mmc.iuav.user.model.vo.wallet.TopUpOrderVO; import com.mmc.iuav.user.model.vo.wallet.TopUpOrderVO;
...@@ -26,5 +27,12 @@ public interface PayWalletService { ...@@ -26,5 +27,12 @@ public interface PayWalletService {
ResultBody payUavWallet(PayUavWalletVO payUavWalletVO); ResultBody payUavWallet(PayUavWalletVO payUavWalletVO);
/**
* 保存用户购买课程消耗的云享金和佣金的金额流水
* @param param
* @return {@link ResultBody}
*/
ResultBody feignCurriculumOrderLog(Integer userId, CurriculumOrderLogVO param);
ResultBody optimizeWalletFlow(WalletFlowVO walletFlowVO); ResultBody optimizeWalletFlow(WalletFlowVO walletFlowVO);
} }
...@@ -8,10 +8,7 @@ import com.mmc.iuav.user.dao.UserServiceDao; ...@@ -8,10 +8,7 @@ import com.mmc.iuav.user.dao.UserServiceDao;
import com.mmc.iuav.user.dao.wallet.PayWalletDao; import com.mmc.iuav.user.dao.wallet.PayWalletDao;
import com.mmc.iuav.user.entity.UserAccountDO; import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.XzWithdrawalApplyDO; import com.mmc.iuav.user.entity.XzWithdrawalApplyDO;
import com.mmc.iuav.user.entity.wallet.PayLogDO; import com.mmc.iuav.user.entity.wallet.*;
import com.mmc.iuav.user.entity.wallet.PayWalletDO;
import com.mmc.iuav.user.entity.wallet.UserBillingDetailVO;
import com.mmc.iuav.user.entity.wallet.WithdrawalLogDO;
import com.mmc.iuav.user.enums.PayMethodEnums; import com.mmc.iuav.user.enums.PayMethodEnums;
import com.mmc.iuav.user.model.dto.wallet.PayWalletDTO; import com.mmc.iuav.user.model.dto.wallet.PayWalletDTO;
import com.mmc.iuav.user.model.qo.wallet.WalletFlowQO; import com.mmc.iuav.user.model.qo.wallet.WalletFlowQO;
...@@ -37,6 +34,7 @@ import java.util.stream.Collectors; ...@@ -37,6 +34,7 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@Slf4j @Slf4j
@Transactional(rollbackFor = Exception.class)
public class PayWalletServiceImpl implements PayWalletService { public class PayWalletServiceImpl implements PayWalletService {
@Resource @Resource
PayWalletDao payWalletDao; PayWalletDao payWalletDao;
...@@ -630,6 +628,53 @@ public class PayWalletServiceImpl implements PayWalletService { ...@@ -630,6 +628,53 @@ public class PayWalletServiceImpl implements PayWalletService {
} }
} }
/**
* 保存用户购买课程消耗的云享金和佣金的金额流水
*
* @param param
* @return {@link ResultBody}
*/
@Override
public ResultBody feignCurriculumOrderLog(Integer userId, CurriculumOrderLogVO param) {
PayWalletDO payWalletByUser = payWalletDao.getPayWalletByUser(userId);
//需要扣除的云享金
BigDecimal cashAmtPaid = param.getCashAmtPaid() == null ? BigDecimal.ZERO : param.getCashAmtPaid();
//需要扣除的佣金
BigDecimal salaryAmtPaid = param.getSalaryAmtPaid() == null ? BigDecimal.ZERO : param.getSalaryAmtPaid();
//如果需要扣除的云享金和佣金是0的话直接返回成功
if(cashAmtPaid.compareTo(BigDecimal.ZERO) == 0 && salaryAmtPaid.compareTo(BigDecimal.ZERO) == 0){
return ResultBody.success();
}
// 这是扣钱的接口 如果小于0表示加钱 不行
if(cashAmtPaid.compareTo(BigDecimal.ZERO) < 0 || salaryAmtPaid.compareTo(BigDecimal.ZERO) < 0){
return ResultBody.error("需要扣除的金额不能为负");
}
//扣除完后云享金
BigDecimal cashAmt = payWalletByUser.getCashAmt().subtract(cashAmtPaid);
//扣除完后佣金余额
BigDecimal salaryAmt = payWalletByUser.getSalaryAmt().subtract(salaryAmtPaid);
if(cashAmt.compareTo(BigDecimal.ZERO) >= 0){
payWalletByUser.setCashAmt(cashAmt);
}else {
return ResultBody.error("云享金不足");
}
if(salaryAmt.compareTo(BigDecimal.ZERO) >= 0){
payWalletByUser.setSalaryAmt(salaryAmt);
}else {
return ResultBody.error("佣金不足");
}
payWalletDao.updatePayWallet(payWalletByUser);
PayLogDO payLogDO = param.buildPayLog();
payLogDO.setOperateUser(userId);
payLogDO.setPayMethod(1900);
payWalletDao.insertPayLogDO(payLogDO);
return ResultBody.success();
}
private ResultBody handleLeaseOrderRefund(PayUavWalletVO payUavWalletVO, PayWalletDO userWalletInfo, PayLogDO payLogDO, PayWalletDO payWalletDO) { private ResultBody handleLeaseOrderRefund(PayUavWalletVO payUavWalletVO, PayWalletDO userWalletInfo, PayLogDO payLogDO, PayWalletDO payWalletDO) {
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount()); payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount());
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount()); payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount());
......
...@@ -18,4 +18,4 @@ patches: ...@@ -18,4 +18,4 @@ patches:
images: images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG - name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: 46a43df60d229f51adcc7ca999b70db01751f9fa newTag: f364bdf4788be9eb9edf743f768b3c33fbc36c9e
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论