Merchant.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\merchant\system;
  12. use app\common\repositories\store\MerchantTakeRepository;
  13. use app\validate\merchant\MerchantTakeValidate;
  14. use crmeb\basic\BaseController;
  15. use app\common\repositories\system\merchant\MerchantRepository;
  16. use app\validate\merchant\MerchantUpdateValidate;
  17. use crmeb\jobs\ChangeMerchantStatusJob;
  18. use think\App;
  19. use think\facade\Queue;
  20. /**
  21. * Class Merchant
  22. * @package app\controller\merchant\system
  23. * @author xaboy
  24. * @day 2020/6/25
  25. */
  26. class Merchant extends BaseController
  27. {
  28. /**
  29. * @var MerchantRepository
  30. */
  31. protected $repository;
  32. /**
  33. * Merchant constructor.
  34. * @param App $app
  35. * @param MerchantRepository $repository
  36. */
  37. public function __construct(App $app, MerchantRepository $repository)
  38. {
  39. parent::__construct($app);
  40. $this->repository = $repository;
  41. }
  42. /**
  43. * @return mixed
  44. * @throws \FormBuilder\Exception\FormBuilderException
  45. * @author xaboy
  46. * @day 2020/6/25
  47. */
  48. public function updateForm()
  49. {
  50. return app('json')->success(formToData($this->repository->merchantForm($this->request->merchant()->toArray())));
  51. }
  52. /**
  53. * @param MerchantUpdateValidate $validate
  54. * @return mixed
  55. * @author xaboy
  56. * @day 2020/6/25
  57. */
  58. public function update(MerchantUpdateValidate $validate)
  59. {
  60. $data = $this->request->params(['mer_info', 'service_phone', 'mer_avatar', 'mer_banner', 'mer_state', 'mini_banner', 'mer_keyword', 'mer_address', 'long', 'lat']);
  61. $validate->check($data);
  62. $this->request->merchant()->save($data);
  63. Queue::push(ChangeMerchantStatusJob::class, $this->request->merId());
  64. return app('json')->success('修改成功');
  65. }
  66. /**
  67. * @return mixed
  68. * @author xaboy
  69. * @day 2020/7/21
  70. */
  71. public function info()
  72. {
  73. $merchant = $this->request->merchant();
  74. return app('json')->success($merchant->append(['merchantCategory'])->hidden(['mark', 'reg_admin_id', 'sort'])->toArray());
  75. }
  76. /**
  77. * @param MerchantTakeRepository $repository
  78. * @return mixed
  79. * @author xaboy
  80. * @day 2020/8/1
  81. */
  82. public function takeInfo(MerchantTakeRepository $repository)
  83. {
  84. $merId = $this->request->merId();
  85. return app('json')->success($repository->get($merId) + systemConfig(['tx_map_key']));
  86. }
  87. /**
  88. * @param MerchantTakeValidate $validate
  89. * @param MerchantTakeRepository $repository
  90. * @return mixed
  91. * @author xaboy
  92. * @day 2020/8/1
  93. */
  94. public function take(MerchantTakeValidate $validate, MerchantTakeRepository $repository)
  95. {
  96. $data = $this->request->params(['mer_take_status', 'mer_take_name', 'mer_take_phone', 'mer_take_address', 'mer_take_location', 'mer_take_day', 'mer_take_time']);
  97. $validate->check($data);
  98. $repository->set($this->request->merId(), $data);
  99. return app('json')->success('设置成功');
  100. }
  101. }