ShopClass.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace bizHd\merchant\classes;
  3. use common\components\httpUtil;
  4. use common\components\qrCodeUtil;
  5. use common\components\util;
  6. use Yii;
  7. use bizHd\base\classes\BaseClass;
  8. class ShopClass extends BaseClass
  9. {
  10. public static $baseFile = '\bizHd\merchant\models\Shop';
  11. public static function getShopList($where)
  12. {
  13. $list = self::getList('*', $where, 'addTime DESC');
  14. return $list;
  15. }
  16. //获取商家默认的门店ID ssh 2020.1.19
  17. public static function getDefaultShopId($merchant)
  18. {
  19. return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
  20. }
  21. //取商家所有门店 ssh 2020.2.29
  22. public static function getAllShop($sjId)
  23. {
  24. return self::getAllByCondition(['sjId' => $sjId]);
  25. }
  26. //验证所属权限 ssh 2020.2.29
  27. public static function valid($shop, $sjId)
  28. {
  29. if (empty($shop)) {
  30. util::fail('门店无效');
  31. }
  32. if (isset($shop['sjId']) == false || $shop['sjId'] != $sjId) {
  33. util::fail('您无法访问');
  34. }
  35. }
  36. //删除门店 ssh 2020.3.1
  37. public static function deleteShop($shop)
  38. {
  39. if (isset($shop['default']) && $shop['default'] == 1) {
  40. util::fail('默认门店不允许删除');
  41. }
  42. $id = $shop['id'];
  43. self::updateById($id, ['delStatus' => 1]);
  44. }
  45. //生成收款码 ssh 2020.3.9
  46. public static function generateGatheringCode($sjId, $shopId)
  47. {
  48. $url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$shopId}";
  49. //强制转成https
  50. $url = httpUtil::becomeHttps($url);
  51. $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $sjId, $shopId, '', 10);
  52. $imgUrl = Yii::$app->params['hdImgHost'] . 'gathering/1.jpg?x-oss-process=image/watermark,image_' . base64_encode($gatheringCode . '?x-oss-process=image/resize,P_55') . ',g_nw,x_278,y_465/watermark,image_' . base64_encode('gathering/logo.jpg') . ',g_nw,x_510,y_685';
  53. return $imgUrl;
  54. }
  55. }