CapitalController.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace backend\controllers;
  3. use common\services\xhMerchantCapitalService;
  4. use common\components\stringUtil;
  5. use common\services\xhUserUniteService;
  6. use common\services\xhUserAssetService;
  7. use common\services\xhUserAlipayService;
  8. use common\services\xhOrderService;
  9. use common\components\configDict;
  10. use common\components\util;
  11. use common\services\xhUserService;
  12. use common\models\xhUser;
  13. use common\services\xhMerchantService;
  14. use common\services\xhUserIntegralService;
  15. use Yii;
  16. use yii\web\Controller;
  17. use yii\data\Pagination;
  18. use common\models\xhMerchantCapital;
  19. use common\models\xhUserCapital;
  20. class CapitalController extends BackendController
  21. {
  22. /**
  23. * 商家的资金流水
  24. */
  25. public function actionList()
  26. {
  27. $get = Yii::$app->request->get();
  28. $query = xhMerchantCapital::find();
  29. $query->where(['merchantId' => $this->merchantId, 'io' => 1]);
  30. if(isset($get['payWay']) && $get['payWay']!=-1){
  31. $query->andWhere(['payWay'=>$get['payWay']]);
  32. }
  33. if(isset($get['date']) && !empty($get['date'])){
  34. $arrDate = explode(' - ',$get['date']);
  35. $startTime = strtotime($arrDate[0]);
  36. $endTime = strtotime($arrDate[1]);
  37. $query->andWhere(['>=', 'addTime', $startTime]);
  38. $query->andWhere(['<','addTime',$endTime]);
  39. }
  40. $countQuery = clone $query;
  41. //总计
  42. $totalAmount = $countQuery->sum('amount');
  43. $totalCount = $countQuery->count();
  44. $pages = new Pagination(['totalCount' => $totalCount, 'pageSize' => 50]);
  45. $models = $query->offset($pages->offset)->limit($pages->limit)->orderBy('addTime desc')->all();
  46. $payWay = configDict::getConfig('payWayName');
  47. $capitalTypeList = configDict::getConfig('capitalTypeList');
  48. return $this->render('list', ['models' => $models, 'pages' => $pages, 'payWay' => $payWay, 'capitalTypeList' => $capitalTypeList,'totalAmount'=>$totalAmount]);
  49. }
  50. public function actionBalance()
  51. {
  52. $query = xhMerchantCapital::find();
  53. $alipayWay = configDict::getConfig('payWay', 'alipay');
  54. $query->where(['merchantId' => $this->merchantId, 'affectBalance' => 1]);//查询会影响商家提现余额的流水
  55. $query->orderBy('id desc');
  56. $countQuery = clone $query;
  57. $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
  58. $models = $query->offset($pages->offset)->limit($pages->limit)->all();
  59. $payWay = configDict::getConfig('payWayName');
  60. $capitalTypeList = configDict::getConfig('capitalTypeList');
  61. return $this->render('balance', ['models' => $models, 'pages' => $pages, 'payWay' => $payWay, 'capitalTypeList' => $capitalTypeList]);
  62. }
  63. public function actionUser()
  64. {
  65. $get = Yii::$app->request->get();
  66. $userId = isset($get['id']) ? $get['id'] : 0;
  67. $user = xhUserService::getById($userId);
  68. if (empty($user) || $user['merchantId'] != $this->merchantId) {
  69. util::stop('出错了,请联系管理员哦');
  70. }
  71. $query = xhUserCapital::find();
  72. $query->where(['merchantId' => $this->merchantId, 'userId' => $userId]);
  73. $query->orderBy('id desc');
  74. $countQuery = clone $query;
  75. $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
  76. $models = $query->offset($pages->offset)->limit($pages->limit)->all();
  77. return $this->render('user', ['models' => $models, 'pages' => $pages, 'user' => $user]);
  78. }
  79. public function actionPaymentDetail()
  80. {
  81. $get = Yii::$app->request->get();
  82. $id = isset($get['id']) ? $get['id'] : '';
  83. $payment = xhOrderService::getById($id);
  84. $payWay = configDict::getConfig('payWayFullName');
  85. $alipayWay = configDict::getConfig('payWay', 'alipay');
  86. $alipayInfo = [];
  87. if ($payment['payWay'] == $alipayWay) {
  88. $alipayId = $payment['alipayId'];
  89. $merchantId = $payment['merchantId'];
  90. $alipayInfo = xhUserAlipayService::getByIds($alipayId, $merchantId);
  91. }
  92. $userName = '游客';
  93. if (!empty($payment['userId'])) {
  94. $user = xhUserService::getById($payment['userId']);
  95. $userName = $user['userName'];
  96. }
  97. return $this->render('paymentDetail', ['payment' => $payment, 'userName' => $userName, 'alipayInfo' => $alipayInfo, 'payWay' => $payWay, 'alipayWay' => $alipayWay]);
  98. }
  99. public function actionOrderDetail()
  100. {
  101. return $this->render('orderDetail');
  102. }
  103. public function actionActiveOrderDetail()
  104. {
  105. return $this->render('activeOrderDetail');
  106. }
  107. public function actionCashPaymentDetail()
  108. {
  109. return $this->render('cashPaymentDetail');
  110. }
  111. public function actionDrawCash()
  112. {
  113. return $this->render('drawCash');
  114. }
  115. public function actionUserUnite()
  116. {
  117. return $this->render('userUnite');
  118. }
  119. }