DeliveryStation.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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\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. /**
  20. * 同城配送门店
  21. */
  22. class DeliveryStation extends BaseController
  23. {
  24. protected $repository;
  25. public function __construct(App $app, DeliveryStationRepository $repository)
  26. {
  27. parent::__construct($app);
  28. $this->repository = $repository;
  29. }
  30. /**
  31. * 配置表单
  32. * @return \think\response\Json
  33. * @author Qinii
  34. */
  35. public function deliveryForm()
  36. {
  37. return app('json')->success(formToData($this->repository->deliveryForm()));
  38. }
  39. /**
  40. * 配置保存
  41. * @return \think\response\Json
  42. * @author Qinii
  43. */
  44. public function saveDeliveryConfig()
  45. {
  46. $status = $this->request->param('delivery_status') == 1 ? 1 : 0;
  47. $type = $this->request->param('delivery_type') == 1 ? 1 : 2;
  48. if ($type == 1) {
  49. $data = $this->request->params([
  50. 'delivery_type',
  51. 'dada_app_key',
  52. 'dada_app_sercret',
  53. 'dada_source_id'
  54. ]);
  55. } else {
  56. $data = $this->request->params([
  57. 'delivery_type',
  58. 'uupt_appkey',
  59. 'uupt_app_id',
  60. 'uupt_open_id',
  61. ]);
  62. }
  63. $data['delivery_status'] = $status;
  64. $cid = app()->make(ConfigClassifyRepository::class)->keyById('delivery_config');
  65. if (!$cid) return app('json')->fail('保存失败');
  66. app()->make(ConfigValueRepository::class)->save($cid, $data, 0);
  67. return app('json')->success('保存成功');
  68. }
  69. /**
  70. * 列表
  71. * @return \think\response\Json
  72. * @author Qinii
  73. */
  74. public function lst()
  75. {
  76. [$page, $limit] = $this->getPage();
  77. $where = $this->request->params(['keyword', 'station_name', 'status', 'mer_id']);
  78. $data = $this->repository->sysList($where, $page, $limit);
  79. return app('json')->success($data);
  80. }
  81. /**
  82. * 详情
  83. * @param $id
  84. * @return \think\response\Json
  85. * @author Qinii
  86. */
  87. public function detail($id)
  88. {
  89. $data = $this->repository->detail($id, null);
  90. return app('json')->success($data);
  91. }
  92. /**
  93. * 获取余额
  94. * @return \think\response\Json
  95. * @author Qinii
  96. */
  97. public function getBalance()
  98. {
  99. return app('json')->success($this->repository->getBalance());
  100. }
  101. /**
  102. * 获取充值地址
  103. * @return \think\response\Json
  104. * @author Qinii
  105. */
  106. public function getRecharge()
  107. {
  108. return app('json')->success($this->repository->getRecharge());
  109. }
  110. /**
  111. * 充值记录
  112. * @author Qinii
  113. * @day 2/18/22
  114. */
  115. public function payLst()
  116. {
  117. [$page, $limit] = $this->getPage();
  118. $where = $this->request->params(['mer_id', 'date']);
  119. $where['type'] = 20;
  120. $data = app()->make(ServeOrderRepository::class)->getList($where, $page, $limit);
  121. return app('json')->success($data);
  122. }
  123. public function options()
  124. {
  125. return app('json')->success($this->repository->getOptions(null));
  126. }
  127. }