| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.beetl.ShiroExtUtil; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.WithdrawalExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.WithdrawalReq; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.HttpRequestUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushURL; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.unionpay.upyzt.exception.UpyztException; |
| | | import com.unionpay.upyzt.resp.AllocationResp; |
| | | import com.unionpay.upyzt.resp.WithdrawalResp; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 提现列表控制器 |
| | |
| | | */ |
| | | @RequestMapping("") |
| | | public String index(Model model) { |
| | | model.addAttribute("id",ShiroKit.getUser().getObjectId()); |
| | | model.addAttribute("id", ShiroExtUtil.getUser().getObjectId()); |
| | | return PREFIX + "tPubWithdrawal.html"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping(value = "/immediately") |
| | | @ResponseBody |
| | | @Transactional(rollbackFor = UpyztException.class,propagation = Propagation.REQUIRES_NEW) |
| | | public synchronized Object immediately(@RequestParam Integer id,@RequestParam Integer state,@RequestParam String remark) { |
| | | TPubWithdrawal tPubWithdrawal = tPubWithdrawalService.selectById(id); |
| | | if(tPubWithdrawal.getState()!=1){ |
| | |
| | | }else if (3 == state){ //拒绝提现 |
| | | stateObj = 2; |
| | | } |
| | | |
| | | Integer objectId = ShiroKit.getUser().getObjectId(); |
| | | |
| | | Integer objectId = ShiroExtUtil.getUser().getObjectId(); |
| | | // 获取手续费 |
| | | Double poundage = tPubWithdrawalService.getPoundage(objectId); |
| | | if(poundage!=null && poundage>0){ |
| | |
| | | TUser tUser1 = userService.selectById(tPubWithdrawal.getUserId()); |
| | | // 用户 |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser1.getPhone()).eq("applicationStatus","succeeded")); |
| | | if(userWithdrawals.size()>0){ |
| | | System.out.println("用户:"+userWithdrawals); |
| | | System.out.println("用户:"+userWithdrawals.get(0)); |
| | | try { |
| | | log.info("用户提现创建========="); |
| | | WithdrawalResp withdrawalResp = WithdrawalExample.create(userWithdrawalService.createInfo(userWithdrawals.get(0), tPubWithdrawal)); |
| | | tPubWithdrawal.setWithdrawId(withdrawalResp.getWithdrawalId()); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | log.info("用户提现创建信息========="+withdrawalResp.toString()); |
| | | log.info("用户提现创建成功========="); |
| | | } catch (UpyztException e) { |
| | | log.info("用户提现创建失败========="); |
| | | e.printStackTrace(); |
| | | if(userType==1){ |
| | | TUser tUser = userService.selectById(tPubWithdrawal.getUserId()); |
| | | BigDecimal balance = tUser.getBalance(); |
| | | BigDecimal money = balance.add(tPubWithdrawal.getMoney()); |
| | | tUser.setBalance(money); |
| | | userService.updateById(tUser); |
| | | |
| | | }else { |
| | | TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); |
| | | BigDecimal balance = tDriver.getBalance(); |
| | | BigDecimal money = balance.add(tPubWithdrawal.getMoney()); |
| | | tDriver.setBalance(money); |
| | | driverService.updateById(tDriver); |
| | | } |
| | | tPubWithdrawal.setState(3); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | return e.getMessage(); |
| | | } |
| | | if(userWithdrawals.size()>0) { |
| | | System.out.println("用户:" + userWithdrawals); |
| | | System.out.println("用户:" + userWithdrawals.get(0)); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | }else { |
| | | return "该用户未进件"; |
| | | } |
| | |
| | | .eq("phone", tUser1.getPhone()) |
| | | .last("LIMIT 1")); |
| | | // 先从平台进行分账到用户电子账簿 |
| | | if(userWithdrawal==null){ |
| | | if (userWithdrawal == null) { |
| | | return "该司机未进件"; |
| | | } |
| | | try { |
| | | log.info("司机提现创建========="); |
| | | WithdrawalResp withdrawalResp = WithdrawalExample.create(userWithdrawalService.createInfo(userWithdrawal, tPubWithdrawal)); |
| | | tPubWithdrawal.setWithdrawId(withdrawalResp.getWithdrawalId()); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | log.info("司机提现创建信息========="+withdrawalResp.toString()); |
| | | log.info("司机提现创建成功========="); |
| | | } catch (UpyztException e) { |
| | | log.info("司机提现创建失败========="); |
| | | e.printStackTrace(); |
| | | if(userType==1){ |
| | | TUser tUser = userService.selectById(tPubWithdrawal.getUserId()); |
| | | BigDecimal balance = tUser.getBalance(); |
| | | BigDecimal money = balance.add(tPubWithdrawal.getMoney()); |
| | | tUser.setBalance(money); |
| | | userService.updateById(tUser); |
| | | }else { |
| | | TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); |
| | | if(tPubWithdrawal.getType()==2){ |
| | | BigDecimal balance = new BigDecimal(tDriver.getLaveBusinessMoney()); |
| | | BigDecimal money = balance.add(tPubWithdrawal.getMoney()); |
| | | tDriver.setLaveBusinessMoney(money.doubleValue()); |
| | | }else |
| | | { |
| | | BigDecimal balance = new BigDecimal(tDriver.getLaveActivityMoney()); |
| | | BigDecimal money = balance.add(tPubWithdrawal.getMoney()); |
| | | tDriver.setLaveActivityMoney(money.doubleValue()); |
| | | } |
| | | |
| | | driverService.updateById(tDriver); |
| | | } |
| | | tPubWithdrawal.setState(3); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | return e.getMessage(); |
| | | } |
| | | log.info("司机提现创建========="); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | log.info("司机提现创建成功========="); |
| | | } |
| | | }else { |
| | | tPubWithdrawal.setState(state); |