GhsController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. namespace hd\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\recharge\classes\RechargeHbClass;
  5. use biz\shop\classes\ShopClass;
  6. use bizGhs\custom\classes\CustomClass;
  7. use bizGhs\custom\classes\CustomLevelClass;
  8. use bizHd\stat\classes\StatVisitClass;
  9. use common\components\util;
  10. use Yii;
  11. class GhsController extends BaseController
  12. {
  13. public $guestAccess = ['info'];
  14. public static $levelMap = [
  15. 'pt' => ['name' => '普店', 'num' => 0, 'amount' => 0, 'key' => ''],
  16. 'hj' => ['name' => '银店', 'num' => 0, 'amount' => 0, 'key' => 'hj'],
  17. 'zs' => ['name' => '金店', 'num' => 0, 'amount' => 0, 'key' => 'zs'],
  18. ];
  19. //供应商列表 ssh 2021.1.24
  20. public function actionList()
  21. {
  22. $where = [];
  23. $where['ownShopId'] = $this->shopId;
  24. $respond = GhsClass::getGhsList($where);
  25. util::success($respond);
  26. }
  27. //详情 ssh 2021.4.11
  28. public function actionDetail()
  29. {
  30. $id = Yii::$app->request->get('id');
  31. $info = GhsClass::getGhsInfo($id);
  32. $giveLevel = $info['giveLevel'] ?? 0;
  33. $levelMap = CustomClass::$nickNameMap;
  34. $giveLevelName = $levelMap[$giveLevel] ?? '散客';
  35. $info['giveLevelName'] = $giveLevelName;
  36. GhsClass::valid($info, $this->shopId);
  37. //是否有充值送红包活动
  38. $ghsShopId = $info['shopId'] ?? 0;
  39. $ghsShop = ShopClass::getById($ghsShopId, true);
  40. $info['hasRechargeHb'] = $ghsShop->recharge ?? 0;
  41. $hb = RechargeHbClass::getByCondition(['shopId' => $ghsShopId, 'delStatus' => 0], true, 'totalHb DESC');
  42. $info['hasRechargeHbAmount'] = $hb->totalHb ?? 0;
  43. $info['xrFl'] = $ghsShop->xrFl ?? 0;
  44. $info['xrFlAmount'] = $ghsShop->xrFlAmount ?? 0;
  45. $info['tjFl'] = $ghsShop->tjFl ?? 0;
  46. $info['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0;
  47. //预订单的最低公斤数和每公斤服务费
  48. $info['kiloFee'] = $ghsShop->kiloFee ?? 0;
  49. $info['miniKilo'] = $ghsShop->miniKilo ?? 0;
  50. util::success($info);
  51. }
  52. //根据门店获取供应商信息 ssh 2021.4.14
  53. public function actionInfo()
  54. {
  55. $shopId = Yii::$app->request->get('shopId');
  56. if (isset($this->shopId) && !empty($this->shopId)) {
  57. $ghs = GhsClass::build($shopId, $this->shopId);
  58. //是否有充值送红包活动
  59. $ghsShopId = $ghs['shopId'] ?? 0;
  60. $ghsShop = ShopClass::getById($ghsShopId, true);
  61. $ghs['hasRechargeHb'] = $ghsShop->recharge ?? 0;
  62. $hb = RechargeHbClass::getByCondition(['shopId' => $ghsShopId, 'delStatus' => 0], true, 'totalHb DESC');
  63. $ghs['hasRechargeHbAmount'] = $hb->totalHb ?? 0;
  64. $map = CustomClass::$nickNameMap;
  65. $giveLevel = $ghs['giveLevel'] ?? 0;
  66. $ghs['giveLevelName'] = $map[$giveLevel] ?? '';
  67. $ghs['xrFl'] = $ghsShop->xrFl ?? 0;
  68. $ghs['xrFlAmount'] = $ghsShop->xrFlAmount ?? 0;
  69. $ghs['tjFl'] = $ghsShop->tjFl ?? 0;
  70. $ghs['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0;
  71. } else {
  72. //没有开店也给显示供应商信息
  73. $shop = ShopClass::getShopInfo($shopId);
  74. $shopName = $shop['shopName'] ?? '';
  75. $sjName = $shop['merchantName'] ?? '';
  76. $default = $shop['default'] ?? 0;
  77. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  78. $ghs = [
  79. 'id' => 0,
  80. 'name' => $name,
  81. 'debtAmount' => 0.00,
  82. 'expendAmount' => 0.00,
  83. 'giveLevel' => 0,
  84. 'giveLevelName' => '普通',
  85. 'xrFl' => 0,
  86. 'xrFlAmount' => 0,
  87. 'tjFl' => 0,
  88. 'tjFlAmount' => 0,
  89. ];
  90. }
  91. util::success($ghs);
  92. }
  93. //获取客户等级 ssh 20211016
  94. public function actionGetCustomLevel()
  95. {
  96. $id = Yii::$app->request->get('id');
  97. $info = GhsClass::getById($id, true);
  98. GhsClass::valid($info, $this->shopId);
  99. $ghsShopId = $info->shopId ?? 0;
  100. $info = CustomLevelClass::getByCondition(['shopId' => $ghsShopId]);
  101. $map = self::$levelMap;
  102. foreach ($map as $key => $val) {
  103. $flag = $val['key'] ?? '';
  104. if (empty($flag)) {
  105. $map[$key]['num'] = $info["num"] ?? 0;
  106. $map[$key]['amount'] = $info["amount"] ?? 0;
  107. } else {
  108. $map[$key]['num'] = $info[$flag . "Num"] ?? 0;
  109. $map[$key]['amount'] = $info[$flag . "Amount"] ?? 0;
  110. }
  111. }
  112. util::success(['list' => $map]);
  113. }
  114. //访问供货商的商城 ssh 20211022
  115. public function actionVisitMall()
  116. {
  117. $id = Yii::$app->request->get('id');
  118. $info = GhsClass::getById($id, true);
  119. GhsClass::valid($info, $this->shopId);
  120. $customId = $info->customId ?? 0;
  121. $custom = CustomClass::getById($customId, true);
  122. if (empty($custom)) {
  123. util::fail('没有找到客户');
  124. }
  125. StatVisitClass::addGhsCustomVisit($info, $custom);
  126. util::complete();
  127. }
  128. //补充缺失的供货商 ssh 20211027
  129. public function actionBcGhs()
  130. {
  131. util::fail('过几天再试');
  132. GhsClass::bcGhs($this->shopId);
  133. util::complete('载入成功');
  134. }
  135. }