UserController.php 3.2 KB

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