| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.TransactionDetails; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.service.ITransactionDetailsService; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @Autowired |
| | | private ITransactionDetailsService transactionDetailsService; |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | @ResponseBody |
| | | @PostMapping("/wxRecharge") |
| | | public void wxRecharge(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if (null != map) { |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String result = map.get("result"); |
| | | TransactionDetails transactionDetails = transactionDetailsService.selectOne(new EntityWrapper<TransactionDetails>() |
| | | .eq("code", out_trade_no)); |
| | | if (transactionDetails!=null){ |
| | | if (transactionDetails.getState()==2){ |
| | | return; |
| | | } |
| | | Driver driver = driverService.selectById(transactionDetails.getUserId()); |
| | | if (driver!=null){ |
| | | driver.setBalance(driver.getBalance() + transactionDetails.getMoney()); |
| | | driverService.updateById(driver); |
| | | } |
| | | transactionDetails.setState(2); |
| | | transactionDetailsService.updateById(transactionDetails); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |