UserController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace saas\controllers;
  3. use biz\merchant\classes\MerchantExtendClass;
  4. use biz\merchant\services\MerchantAssetService;
  5. use biz\merchant\services\MerchantExtendService;
  6. use biz\merchant\services\ShopService;
  7. use biz\retail\services\RetailAssetService;
  8. use biz\user\services\UserService;
  9. use common\components\dirUtil;
  10. use common\components\httpUtil;
  11. use common\components\qrCodeUtil;
  12. use common\components\util;
  13. use Yii;
  14. class UserController extends BaseController
  15. {
  16. public function actionList()
  17. {
  18. $get = Yii::$app->request->get();
  19. $type = isset($get['type']) ? $get['type'] : -1;
  20. $where = [];
  21. switch ($type) {
  22. case 1:
  23. //粉丝
  24. $where['subscribe'] = 1;
  25. break;
  26. case 2:
  27. //会员
  28. $where['member>'] = -1;
  29. break;
  30. default:
  31. }
  32. $list = UserService::getUserList($where);
  33. $asset = RetailAssetService::getAsset();
  34. $list['asset'] = $asset;
  35. util::success($list);
  36. }
  37. //客户列表 shish 2019.11.30
  38. public function actionOaList()
  39. {
  40. $get = Yii::$app->request->get();
  41. $type = isset($get['type']) ? $get['type'] : -1;
  42. $merchantId = 12358;
  43. $where = ['merchantId' => $merchantId];
  44. switch ($type) {
  45. case 1:
  46. //粉丝
  47. $where['subscribe'] = 1;
  48. break;
  49. case 2:
  50. //会员
  51. $where['member>'] = -1;
  52. break;
  53. default:
  54. }
  55. $list = UserService::getUserList($where);
  56. $merchantAsset = MerchantAssetService::getByMerchantId($merchantId);
  57. $list['asset'] = $merchantAsset;
  58. util::success($list);
  59. }
  60. //会员申请码查看 shish 2020.2.15
  61. public function actionApplyCode()
  62. {
  63. $id = Yii::$app->request->get('id');
  64. $shop = ShopService::getById($id);
  65. $merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
  66. if (empty($merchantId)) {
  67. util::fail('没有找到商家');
  68. }
  69. $url = MerchantExtendClass::getApplyMemberCode($merchantId);
  70. echo "<img width='300' src='{$url}' />";
  71. }
  72. //收款码查看 shish 2020.2.20
  73. public function actionGatheringCode()
  74. {
  75. $id = Yii::$app->request->get('id');
  76. $shop = ShopService::getById($id);
  77. $merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
  78. if (empty($merchantId)) {
  79. util::fail('没有找到商家');
  80. }
  81. $gatheringCode = isset($shop['gatheringCode']) ? $shop['gatheringCode'] : '';
  82. $file = dirUtil::getImgDir() . $gatheringCode;
  83. $url = Yii::$app->params['mDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $id;
  84. $url = httpUtil::becomeHttps($url);
  85. if (empty($gatheringCode) || file_exists($file) == false) {
  86. //强制转成https
  87. $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $id, '', 10);
  88. ShopService::updateById($id, ['gatheringCode' => $gatheringCode]);
  89. }
  90. $imgUrl = Yii::$app->params['imgHost'] . $gatheringCode;
  91. echo '<br /><br />收款码<br /><br />';
  92. echo "<img width='300' src='{$imgUrl}' /><br /><br />";
  93. echo $url;
  94. $mall = Yii::$app->params['mDomain'] . "/#/?account=" . $merchantId;
  95. echo "<br /><br />商城首页:<br />" . httpUtil::becomeHttps($mall);
  96. }
  97. }