Tx.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018-2020 rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: TABLE ME
  8. // +----------------------------------------------------------------------
  9. // | Date: 2020-11-08 12:56
  10. // +----------------------------------------------------------------------
  11. namespace app\system\controller\v1;
  12. use app\BaseController;
  13. use app\model\system\SiteTotal;
  14. use app\Request;
  15. use library\services\UtilService;
  16. use library\utils\alipay;
  17. class Tx extends BaseController {
  18. public function init(){
  19. //获取全部提现
  20. $allTx = (new \app\model\system\Tx)->count();
  21. $noTx = (new \app\model\system\Tx)->where('is_type',0)->count();
  22. $yeTx = (new \app\model\system\Tx)->where('is_type',1)->count();
  23. $allTxPrice = (new \app\model\system\Tx)->sum('money');
  24. return app('json')->success([
  25. 'all_tx' => $allTx,
  26. 'no_tx' => $noTx,
  27. 'yes_tx' => $yeTx,
  28. 'all_tx_price' => $allTxPrice
  29. ]);
  30. }
  31. /**
  32. * 添加
  33. * @param Request $request
  34. */
  35. public function add(Request $request) {
  36. $post = UtilService::getMore(
  37. [
  38. ['id','','empty','参数错误'],
  39. ['mono'],
  40. ['type',0]
  41. ],$request);
  42. $txData = (new \app\model\system\Tx)->where('id',$post['id'])->find();
  43. if(empty($txData)) {
  44. return app('json')->fail('数据不存在');
  45. }
  46. if(!empty($txData['is_type'])) {
  47. return app('json')->fail('已经确认打款了');
  48. }
  49. if($post['type'] == 1) {
  50. $alipaly = new alipay();
  51. $result = $alipaly->accountTransfer($txData['code'],$txData['money'],$txData['name']);
  52. if($result['code'] == 1000){
  53. $mono = '后台确认,操作员:'
  54. . $request->adminInfo['username']
  55. . (empty($post['mono'] ) ? '' : (',备注理由:' .$post['mono'] )) ;
  56. (new \app\model\system\Tx)
  57. ->where('id',$post['id'])
  58. ->save(['is_type'=>1,
  59. 'mono'=>$mono,
  60. 'check_time'=>time(),
  61. 'transfer_type' => 2,
  62. 'pay_fund_order_id' => $result['pay_fund_order_id'],
  63. 'out_biz_no' => $result['out_biz_no'],
  64. 'order_id' => $result['order_id']
  65. ]);
  66. } else {
  67. return app('json')->fail($result['msg']);
  68. }
  69. } else {
  70. $mono = '后台确认,操作员:'
  71. . $request->adminInfo['username']
  72. . (empty($post['mono'] ) ? '' : (',备注理由:' .$post['mono'] )) ;
  73. (new \app\model\system\Tx)
  74. ->where('id',$post['id'])
  75. ->save(['is_type'=>1,
  76. 'mono'=>$mono,
  77. 'check_time'=>time(),
  78. 'transfer_type' => 1,
  79. 'pay_fund_order_id' => '',
  80. 'out_biz_no' => '',
  81. 'order_id' => ''
  82. ]);
  83. }
  84. return app('json')->success('操作成功');
  85. }
  86. /**
  87. * 获取订单数据
  88. * @param Request $request
  89. */
  90. public function list(Request $request){
  91. $pageSize = 50;
  92. $post = UtilService::getMore(
  93. [
  94. ['page',1],
  95. ['orderType',''],
  96. ['mobile',''],
  97. ['type',''],
  98. ['uid',''],
  99. ['sassids','']
  100. ],$request
  101. );
  102. $where = $post;
  103. list($pageCount,$data) = (new \app\model\system\Tx)->getList($post['page'],$where,$pageSize);
  104. $result = UtilService::getParam([
  105. "id",
  106. "member_mobile",
  107. "site_name",
  108. "money",
  109. "bank",
  110. "name",
  111. "code",
  112. ["time","time","date('Y-m-d H:i',$1)"],
  113. ["check_time","check_time","date('Y-m-d H:i',$1)"],
  114. "is_type",
  115. "transfer_type",
  116. "pay_fund_order_id",
  117. "warehouse_name",
  118. "type",
  119. "mono"
  120. ],$data);
  121. return app('json')->success([
  122. 'list' => $result,
  123. 'pageCount' => $pageCount,
  124. 'pageSize' => $pageSize,
  125. 'page' => $post['page']
  126. ]);
  127. }
  128. }