PlatLog.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/9/22
  8. * Time: 13:37
  9. */
  10. namespace business\common\models;
  11. use app\common\models\BaseModel;
  12. use business\common\services\BusinessService;
  13. use Illuminate\Database\Eloquent\Builder;
  14. class PlatLog extends BaseModel
  15. {
  16. public $table = 'yz_business_plat_log';
  17. public $timestamps = true;
  18. protected $guarded = [];
  19. protected $appends = [];
  20. protected $casts = [];
  21. public function getPlatLogId($uid = 0)
  22. {
  23. $res = self::getPlatLog($uid);
  24. return $res->final_plat_id ?: 0;
  25. }
  26. public function getPlatLog($uid = 0)
  27. {
  28. if ($uid = $uid ?: \YunShop::app()->getMemberId()) {
  29. $model = self::where('uid', $uid)->first();
  30. if ($model && $model->final_plat_id) {
  31. $res = BusinessService::checkBusinessRight($model->final_plat_id, $uid);
  32. if (!$res['identity']) {
  33. $model->final_plat_id = 0;
  34. $model->save();
  35. }
  36. }
  37. if (!$model) {
  38. $model = self::create([
  39. 'uniacid' => \YunShop::app()->uniacid,
  40. 'uid' => $uid,
  41. 'final_plat_id' => 0
  42. ]);
  43. }
  44. } else {
  45. $model = (Object)[];
  46. }
  47. return $model;
  48. }
  49. }