From c253b555c7905c5136d47cd615ef545fa50cc6ad Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Sun, 20 Feb 2022 21:24:16 +0800 Subject: [PATCH] Merge branch 'api_score_meger' --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesWithdrawalAction.java | 124 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 124 insertions(+), 0 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesWithdrawalAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesWithdrawalAction.java new file mode 100644 index 0000000..2c5cba2 --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesWithdrawalAction.java @@ -0,0 +1,124 @@ +package com.matrix.system.shopXcx.api.action; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.matrix.system.hive.bean.SysVipInfo; +import com.matrix.system.hive.dao.SysVipInfoDao; +import com.matrix.system.common.init.UserCacheManager; +import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; +import com.matrix.core.constance.MatrixConstance; +import com.matrix.core.pojo.AjaxResult; +import com.matrix.core.pojo.BasePageQueryDto; +import com.matrix.system.fenxiao.dao.ShopRevenueFlowDao; +import com.matrix.system.fenxiao.entity.ShopRevenueFlow; +import com.matrix.system.hive.service.CodeService; +import com.matrix.system.shopXcx.api.dto.RevenueFlowDto; +import com.matrix.system.shopXcx.api.dto.WithdrawalCashDto; +import io.swagger.annotations.Api; +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.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +/** + * @author jyy + * @date 2021-03-10 + **/ +@Api(tags = "提现接口类") +@RestController +@RequestMapping(value = "/wxapi/salesWithdrawal") +public class WxSalesWithdrawalAction { + + + @Autowired + private UserCacheManager userCacheManager; + + @Autowired + private SysVipInfoDao sysVipInfoDao; + + @Autowired + private ShopRevenueFlowDao revenueFlowDao; + + + @Autowired + private ShopRevenueFlowDao shopRevenueFlowDao; + @Autowired + WeixinServiceUtil weixinServiceUtil; + + @Autowired + CodeService codeService; + + @ApiOperation(value = "获取收支明细", notes = "") + @PostMapping(value = "/getRevenueFlow") + @ApiResponses({ + @ApiResponse(code = 200, message = "ok", response = ShopRevenueFlow.class) + }) + AjaxResult getInvitationuserList(@RequestBody @Validated RevenueFlowDto revenueFlowDto) { + SysVipInfo loginUser = userCacheManager.getLoginUser(); + Page<ShopRevenueFlow> page=new Page<>(revenueFlowDto.getPageNum(),revenueFlowDto.getPageSize()); + revenueFlowDto.setUserId(loginUser.getId()); + IPage<ShopRevenueFlow> shopSalesmanApplyIPage = revenueFlowDao.selectRevenuFlowList(page, revenueFlowDto); + AjaxResult result=AjaxResult.buildSuccessInstance(shopSalesmanApplyIPage.getRecords()); + return result; + } + + + @ApiOperation(value = "提现", notes = "") + @PostMapping(value = "/withdrawalCash") + @ApiResponses({ + @ApiResponse(code = 200, message = "ok", response = BasePageQueryDto.class) + }) + @Transactional + AjaxResult withdrawalCash(@RequestBody @Validated WithdrawalCashDto withdrawalCashDto) { + SysVipInfo loginUser = userCacheManager.getLoginUser(); + loginUser=sysVipInfoDao.selectById(loginUser.getId()); + if(withdrawalCashDto.getAmount()<1){ + return AjaxResult.buildFailInstance("最小提现金额为1元"); + }else if(withdrawalCashDto.getAmount()>20000){ + return AjaxResult.buildFailInstance("最大提现金额为2万元"); + }else{ + if(loginUser.getWithdrawalCash()==null || loginUser.getWithdrawalCash()<withdrawalCashDto.getAmount()){ + return AjaxResult.buildFailInstance("余额不足"); + }else{ + + String txNo = codeService.get32LenNumberCode(); + + /*调试注释 + weixinServiceUtil.comPay("提现", txNo,Integer.parseInt((withdrawalCashDto.getAmount()*1000)+""), + loginUser.getOpenId(),loginUser.getCompanyId()); + */ + //记录收益流水 + ShopRevenueFlow invitationRevenueFlow=new ShopRevenueFlow(); + invitationRevenueFlow.setCompanyId(loginUser.getCompanyId()); + invitationRevenueFlow.setCreateBy(MatrixConstance.SYSTEM_USER); + invitationRevenueFlow.setUpdateBy(txNo); + invitationRevenueFlow.setCreateTime(new Date()); + invitationRevenueFlow.setUpdateTime(new Date()); + invitationRevenueFlow.setAmount(-withdrawalCashDto.getAmount()); + invitationRevenueFlow.setUserId(loginUser.getId()); + invitationRevenueFlow.setRevenueContent("提现"); + shopRevenueFlowDao.insert(invitationRevenueFlow); + //扣除用户剩余提现金额 + loginUser.setWithdrawalCash(loginUser.getWithdrawalCash()-withdrawalCashDto.getAmount()); + sysVipInfoDao.update(loginUser); + userCacheManager.updateUserInfo(loginUser); + return AjaxResult.buildSuccessInstance("提现成功"); + } + } + + + } + + + + + +} -- Gitblit v1.9.1