MerchantMargin.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\system\merchant;
  12. use app\common\repositories\system\merchant\MerchantRepository;
  13. use app\common\repositories\system\serve\ServeOrderRepository;
  14. use app\common\repositories\user\UserBillRepository;
  15. use crmeb\basic\BaseController;
  16. use think\App;
  17. /**
  18. * 商户保证金
  19. */
  20. class MerchantMargin extends BaseController
  21. {
  22. /**
  23. * MerchantMargin constructor.
  24. * @param App $app
  25. */
  26. public function __construct(App $app)
  27. {
  28. parent::__construct($app);
  29. }
  30. /**
  31. * 列表
  32. * @param ServeOrderRepository $orderRepository
  33. * @return \think\response\Json
  34. * @author Qinii
  35. * @day 1/26/22
  36. */
  37. public function lst(MerchantRepository $orderRepository)
  38. {
  39. [$page, $limit] = $this->getPage();
  40. $where = $this->request->params(['date', 'keyword', 'is_trader', 'category_id', 'type_id']);
  41. $where['margin'] = 10;
  42. $data = $orderRepository->getPaidToMarginLst($where, $page, $limit);
  43. return app('json')->success($data);
  44. }
  45. /**
  46. * 获取商户保证金记录
  47. * @param $id
  48. * @return \think\response\Json
  49. * @author Qinii
  50. * @day 2023/4/25
  51. */
  52. public function getMarginLst($id)
  53. {
  54. [$page, $limit] = $this->getPage();
  55. $where = [
  56. 'mer_id' => $id,
  57. 'category' => 'mer_margin'
  58. ];
  59. $data = app()->make(UserBillRepository::class)->getLst($where, $page, $limit);
  60. return app('json')->success($data);
  61. }
  62. /**
  63. * 扣除保证金
  64. * @param $id
  65. * @return \think\response\Json
  66. * @author Qinii
  67. * @day 2023/4/25
  68. */
  69. public function setMarginForm($id)
  70. {
  71. $data = app()->make(MerchantRepository::class)->setMarginForm($id);
  72. return app('json')->success(formToData($data));
  73. }
  74. /**
  75. * 扣除保证金
  76. * @return \think\response\Json
  77. * @author Qinii
  78. * @day 2023/4/25
  79. */
  80. public function setMargin()
  81. {
  82. $data = $this->request->params(['mer_id', 'number', ['type', 'mer_margin'], 'mark']);
  83. $data['title'] = '保证金扣除';
  84. if ($data['number'] < 0)
  85. return app('json')->fail('扣除金额不能小于0');
  86. app()->make(MerchantRepository::class)->setMargin($data);
  87. return app('json')->success('扣除保证金成功');
  88. }
  89. /**
  90. * 线下补缴表单
  91. * @param $id
  92. * @return \think\response\Json
  93. * @author Qinii
  94. */
  95. public function localMarginForm($id)
  96. {
  97. $data = app()->make(MerchantRepository::class)->localMarginForm($id);
  98. return app('json')->success(formToData($data));
  99. }
  100. /**
  101. * 线下补缴
  102. * @param $id
  103. * @return \think\response\Json
  104. * @author Qinii
  105. */
  106. public function localMarginSet($id)
  107. {
  108. $data = $this->request->params(['number', 'mark', 'status']);
  109. app()->make(MerchantRepository::class)->localMarginSet($id, $data);
  110. return app('json')->success('操作成功');
  111. }
  112. }