DeliveryStation.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\delivery;
  12. use app\common\repositories\delivery\DeliveryStationRepository;
  13. use app\common\repositories\system\config\ConfigClassifyRepository;
  14. use app\common\repositories\system\config\ConfigRepository;
  15. use app\common\repositories\system\config\ConfigValueRepository;
  16. use app\common\repositories\system\serve\ServeOrderRepository;
  17. use crmeb\basic\BaseController;
  18. use think\App;
  19. class DeliveryStation extends BaseController
  20. {
  21. protected $repository;
  22. public function __construct(App $app, DeliveryStationRepository $repository)
  23. {
  24. parent::__construct($app);
  25. $this->repository = $repository;
  26. }
  27. public function deliveryForm()
  28. {
  29. return app('json')->success(formToData($this->repository->deliveryForm()));
  30. }
  31. public function saveDeliveryConfig()
  32. {
  33. $status = $this->request->param('delivery_status') == 1 ? 1 : 0;
  34. $type = $this->request->param('delivery_type') == 1 ? 1 : 2;
  35. if ($type == 1) {
  36. $data = $this->request->params([
  37. 'delivery_type',
  38. 'dada_app_key',
  39. 'dada_app_sercret',
  40. 'dada_source_id'
  41. ]);
  42. } else {
  43. $data = $this->request->params([
  44. 'delivery_type',
  45. 'uupt_appkey',
  46. 'uupt_app_id',
  47. 'uupt_open_id',
  48. ]);
  49. }
  50. $data['delivery_status'] = $status;
  51. $cid = app()->make(ConfigClassifyRepository::class)->keyById('delivery_config');
  52. if (!$cid) return app('json')->fail('保存失败');
  53. app()->make(ConfigValueRepository::class)->save($cid, $data, 0);
  54. return app('json')->success('保存成功');
  55. }
  56. public function lst()
  57. {
  58. [$page, $limit] = $this->getPage();
  59. $where = $this->request->params(['keyword','station_name','status','mer_id']);
  60. $data = $this->repository->sysList($where, $page, $limit);
  61. return app('json')->success($data);
  62. }
  63. public function detail($id)
  64. {
  65. $data = $this->repository->detail($id, null);
  66. return app('json')->success($data);
  67. }
  68. public function getBalance()
  69. {
  70. return app('json')->success($this->repository->getBalance());
  71. }
  72. public function getRecharge()
  73. {
  74. return app('json')->success($this->repository->getRecharge());
  75. }
  76. /**
  77. * TODO 充值记录
  78. * @author Qinii
  79. * @day 2/18/22
  80. */
  81. public function payLst()
  82. {
  83. [$page, $limit] = $this->getPage();
  84. $where = $this->request->params(['mer_id','date']);
  85. $where['type'] = 20;
  86. $data = app()->make(ServeOrderRepository::class)->getList($where, $page, $limit);
  87. return app('json')->success($data);
  88. }
  89. public function options()
  90. {
  91. return app('json')->success($this->repository->getOptions(null));
  92. }
  93. }