Finance.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xurongyao <763569752@qq.com>
  5. * Date: 2018/6/14 下午5:25
  6. */
  7. namespace app\admin\controller\finance;
  8. use app\admin\controller\AuthController;
  9. use FormBuilder\exception\FormBuilderException;
  10. use think\Exception;
  11. use think\facade\Route;
  12. use app\admin\model\user\{User, UserBill};
  13. use app\admin\model\finance\FinanceModel;
  14. use crmeb\services\{FormBuilder, JsonService, UtilService as Util, JsonService as Json, UtilService};
  15. /**
  16. * 微信充值记录
  17. * Class UserRecharge
  18. * @package app\admin\controller\user
  19. */
  20. class Finance extends AuthController
  21. {
  22. /**
  23. * 显示资金记录
  24. */
  25. public function bill()
  26. {
  27. $list = UserBill::where('category', 'not in', 'integral')
  28. ->field(['title', 'type'])
  29. ->group('type')
  30. ->distinct(true)
  31. ->select()
  32. ->toArray();
  33. $this->assign('selectList', $list);
  34. return $this->fetch();
  35. }
  36. /**
  37. * 显示资金记录ajax列表
  38. */
  39. public function billlist()
  40. {
  41. $where = Util::getMore([
  42. ['start_time', ''],
  43. ['end_time', ''],
  44. ['nickname', ''],
  45. ['limit', 20],
  46. ['page', 1],
  47. ['type', ''],
  48. ]);
  49. return Json::successlayui(FinanceModel::getBillList($where));
  50. }
  51. /**
  52. *保存资金监控的excel表格
  53. */
  54. public function save_bell_export()
  55. {
  56. $where = Util::getMore([
  57. ['start_time', ''],
  58. ['end_time', ''],
  59. ['nickname', ''],
  60. ['type', ''],
  61. ]);
  62. FinanceModel::SaveExport($where);
  63. }
  64. /**
  65. * 显示佣金记录
  66. */
  67. public function commission_list()
  68. {
  69. $this->assign('is_layui', true);
  70. return $this->fetch();
  71. }
  72. /**
  73. * 佣金记录异步获取
  74. */
  75. public function get_commission_list()
  76. {
  77. $get = Util::getMore([
  78. ['page', 1],
  79. ['limit', 20],
  80. ['nickname', ''],
  81. ['price_max', ''],
  82. ['price_min', ''],
  83. ['order', ''],
  84. ['excel', ''],
  85. ]);
  86. return Json::successlayui(User::getCommissionList($get));
  87. }
  88. /**
  89. * 显示操作记录
  90. */
  91. public function index3()
  92. {
  93. }
  94. /**
  95. * 佣金详情
  96. */
  97. public function content_info($uid = '')
  98. {
  99. if ($uid == '') return $this->failed('缺少参数');
  100. $this->assign('userinfo', User::getUserinfo($uid));
  101. $this->assign('uid', $uid);
  102. return $this->fetch();
  103. }
  104. /**
  105. * 佣金提现记录个人列表
  106. */
  107. public function get_extract_list($uid = '')
  108. {
  109. if ($uid == '') return Json::fail('缺少参数');
  110. $where = Util::getMore([
  111. ['page', 1],
  112. ['limit', 20],
  113. ['start_time', ''],
  114. ['end_time', ''],
  115. ['nickname', '']
  116. ]);
  117. return Json::successlayui(UserBill::getExtrctOneList($where, $uid));
  118. }
  119. /**
  120. * 创建form表单
  121. *
  122. * @param int $id
  123. * @return string
  124. * @throws Exception
  125. * @throws FormBuilderException|\Exception
  126. */
  127. public function create($id = 0)
  128. {
  129. if (!$id) $this->failed('参数错误');
  130. $info = UserBill::get($id);
  131. if (!$info) $this->failed('记录不存在');
  132. $field[] = FormBuilder::textarea('admin_mark', '备注', isset($info) ? $info->admin_mark : '')->col(24)->rows(20);
  133. $form = FormBuilder::make_post_form('添加计划', $field, Route::buildUrl('save', ['id' => $id]), 2);
  134. $this->assign(compact('form'));
  135. return $this->fetch('public/form-builder');
  136. }
  137. /**
  138. * 添加或者修改
  139. * @param $id
  140. * @return void
  141. */
  142. public function save($id = 0)
  143. {
  144. if (!$id) $this->failed('参数错误');
  145. $info = UserBill::get($id);
  146. if (!$info) $this->failed('记录不存在');
  147. $data = UtilService::postMore([
  148. ['admin_mark', ''],
  149. ]);
  150. UserBill::beginTrans();
  151. try {
  152. //修改
  153. if (UserBill::edit($data, $id)) {
  154. UserBill::commitTrans();
  155. JsonService::successful('修改成功');
  156. } else {
  157. UserBill::rollbackTrans();
  158. JsonService::fail('修改失败');
  159. }
  160. } catch (\Exception $e) {
  161. UserBill::rollbackTrans();
  162. JsonService::fail($e->getMessage());
  163. }
  164. }
  165. }