UserController.php 3.1 KB

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