MerchantController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace pt\controllers;
  3. use bizTy\sj\classes\MerchantClass;
  4. use bizTy\sj\services\MerchantExtendService;
  5. use Yii;
  6. use bizHd\admin\services\AdminService;
  7. use bizTy\sj\services\MerchantService;
  8. use common\components\util;
  9. class MerchantController extends BaseController
  10. {
  11. //商家列表 shish 2019.12.20
  12. public function actionList()
  13. {
  14. $get = Yii::$app->request->get();
  15. $style = $get['style'] ?? MerchantClass::STYLE_RETAIL;
  16. $where = [];
  17. if (!empty($style)) {
  18. $where['style'] = $style;
  19. }
  20. $list = MerchantService::getMerchantList($where);
  21. util::success($list);
  22. }
  23. //获取当前登陆老板的帐号详情,官网购买套餐时使用 shish 2020.1.11
  24. public function actionLoginAccount()
  25. {
  26. $userId = $this->userId;
  27. $admin = AdminService::getByCondition(['platUserId' => $userId]);
  28. if (empty($admin)) {
  29. util::fail('没有找到注册信息');
  30. }
  31. $merchantId = $admin['merchantId'];
  32. $merchant = MerchantService::getMerchantById($merchantId);
  33. util::success($merchant);
  34. }
  35. //商家信息 shish 2020.1.11
  36. public function actionDetail()
  37. {
  38. $id = Yii::$app->request->get('id');
  39. $merchant = MerchantService::getMerchantById(12358);
  40. util::success($merchant);
  41. }
  42. //平台帐号激活 shish 2020.2.15
  43. public function actionAddPlatformMerchant()
  44. {
  45. MerchantService::initOpenMerchant();
  46. echo 'ok';
  47. }
  48. //注释商家 shish 2020.3.4
  49. public function actionCancel()
  50. {
  51. if (getenv('YII_ENV') != 'test') {
  52. util::fail('只有测试环境才能操作');
  53. }
  54. $id = Yii::$app->request->get('id', 0);
  55. $merchant = MerchantService::getById($id, true);
  56. if (isset($merchant->wxAppId) && empty($merchant->wxAppId)) {
  57. util::fail('已注销/未授权');
  58. }
  59. $merchant->wxAppId = '';
  60. $merchant->miniAppId = '';
  61. $merchant->save();
  62. $extend = MerchantExtendService::getByMerchantId($id, true);
  63. $extend->miniAppId = '';
  64. $extend->wxAppId = '';
  65. $extend->save();
  66. util::complete();
  67. }
  68. //商家h5商城二维码 shish 2020.4.30
  69. public function actionGetH5MallQrCode()
  70. {
  71. $id = Yii::$app->request->get('id', 0);
  72. $imgUrl = MerchantService::getH5MallQrCode($id);
  73. util::success(['imgUrl' => $imgUrl]);
  74. }
  75. }