76 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace app\common\model\manystore;
 | 
						|
 | 
						|
use app\admin\model\dyqc\ManystoreShop;
 | 
						|
use app\common\model\BaseModel;
 | 
						|
use think\Model;
 | 
						|
use traits\model\SoftDelete;
 | 
						|
 | 
						|
class LakalaBusiness extends BaseModel
 | 
						|
{
 | 
						|
 | 
						|
    use SoftDelete;
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    // 表名
 | 
						|
    protected $name = 'manystore_lakala_business';
 | 
						|
    
 | 
						|
    // 自动写入时间戳字段
 | 
						|
    protected $autoWriteTimestamp = 'integer';
 | 
						|
 | 
						|
    // 定义时间戳字段名
 | 
						|
    protected $createTime = 'createtime';
 | 
						|
    protected $updateTime = 'updatetime';
 | 
						|
    protected $deleteTime = 'deletetime';
 | 
						|
 | 
						|
    // 追加属性
 | 
						|
    protected $append = [
 | 
						|
        'status_text'
 | 
						|
    ];
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
    public function getStatusList()
 | 
						|
    {
 | 
						|
        return ['1' => __('Status 1'), '2' => __('Status 2')];
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
 | 
						|
        $list = $this->getStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    public function manystore()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\admin\model\Manystore', 'store_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function shop()
 | 
						|
    {
 | 
						|
        return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
    public static function checkBind($user_id,$check=false){
 | 
						|
        //判断是否对接了lakala进件
 | 
						|
        if(config("site.activity_price_lakala_switch") || $check){
 | 
						|
            if(config("site.activity_pay_process") == "lakala" || $check){
 | 
						|
                $lakalaBusiness = self::where("user_id",$user_id)->find();
 | 
						|
                if(!$lakalaBusiness){
 | 
						|
                    throw new \Exception("当前商户未完成拉卡拉进件以及平台绑定!");
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
}
 |