xieruidong 2 years ago
parent
commit
1ae2655196
38 changed files with 0 additions and 2004 deletions
  1. 0 61
      application/admin/model/AdIndexOrderedFlow.php
  2. 0 26
      application/admin/model/Mobile.php
  3. 0 31
      application/admin/model/MobileAnchor.php
  4. 0 42
      application/admin/model/MobileExportLog.php
  5. 0 36
      application/admin/model/MobileOrder.php
  6. 0 27
      application/admin/model/MobileOrderAdmin.php
  7. 0 11
      application/admin/model/MobileOrderNo.php
  8. 0 10
      application/admin/model/MobileOrderOperation.php
  9. 0 19
      application/admin/model/MobileOrderRefundLog.php
  10. 0 32
      application/admin/model/MobileOrderSubAnchor.php
  11. 0 25
      application/admin/model/MobileOrderSubRemark.php
  12. 0 10
      application/admin/model/MobilePriceLog.php
  13. 0 18
      application/admin/model/MobileUpload.php
  14. 0 10
      application/admin/model/MobileUploadLog.php
  15. 0 48
      application/common/command/AreaCommand.php
  16. 0 25
      application/common/command/EsImportCommand.php
  17. 0 19
      application/common/command/EsMapCommand.php
  18. 0 29
      application/common/command/EsMobileCommand.php
  19. 0 32
      application/common/command/OrderExpiredCommand.php
  20. 0 12
      application/common/model/AdIndexOrderedFlow.php
  21. 0 458
      application/common/model/Mobile.php
  22. 0 48
      application/common/model/MobileExportLog.php
  23. 0 41
      application/common/model/MobileHoldLog.php
  24. 0 16
      application/common/model/MobileId.php
  25. 0 51
      application/common/model/MobileInfo.php
  26. 0 331
      application/common/model/MobileOrder.php
  27. 0 29
      application/common/model/MobileOrderInfo.php
  28. 0 16
      application/common/model/MobileOrderMind.php
  29. 0 20
      application/common/model/MobileOrderNo.php
  30. 0 29
      application/common/model/MobileOrderOperation.php
  31. 0 57
      application/common/model/MobileOrderRefundLog.php
  32. 0 13
      application/common/model/MobileOrderRules.php
  33. 0 15
      application/common/model/MobileOrderStatus.php
  34. 0 26
      application/common/model/MobilePriceLog.php
  35. 0 66
      application/common/model/MobileSub.php
  36. 0 253
      application/service/EsMobileService.php
  37. 0 6
      application/service/mobile_get/ChinaMobileService.php
  38. 0 6
      application/service/mobile_get/MobileGetService.php

+ 0 - 61
application/admin/model/AdIndexOrderedFlow.php

@@ -1,61 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class AdIndexOrderedFlow extends Model
-{
-
-    
-
-    
-
-    // 表名
-    protected $table = 'ad_index_ordered_flow';
-    
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
-
-    // 定义时间戳字段名
-    protected $createTime = false;
-    protected $updateTime = false;
-    protected $deleteTime = false;
-
-    // 追加属性
-    protected $append = [
-        'create_time_text',
-        'update_time_text'
-    ];
-    
-
-    
-
-
-
-    public function getCreateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-
-    public function getUpdateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-    protected function setCreateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-    protected function setUpdateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-
-}

+ 0 - 26
application/admin/model/Mobile.php

@@ -1,26 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class Mobile extends \app\common\model\Mobile
-{
-    // 追加属性
-    protected $append = [
-    ];
-    public function info()
-    {
-        return parent::info()->setEagerlyType(0); // TODO: Change the autogenerated stub
-    }
-    public function proxy(){
-        return $this->belongsTo(Admin::class,'proxy_id','id',[])->setEagerlyType(0);
-    }
-    public function getLogoAttr($logo,$data=[]){
-        return $logo;
-    }
-    public function getActivityTimeEndAttr($a){
-        return $a;
-    }
-}

+ 0 - 31
application/admin/model/MobileAnchor.php

@@ -1,31 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileAnchor extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $readonly=['admin_id'];
-    protected static function init()
-    {
-        self::afterDelete(function (self $anchor){
-            $anchor->mobileOrder()->update(['mobile_anchor_id'=>0]);
-            $anchor->mobileOrderSubAnchor()->delete();
-        });
-        self::beforeInsert(function (self $anchor){
-            $anchor['admin_id']=$_SERVER['admin']['id'];
-        });
-    }
-    public function mobileOrder(){
-        return $this->hasMany(MobileOrder::class);
-    }
-    public function mobileOrderSubAnchor(){
-        return $this->hasMany(MobileOrderSubAnchor::class,'sub_mobile_anchor_id');
-    }
-    public function admin(){
-        return $this->belongsTo(Admin::class)->setEagerlyType(0);
-    }
-}

+ 0 - 42
application/admin/model/MobileExportLog.php

@@ -1,42 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileExportLog extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-    protected $append=['file_url','name'];
-
-    public static function exists(){
-        return self::where('status',0)->find();
-    }
-    public static function make($adminId){
-        return self::create([
-            'admin_id'=>$adminId,
-            //'filename'=>'/uploads/mobile_export/'.session_create_id().'.csv',
-        ]);
-    }
-
-    public function getFileUrlAttr($_,$model){
-        return request()->domain().$model['filename'];
-    }
-    public function getNameAttr($_,$model){
-        return basename($model['filename']);
-    }
-
-    protected static function init()
-    {
-        self::afterDelete(function (self $exportLog){
-            if($exportLog['filename']) {
-                $filename = ROOT_PATH . '/public' . $exportLog['filename'];
-                if (file_exists($filename)) {
-                    unlink($filename);
-                }
-            }
-        });
-    }
-}

+ 0 - 36
application/admin/model/MobileOrder.php

@@ -1,36 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-use think\model\relation\BelongsTo;
-use think\model\relation\HasMany;
-use think\model\relation\HasOne;
-
-
-class MobileOrder extends \app\common\model\MobileOrder
-{
-    public function getPhoneOrderCountAttr(){
-        $no=$this['phone'];
-        static $arr=[];
-        if(!isset($arr[$no])){
-            $arr[$no]=self::where('phone',$no)->where('type',1)->count();
-        }
-        return $arr[$no];
-    }
-
-    public function subRemark(): HasMany
-    {
-        return $this->hasMany(MobileOrderSubRemark::class)->order('mobile_order_sub_remark.mobile_order_sub_remark_id','desc');
-    }
-
-    public function subAnchor(): HasOne
-    {
-        return $this->hasOne(MobileOrderSubAnchor::class);
-    }
-
-    public function anchor(): BelongsTo
-    {
-        return $this->belongsTo(MobileAnchor::class,'mobile_anchor_id','id',[],'left')->setEagerlyType(0);
-    }
-}

+ 0 - 27
application/admin/model/MobileOrderAdmin.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-/**
- * 配置模型
- */
-class MobileOrderAdmin extends Model
-{
-    public static function add(\app\common\model\MobileOrder $mobileOrder,$when,$admin_id){
-        if($when){
-            $exists=self::where('mobile_order_id',$mobileOrder['id'])->where('admin_id',$admin_id)->value('id');
-            if(!$exists) {
-                self::create([
-                    'mobile_order_id' => $mobileOrder['id'],
-                    'admin_id' => $admin_id,
-                ]);
-            }
-        }
-    }
-
-    public function admin(){
-        return $this->belongsTo(Admin::class,'admin_id','id',[])->setEagerlyType(0);
-    }
-}

+ 0 - 11
application/admin/model/MobileOrderNo.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileOrderNo extends \app\common\model\MobileOrderNo
-{
-    protected $append=['city_name'];
-}

+ 0 - 10
application/admin/model/MobileOrderOperation.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-/**
- * 配置模型
- */
-class MobileOrderOperation extends \app\common\model\MobileOrderOperation
-{
-}

+ 0 - 19
application/admin/model/MobileOrderRefundLog.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileOrderRefundLog extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-
-    public function od(){
-        return $this->belongsTo(MobileOrder::class)->setEagerlyType(0);
-    }
-    public function admin(){
-        return $this->belongsTo(Admin::class,'refunduser_id')->setEagerlyType(0);
-    }
-}

+ 0 - 32
application/admin/model/MobileOrderSubAnchor.php

@@ -1,32 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileOrderSubAnchor extends Model
-{
-    protected $autoWriteTimestamp=false;
-    public function admin(){
-        return $this->belongsTo(Admin::class,'sub_admin_id','id',[],'left');
-    }
-    public function mobileAnchor(){
-        return $this->belongsTo(MobileAnchor::class,'sub_mobile_anchor_id','id',[],'left');
-    }
-    public static function sync(MobileOrder $mobileOrder,$mobileAnchorId){
-        $admin=Admin::get($mobileOrder['s_id']);
-        if(!$admin){
-            return;
-        }
-        if($subAnchor=$mobileOrder->subAnchor()->where('sub_admin_id',$admin['id'])->find()){
-            $subAnchor['sub_mobile_anchor_id']=$mobileAnchorId;
-            $subAnchor->save();
-        }else{
-            $mobileOrder->subAnchor()->save([
-                'sub_admin_id'=>$admin['id'],
-                'sub_mobile_anchor_id'=>$mobileAnchorId,
-            ]);
-        }
-    }
-}

+ 0 - 25
application/admin/model/MobileOrderSubRemark.php

@@ -1,25 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileOrderSubRemark extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-    protected $append=[
-        'create_time_format',
-        'create_time_format_short',
-    ];
-    public function getCreateTimeFormatAttr($a,$m){
-        return date('m/d H:i',$m['create_time']);
-    }
-    public function getCreateTimeFormatShortAttr($a,$m){
-        return date('m/d',$m['create_time']);
-    }
-    public function admin(){
-        return $this->belongsTo(Admin::class,'sub_admin_id','id',[],'left');
-    }
-}

+ 0 - 10
application/admin/model/MobilePriceLog.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobilePriceLog extends \app\common\model\MobilePriceLog
-{
-}

+ 0 - 18
application/admin/model/MobileUpload.php

@@ -1,18 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileUpload extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-    protected $type=[
-        'params'=>'json',
-    ];
-    public function log(){
-        return $this->hasMany(MobileUploadLog::class);
-    }
-}

+ 0 - 10
application/admin/model/MobileUploadLog.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace app\admin\model;
-
-use think\Model;
-
-
-class MobileUploadLog extends Model
-{
-}

+ 0 - 48
application/common/command/AreaCommand.php

@@ -1,48 +0,0 @@
-<?php
-namespace app\common\command;
-
-use app\common\model\Area;
-use think\console\Command;
-use think\console\Input;
-use think\console\Output;
-use think\Db;
-
-class AreaCommand extends Command{
-    protected function configure()
-    {
-        $this->setName('area')->setDescription('地区信息');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        $this->make();
-    }
-    public function make()
-    {
-        $exists= Area::find(1);
-        if(!$exists){
-            Db::execute("truncate table area");
-            $arr=json_decode(file_get_contents(EXTEND_PATH.'/pcas-code.json'));
-            $this->circle($arr);
-        }
-    }
-
-    protected function circle($arr,$code=null){
-        foreach ($arr as $area){
-            if($code){
-                $temp=Area::where('code',$code)->find();
-            }else{
-                $temp=[];
-            }
-            Area::insert([
-                'pid'=>$temp['id']??0,
-                'name'=>$area->name,
-                'code'=>$area->code,
-                'level'=>($temp['level']??0)+1,
-            ]);
-            if(!empty($area->children)) {
-                $this->circle($area->children,$area->code);
-            }
-        }
-    }
-}

+ 0 - 25
application/common/command/EsImportCommand.php

@@ -1,25 +0,0 @@
-<?php
-namespace app\common\command;
-
-use app\common\model\Mobile;
-use app\service\EsMobileService;
-use think\console\Command;
-use think\console\Input;
-use think\console\Output;
-
-class EsImportCommand extends Command{
-    protected function configure()
-    {
-        $this->setName('es:import')->setDescription('test');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        $count=0;
-        Mobile::where('type',1)->chunk(10000,function ($mobiles)use (&$count){
-            EsMobileService::addMobiles($mobiles);
-            $count+=10000;
-            $this->output->info("count:{$count}");
-        });
-    }
-}

+ 0 - 19
application/common/command/EsMapCommand.php

@@ -1,19 +0,0 @@
-<?php
-namespace app\common\command;
-
-use app\service\EsMobileService;
-use think\console\Command;
-use think\console\Input;
-use think\console\Output;
-
-class EsMapCommand extends Command{
-    protected function configure()
-    {
-        $this->setName('es:map')->setDescription('test');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        EsMobileService::mapping();
-    }
-}

+ 0 - 29
application/common/command/EsMobileCommand.php

@@ -1,29 +0,0 @@
-<?php
-namespace app\common\command;
-
-use app\service\EsMobileService;
-use think\console\Command;
-use think\console\Input;
-use think\console\input\Argument;
-use think\console\Output;
-
-class EsMobileCommand extends Command{
-    protected function configure()
-    {
-        $this->setName('es:mobile')
-            ->addArgument('action',Argument::REQUIRED,'执行的操作')
-            ->setDescription('es mobile');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        $action=$input->getArgument('action');
-        if($action=='delindex'){
-            EsMobileService::delIndex();
-        }elseif ($action=='delmobile'){
-            $count=EsMobileService::delByMobile();
-            $output->comment($count);
-        }
-        $output->info('success');
-    }
-}

+ 0 - 32
application/common/command/OrderExpiredCommand.php

@@ -1,32 +0,0 @@
-<?php
-namespace app\common\command;
-
-use app\common\model\MobileOrder;
-use think\console\Command;
-use think\console\Input;
-use think\console\Output;
-use think\Db;
-use think\Log;
-
-class OrderExpiredCommand extends Command{
-    protected function configure()
-    {
-        $this->setName('order:expired')->setDescription('订单超时关闭');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        $orders= MobileOrder::expired()->field('id')->select();
-        foreach ($orders as $order){
-            try {
-                Db::startTrans();
-                $order=MobileOrder::where('id',$order['id'])->lock(true)->find();
-                $order->cancel();
-                Db::commit();
-            }catch (\Exception $e){
-                Log::error("关闭订单[$order->id]失败:{$e->getMessage()}");
-            }
-        }
-        $output->info('success');
-    }
-}

+ 0 - 12
application/common/model/AdIndexOrderedFlow.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- */
-class AdIndexOrderedFlow extends Model
-{
-    protected $autoWriteTimestamp=true;
-}

+ 0 - 458
application/common/model/Mobile.php

@@ -1,458 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use app\admin\model\Network;
-use app\common\service\MobileComputer;
-use app\common\service\MobilePriceLogService;
-use app\service\EsMobileService;
-use think\Cache;
-use think\Db;
-use think\db\Query;
-use think\helper\Str;
-use think\Model;
-use traits\model\SoftDelete;
-
-/**
- * 配置模型
- */
-class Mobile extends Model
-{
-    public static $status=[
-        0=>'正常',
-        1=>'已售',
-        2=>'已下架',
-        3=>'禁止下单',
-    ];
-    public static $flowStatus=[
-        0=>'售卖中',
-        1=>'仓库中',
-        2=>'已下架',
-    ];
-    protected $append=[
-        'saled',
-        'is_private',
-    ];
-    protected $readonly=['no'];
-    protected $autoWriteTimestamp='int';
-    protected $hidden=[];
-    public function info(){
-        return $this->hasOne(MobileInfo::class);
-    }
-    public function orders(){
-        return $this->hasMany(MobileOrder::class);
-    }
-    public function proxy(){
-        return $this->belongsTo(Admin::class,'proxy_id');
-    }
-    public function holdLog(){
-        return $this->hasMany(MobileHoldLog::class);
-    }
-    public function sub(){
-        return $this->hasMany(MobileSub::class);
-    }
-    public function priceLog(){
-        return $this->hasMany(MobilePriceLog::class);
-    }
-    const BEAUTI=1;
-    const FLOW=2;
-
-
-    public function getSaledAttr($a,$b){
-        $s=$b['status']??0;
-        return $s===1?1:0;
-    }
-    #是否是民营
-    public function getIsPrivateAttr($_,$data){
-        $network=$data['network']?:'';
-        return mb_strpos($network,'中国')===false;
-    }
-    public function getLogoAttr($logo,$data=[]){
-        if($logo){
-            $arr=explode(',',$logo);
-            return array_shift($arr);
-        }
-        return null;
-    }
-
-
-    public function makeAmount(){
-        $mobile=$this;
-        if(empty($mobile['amount_base'])){
-            $mobile['amount_base']=0;
-        }
-        if(empty($mobile['amount_charge'])){
-            $mobile['amount_charge']=0;
-        }
-        if(!isset($mobile['is_activity'])){
-            $mobile['is_activity']=0;
-        }
-        if(!$mobile['is_activity']) {
-            $mobile['amount'] = $mobile['amount_base'] + $mobile['amount_charge'];
-        }else{
-            $mobile['amount'] = $mobile['amount_kill'] + $mobile['amount_charge'];
-            $mobile['activity_time']=time();
-        }
-    }
-    public function makeArea(){
-        $mobile=$this;
-        if(empty($mobile['city_id'])){
-            $mobile['city_id']=Area::getIdByName($mobile['city']??'',2);
-        }
-        if(empty($mobile['province_id'])){
-            if(!empty($mobile['province'])) {
-                $mobile['province_id'] = Area::getIdByName($mobile['province'],1);
-            }
-            if(!empty($mobile['city_id'])){
-                $mobile['province_id'] = Area::where('id',$mobile['city_id'])->value('pid');
-            }
-        }
-
-        if(!empty($mobile['province_id'])){
-            $mobile['province']=Area::where('id',$mobile['province_id'])->value('shortname');
-        }
-        if(!empty($mobile['city_id'])){
-            $mobile['city']=Area::where('id',$mobile['city_id'])->value('shortname');
-        }
-    }
-    public function makePriceLog(){
-        (new MobilePriceLogService)
-            ->setMobile($this)
-            ->setBeforePrice($this->origin['amount'])
-            ->setAfterPrice($this['amount'])
-            ->log();
-    }
-    public function makeRules(){
-        $mobile=$this;
-        if($this['type']==self::BEAUTI) {
-            foreach (MobileComputer::setMobile($mobile['no'])->filter() as $key => $value) {
-                $mobile[$key] = $value;
-            }
-        }
-    }
-    public function amountChangeColumn(){
-        return [
-            'amount_base',
-            'amount_charge',
-            'amount_kill',
-            'is_activity',
-        ];
-    }
-    public static function init()
-    {
-        self::beforeWrite(function (self $mobile){
-            if(isset($mobile['amount_di']) && isset($mobile['amount_base']) && $mobile['amount_di']>$mobile['amount_base']){
-                throw_user('底价不能大于售价');
-            }
-        });
-        self::beforeUpdate(function (self $mobile){
-            $data=$mobile->getChangedData();
-
-            if(isset($data['is_activity'])){
-                if($data['is_activity']==1) {
-                    $mobile['activity_time'] = time();
-                }else{
-                    $mobile->makeNotActivity(false);
-                }
-            }
-
-            if(isset($data['no'])){
-                $mobile->makeRules();
-            }
-            if(array_intersect(array_keys($data),$mobile->amountChangeColumn())){
-                $mobile->makeAmount();
-            }
-            $mobile->makeArea();
-            $mobile->makePriceLog();
-            $mobile->makeNetwork(true);
-
-            if(isset($data['sort']) && $data['sort']!=$mobile->origin['sort']){
-                $mobile->makeSort();
-            }
-            $mobile->makeSortLine();
-            if($mobile['is_activity'] && $mobile['amount_di']>$mobile['amount_kill']){
-                throw_user('底价不能大于秒杀价');
-            }
-        });
-        self::beforeInsert(function (self $mobile){
-            $mobile['sort']=self::max('sort')+1;
-            $mobile->makeAmount();
-            $mobile->makeRules();
-            $mobile->makeArea();
-            $mobile->makeNetwork();
-            $mobile['sort_line']=$mobile['sort'];
-        });
-        self::afterInsert(function (self $mobile){
-            if($mobile['type']==self::BEAUTI) {
-                MobileId::insert(['id' => $mobile['id']]);
-            }
-        });
-        self::afterDelete(function (self $mobile){
-            $mobile->makeDelete();
-        });
-        self::afterUpdate(function (self $mobile){
-            if($mobile['type']==self::BEAUTI) {
-                EsMobileService::addMobile($mobile);
-            }
-        });
-    }
-
-    public function makeSortLine(){
-        $change=false;
-        if($this['rec_time']){
-            $change=true;
-            $this['sort_line'] = -10;
-        }
-        if($this['top_time']){
-            $change=true;
-            $this['sort_line'] = -20;
-        }
-        if($this['is_activity']){
-            $change=true;
-            $this['sort_line']=-$this['activity_time'];
-        }
-
-        if(!$change){
-            $this['sort_line']=$this['sort'];
-        }
-    }
-
-    public function makeNetwork($upd=false){
-        $no=$this['no']??'';
-        if(!$upd){
-            $needMake=true;
-        }else{
-            $changed=$this->getChangedData();
-            $needMake=isset($changed['no']);
-        }
-        if($needMake) {
-            $this['network'] = Network::getNetWorkString($no);
-        }
-    }
-    public function makeDelete(){
-        $this->info()->delete();
-        $this->sub()->delete();
-        $this->priceLog()->delete();
-        $this->holdLog()->delete();
-        EsMobileService::delMobile($this);
-        MobileId::destroy($this['id']);
-    }
-
-    protected function initialize()
-    {
-        parent::initialize(); // TODO: Change the autogenerated stub
-        static $columns=null;
-        if(is_null($columns)){
-            $columnsArr=self::getTableInfo('','fields');
-            $columns=collection($columnsArr)->filter(function ($column){
-                return Str::startsWith($column,'filter_');
-            });
-        }
-        $this->hidden=$columns?:[];
-    }
-
-    public static function show($param=[]){
-        $model=new self();
-        $model->with(['info']);
-        if(isset($param['type'])) {
-            if($param['type']==1) {
-                $model->whereIn('status', [0, 3]);
-            }else{
-                $model->where('status',0);
-            }
-        }
-        return $model->getQuery();
-    }
-
-    public static function hiddenColumn(){
-        $columnsArr=self::getTableInfo('','fields');
-        $columns=collection($columnsArr)->filter(function ($column){
-            return Str::startsWith($column,'filter_');
-        });
-        //$columns[]='sort';
-        //$columns[]='sort_line';
-        $columns[]='sub_admin_id';
-        $columns[]='sub_rec_time';
-        $columns[]='sub_sort';
-        //$columns[]='sub_sort_line';
-        $columns[]='sub_top_time';
-        $columns[]='update_time';
-        $columns[]='create_time';
-        $columns[]='mobile_id';
-        $columns[]='hold_chan';
-        $columns[]='hold_user';
-        $columns[]='admin_id';
-        $columns[]='mobile_sub_id';
-        $columns[]='remark';
-        $columns[]='remark_me';
-        //$columns[]='rec_time';
-        $columns[]='proxy_id';
-        $columns[]='batch_no';
-        $columns[]='mobile_sub_id';
-        //$columns[]='top_time';
-        $columns[]='amount_di';
-        return $columns->toArray();
-    }
-
-    /**
-     *@param self $mobile
-     */
-    public static function whenOrderPayed($mobile){
-        if($mobile){
-            if($mobile['type']==self::BEAUTI) {
-                $mobile['status'] = 1;
-                $mobile->save();
-            }else{
-                $mobile['stock_num']=$mobile['stock_num']-1;
-                if($mobile['stock_num']) {
-                    $mobile->save();
-                }
-            }
-        }
-    }
-
-    public function shouldBuy(){
-        if($this['type']==self::BEAUTI){
-            if($this['status']!=0){
-                throw_user('该号码已售或不存在');
-            }
-        }elseif ($this['type']==2){
-            if($this['status']!=0){
-                throw_user('该流量卡暂时无法购买');
-            }
-            if($this['stock_num']==0){
-                throw_user('库存不足');
-            }
-        }
-    }
-
-    public function viewCountCacheName(){
-        return __CLASS__."view_count_{$this['id']}_".date('ymdh');
-    }
-    public function getViewCountAttr(){
-        return Cache::get($this->viewCountCacheName(),0);
-    }
-    public function getActivityTimeEndAttr($a){
-        if(!$a){
-            $a=3;
-        }
-        return time()+$a*60;
-    }
-    public function setIsActivityAttr($a){
-        return intval($a);
-    }
-    public function addViewCount(){
-        $num=Cache::get($this->viewCountCacheName(),0);
-        Cache::set($this->viewCountCacheName(),++$num);
-    }
-    public function needCheckSmsCode(){
-        return in_array($this['type'],[self::BEAUTI]);
-    }
-    #禁止下单
-    public static function cantOrderStatus(){
-        return 3;
-    }
-    #导入状态
-    public static function importStatus($s){
-        $s=preg_replace('/[\s| ]+/','',$s);
-        switch ($s){
-            case '正常':
-                return 0;
-            case '禁止下单':
-                return 3;
-            case '下架':
-                return 2;
-            case '已售':
-                return 1;
-        }
-        return 2;
-    }
-    #流量卡状态
-    public static function flowStatus(){
-        return self::$flowStatus;
-    }
-    #流量卡下架
-    public function flowMakeDown(){
-        $this['status']=2;
-        $this->save();
-    }
-    public function flowMakeUp(){
-        $this['status']=0;
-        $this->save();
-    }
-    #设置为非活动
-    public function makeNotActivity($save=true){
-        $this['is_activity'] = 0;
-        $this['activity_time'] = 0;
-        $this['hold_chan']=0;
-        $this['hold_user']=0;
-        if($save) {
-            $this->save();
-        }
-    }
-    #设置活动
-    public function makeActivity($amountKill,$chanId){
-        $this['is_activity'] = 1;
-        $this['activity_time'] = time();
-        $this['hold_chan']=$chanId;
-        $this['hold_user']=$chanId;
-        $this['amount_kill']=$amountKill;
-        $this->save();
-    }
-    #已售
-    public function scopeFilterSaled(Query $query){
-        $query->where('status',1);
-    }
-
-    public function makeSort()
-    {
-        $sort=$this['sort'];
-        $has=self::where('id','<>',$this['id'])->where('sort',$sort)->find();
-        if($has) {
-            self::where('sort', '>=', $sort)->setInc('sort');
-            self::where('is_activity',0)->where('top_time',0)->where('rec_time',0)->update([
-                'sort_line'=>Db::raw('sort')
-            ]);
-        }
-    }
-
-    public function getAmountBaseAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public function getAmountAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public function getAmountKillAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public function getAmountDiAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public function getAmountOriginalAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public function getAmountChargeAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public function getAmountExistsAttr($amount){
-        return str_replace('.00','',$amount);
-    }
-    public static function deleteOtherTableInfo(){
-        MobileInfo::whereNotExists('select * from mobile where mobile_info.mobile_id=mobile.id')->delete();
-        MobilePriceLog::whereNotExists('select * from mobile where mobile_price_log.mobile_id=mobile.id')->delete();
-        MobileSub::whereNotExists('select * from mobile where mobile_sub.mobile_id=mobile.id')->delete();
-    }
-
-    public function again_sell(){
-        if($this['status']==0){
-            throw_user('当前已是上架状态');
-        }
-        $this['status']=0;
-        $this->save();
-    }
-
-    public static function beautiStatus(){
-        return self::$status;
-    }
-}

+ 0 - 48
application/common/model/MobileExportLog.php

@@ -1,48 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-
-class MobileExportLog extends Model
-{
-
-    
-
-    
-
-    // 表名
-    protected $table = 'mobile_export_log';
-    
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
-
-    // 定义时间戳字段名
-    protected $createTime = false;
-    protected $updateTime = false;
-    protected $deleteTime = false;
-
-    // 追加属性
-    protected $append = [
-        'create_time_text'
-    ];
-    
-
-    
-
-
-
-    public function getCreateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-    protected function setCreateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-
-}

+ 0 - 41
application/common/model/MobileHoldLog.php

@@ -1,41 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileHoldLog extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-
-    public function holdable(){
-        return $this->morphTo('holdable',[
-            'admin'=>Admin::class,
-            'user' =>User::class,
-        ]);
-    }
-    public function mobile(){
-        return $this->belongsTo(Mobile::class,'mobile_id','id')->setEagerlyType(0);
-    }
-
-    public static function withHoldUser(User $user,$is_hold){
-        return new self([
-            'holdable_type'=>'user',
-            'holdable_id'=>$user['id'],
-            'is_hold'=>$is_hold,
-        ]);
-    }
-    public static function withHoldAdmin(Admin $user,$is_hold){
-        return new self([
-            'holdable_type'=>'admin',
-            'holdable_id'=>$user['id'],
-            'is_hold'=>$is_hold,
-        ]);
-    }
-}

+ 0 - 16
application/common/model/MobileId.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- * 邮箱验证码
- */
-class MobileId Extends Model
-{
-    protected $name='mobileid';
-    public static function notExists(){
-        return self::whereNotExists("select id from mobile where mobile.id=mobileid.id");
-    }
-}

+ 0 - 51
application/common/model/MobileInfo.php

@@ -1,51 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\App;
-use app\service\EsMobileService;
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileInfo extends Model
-{
-    protected $type=[
-        'flow_images'=>'json',
-    ];
-    public function mobile(){
-        return $this->belongsTo(Mobile::class);
-    }
-
-    protected static function init()
-    {
-        self::beforeWrite(function (self $info){
-            if(isset($info['first_month_free']) && !is_numeric($info['first_month_free'])){
-                $info['first_month_free']=Str::contains($info['first_month_free'],'是')?1:0;
-            }
-        });
-        self::afterInsert(function (self $info){
-            EsMobileService::addMobile($info['mobile']);
-        });
-    }
-
-    public static function makeFreeApp(&$info){
-        $a=[];
-        if($info){
-            $app=array_filter(explode('#',$info['free_app']));
-            $existsApp=App::column('logo','name');
-            foreach ($app as $name){
-                $a[]=[
-                    'name'=>$name,
-                    'logo'=>$existsApp[$name]??self::defAppLogo()
-                ];
-            }
-        }
-        $info['free_app']=$a;
-    }
-    public static function defAppLogo(){
-        return request()->domain().'/assets/img/app.png';
-    }
-}

+ 0 - 331
application/common/model/MobileOrder.php

@@ -1,331 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use app\admin\model\MobileOrderAdmin;
-use app\common\library\MobileConstant;
-use app\common\service\Refund;
-use app\common\service\SmsSend;
-use think\Db;
-use think\db\Query;
-use think\Model;
-
-
-/**
- * 配置模型
- * @method static static filterSaled()
- * @method static static expired()
- * @method static static filterFlow()
- * @method $this filterShow($type)
- * @method $this waitPay()
- */
-class MobileOrder extends Model
-{
-    use TraitModel;
-    const STATUS_WAIT_SEND=10;
-    const STATUS_CAN_SEND=15;
-    const STATUS_REFUND=30;
-    const STATUS_REFUNDED=90;
-    public static $status=[
-        0=>'待付款',
-        self::STATUS_WAIT_SEND=>'已付款',
-        self::STATUS_CAN_SEND=>'待发货',
-        17=>'有号码未发货',
-        20=>'已发货待激活',
-        25=>'已完成',
-        self::STATUS_REFUND=>'申请退款',
-        50=>'已关闭',
-        60=>'无号码',
-        70=>'换卡',
-        80=>'争议单',
-        self::STATUS_REFUNDED=>'已退款',
-    ];
-    public static $refundAllowStatus=[
-        self::STATUS_WAIT_SEND,
-        15,
-        17,
-        20,
-        60,
-        70,
-    ];
-    public static $flowStatus=[
-        0=>'待付款',//待付款
-        10=>'已付款未处理',//已付款未处理
-        15=>'待处理',//待处理
-        20=>'已提交运营商',//已提交运营商
-        23=>'已发货',//已发货
-        25=>'已完结',//已激活/已完结
-        50=>'已关闭',//已激活/已完结
-        110=>'审核失败',//审核失败
-    ];
-    public static $frontStatus=[
-        0,
-        self::STATUS_WAIT_SEND,
-        self::STATUS_CAN_SEND,
-        17,20,25,30,90,50,
-    ];
-    public static $payTypes=[
-        1=>'微信',
-        2=>'支付宝',
-        3=>'京东',
-    ];
-    protected $hidden=[
-        'status_bak',
-    ];
-
-
-
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-
-    public function mobile(){
-        return $this->belongsTo(Mobile::class);
-    }
-    public function info(){
-        return $this->hasOne(MobileOrderInfo::class);
-    }
-    public function mind(){
-        return $this->hasOne(MobileOrderMind::class);
-    }
-    public function operation(){
-        return $this->hasMany(MobileOrderOperation::class)->order('mobile_order_operation.id','desc');
-    }
-    public function admin(){
-        return $this->hasMany(MobileOrderAdmin::class);
-    }
-    public function status(){
-        return $this->hasMany(MobileOrderStatus::class);
-    }
-    public function refundLog(){
-        return $this->hasMany(MobileOrderRefundLog::class);
-    }
-    public function rules(){
-        return $this->hasMany(MobileOrderRules::class);
-    }
-    public function proxy(){
-        $columns=Admin::getTableInfo()['fields'];
-        unset($columns['password']);
-        return $this->belongsTo(Admin::class)->field($columns);
-    }
-
-    public function getAddressAttr($a,$b){
-        return Area::getNameString($b['city']).$a;
-    }
-    public function setCityAttr($a){
-        if(is_array($a)){
-            return implode(',',$a);
-        }
-        return $a;
-    }
-
-    public function saveRules(){
-        if($this['type']==1) {
-            $mobile=$this['mobile'];
-            $filters=MobileConstant::getFilters();
-            $rules=[];
-            foreach ($filters as $rule=>$filter){
-                $fit=false;
-                foreach ($filter as $column){
-                    if($mobile[$column]){
-                        $fit=true;
-                        break;
-                    }
-                }
-                if($fit){
-                    $rules[]=[
-                        'rule'=>$rule
-                    ];
-                }
-            }
-            $this->rules()->saveAll($rules);
-        }
-    }
-
-    protected static function init()
-    {
-        self::beforeInsert(function (self $mobileOrder){
-            $mobileOrder['order_no']=order_no();
-            $mobileOrder['expire_time']=time()+86400;
-            $mobileOrder['brand']=$mobileOrder['mobile']['brand'];
-            #计算盈利
-            $mobileOrder['amount_profit']=bcsub($mobileOrder['amount'],$mobileOrder['amount_di']);
-        });
-        self::afterInsert(function (self $mobileOrder){
-            $mobileOrder->info()->save([
-                'mobile'=>$mobileOrder['mobile'],
-                'info'=>$mobileOrder['mobile']['info'],
-            ]);
-            #保存规律
-            $mobileOrder->saveRules();
-        });
-
-        self::beforeUpdate(function (self $mobileOrder){
-            $data=$mobileOrder->getChangedData();
-            #记录status
-            if(isset($data['status'])){
-                $mobileOrder->status()->save([
-                    'status'=>$mobileOrder->origin['status'],
-                ]);
-            }
-
-            #物流信息
-            if(!empty($data['trans_id'])){
-                $mobileOrder['trans_name']=LogisticsCompany::getNameById($data['trans_id']);
-            }
-            if(isset($data['trans_id']) && !$data['trans_id']){
-                $mobileOrder['trans_name']=null;
-            }
-
-            #主播
-        });
-    }
-
-    public function sendNotifyToUser(){
-        $mobileOrder=$this;
-        if($mobileOrder['trans_name'] && $mobileOrder['trans_no']) {
-            SmsSend::orderSend($mobileOrder['phone'], $mobileOrder['trans_name'], $mobileOrder['trans_no']);
-        }
-    }
-
-    public function scopeExpired(Query $query){
-        $query->where('status',0)->where('expire_time','<',time())->where('amount','>',0);
-    }
-
-    public function scopeFilterFlow(Query $query){
-        $query->where('type',2);
-    }
-
-    public function cancel(){
-        if($this['pay_time'] || $this['pay_time']!=0){
-            return;
-        }
-        $this['status']=50;
-        $this->save();
-    }
-
-    public function continuePay(){
-        if($this['expire_time']<time()){
-            throw_user('订单已过期');
-        }
-        if($this['status']!=0){
-            throw_user('订单状态有误');
-        }
-        if($this['type']!=1){
-            throw_user('该产品无需支付');
-        }
-        if(!$this['mobile']){
-            throw_user('手机号不存在或已下架');
-        }
-        $this['mobile']->shouldBuy();
-    }
-    public function paySuccessCallback($payment=null,$data=[],$type='wechat'){
-        $mobileOrder=$this;
-        if(!empty($mobileOrder['pay_time'])){
-            throw_user("手机订单已支付");
-        }
-        if($mobileOrder['type']==1) {
-            $mobileOrder['status'] = MobileOrder::STATUS_CAN_SEND;
-        }else{
-            $mobileOrder['status'] = 10;
-        }
-        if($payment) {
-            $payConfig=get_addon_config('epay');
-            $mobileOrder['pay_time'] = $payment['pay_time'];
-            if ($type == 'wechat') {
-                $mobileOrder['pay_type'] = 1;
-                $mobileOrder['pay_no'] = $data['transaction_id'];
-                $mobileOrder['pay_mid_wechat']=$payConfig['wechat']['mch_id'];
-            } elseif ($type == 'alipay') {
-                $mobileOrder['pay_type'] = 2;
-                $mobileOrder['pay_no'] = $data['trade_no'];
-                $mobileOrder['pay_mid_alipay']=$payConfig['alipay']['app_id'];
-            }
-            $mobileOrder['payment_id'] = $payment['id'];
-            SmsSend::orderPayed($mobileOrder['phone']);
-        }else{
-            $mobileOrder['pay_time']=time();
-        }
-        if (!$mobileOrder->save()) {
-            throw_user("订单保存失败");
-        }
-        Mobile::whenOrderPayed($mobileOrder->mobile);
-    }
-
-    public function originData(){
-        return $this->origin;
-    }
-    public function checkAllowRefund(){
-        if(!in_array($this['status'],self::$refundAllowStatus)){
-            throw_user('当前状态不允许退款');
-        }
-    }
-    public function makeUserRefund($reason){
-        $this['status_bak']=$this['status'];
-        $this['status']=self::STATUS_REFUND;
-        $this['refund_reason']=$reason;
-        $this->save();
-    }
-    public static function flowStatus(){
-        $s=self::$flowStatus;
-        return $s;
-    }
-    public function frontStatus(){
-        return self::$frontStatus;
-    }
-    public function scopeFilterShow(Query $query,$type){
-        if ($type==1){
-            $query->whereIn('mobile_order.status',$this->frontStatus());
-        }else{
-            $query->whereIn('mobile_order.status',array_keys(self::flowStatus()));
-        }
-    }
-
-    public function makeRefund($from,$user,$data){
-        $model=$this;
-        $model['amount_refund'] = $data['amount'];
-        $model['refund_no'] = session_create_id();
-        $model['refund_reason']=$data['refund_reason'];
-        $statusBak=$model['status_bak'];
-        $model['status_bak']=$model['status'];
-        if ($data['pass']) {
-            if ($data['amount'] > $model['amount']) {
-                throw_user('退款金额不能大于付款金额');
-            }
-            Refund::setType($model)->refund();
-            $model['status'] = self::STATUS_REFUNDED;
-            SmsSend::orderRefund($model['phone']);
-            #退款盈利哦
-            $model['amount_profit']=bcsub($model['amount'],$model['amount_refund']);
-        }else{
-            $model['amount_refund']=0;
-            $model['status'] = $statusBak;
-        }
-        $model->save();
-        $model->refundLog()->save(MobileOrderRefundLog::withRefund($from,$user,$data));
-    }
-
-    public function flowOrderSubmit(){
-        $this['status']=0;
-    }
-
-    public function scopeWaitPay(Query $query){
-        $query->where('status',0);
-    }
-    #销售金额
-    public function scopeFilterSaled(Query $query){
-        $query->whereNotIn('mobile_order.status',[0,50,90]);
-    }
-    #发货
-    public function dealSend($trans_no,$trans_id){
-        $this['trans_no']=$trans_no;
-        $this['trans_id']=$trans_id;
-        if($this['type']==1){
-            $this['status']=20;
-        }else{
-            $this['status']=23;
-        }
-        $this->save();
-        $this->sendNotifyToUser();
-    }
-}

+ 0 - 29
application/common/model/MobileOrderInfo.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileOrderInfo extends Model
-{
-    protected $type=[
-        'info'=>'json',
-    ];
-
-    public function setMobileAttr($mobile){
-        unset($mobile['info']);
-        $mobile=json_encode($mobile,JSON_UNESCAPED_UNICODE);
-        return $mobile;
-    }
-    public function getMobileAttr($mobile){
-        $mobileArr = json_decode($mobile,true);
-        if($mobileArr['logo']){
-            $mobileArr['logo']=(new Mobile)->getLogoAttr($mobileArr['logo']);
-        }
-        return $mobileArr;
-    }
-}

+ 0 - 16
application/common/model/MobileOrderMind.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileOrderMind extends Model
-{
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    protected $updateTime=false;
-}

+ 0 - 20
application/common/model/MobileOrderNo.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileOrderNo extends Model
-{
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    protected $updateTime=false;
-
-    protected function getCityNameAttr($_,$model){
-        return Area::getNameString($model['city']);
-    }
-}

+ 0 - 29
application/common/model/MobileOrderOperation.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileOrderOperation extends Model
-{
-  protected $autoWriteTimestamp=true;
-  protected $updateTime=null;
-    protected $append=[
-        'create_time_format',
-        'create_time_format_short',
-    ];
-  public function getCreateTimeFormatAttr($a,$m){
-      return date('m/d H:i',$m['create_time']);
-  }
-    public function getCreateTimeFormatShortAttr($a,$m){
-        return date('m/d',$m['create_time']);
-    }
-    public function admin(){
-      return $this->belongsTo(Admin::class);
-    }
-}

+ 0 - 57
application/common/model/MobileOrderRefundLog.php

@@ -1,57 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use think\Model;
-
-/**
- * 配置模型
- */
-class MobileOrderRefundLog extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-    protected $append=[
-        'create_time_format',
-    ];
-
-    public function refunduser(){
-        return $this->morphTo('refunduser',[
-            'admin'=>Admin::class,
-            'user' =>User::class,
-        ]);
-    }
-    public function mobileOrder(){
-        return $this->belongsTo(MobileOrder::class,'mobile_id','id')->setEagerlyType(0);
-    }
-
-    public static function withRefundUser(User $user,$data){
-        return new self([
-            'refunduser_type'=>'user',
-            'refunduser_id'=>$user['id'],
-            'amount'=>$data['amount'],
-        ]);
-    }
-    public static function withRefundAdmin(Admin $user,$data){
-        return new self([
-            'refunduser_type'=>'admin',
-            'refunduser_id'=>$user['id'],
-            'amount'=>$data['amount'],
-        ]);
-    }
-    public static function withRefund($type,$user,$data){
-        return new self([
-            'refunduser_type'=>$type,
-            'refunduser_id'=>$user['id'],
-            'amount_user'=>$data['amount_user']??0,
-            'amount_backend'=>$data['amount'],
-            'reason'=>$data['refund_reason'],
-            'pass'=>$data['pass'],
-        ]);
-    }
-
-    public function getCreateTimeFormatAttr($a,$b){
-        return date('m/d H:i',$b['create_time']);
-    }
-}

+ 0 - 13
application/common/model/MobileOrderRules.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileOrderRules extends Model
-{
-}

+ 0 - 15
application/common/model/MobileOrderStatus.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-use Yansongda\Supports\Str;
-
-/**
- * 配置模型
- */
-class MobileOrderStatus extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $updateTime=null;
-}

+ 0 - 26
application/common/model/MobilePriceLog.php

@@ -1,26 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use think\Model;
-
-/**
- * 配置模型
- */
-class MobilePriceLog extends Model
-{
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-
-    public function admin()
-    {
-        return $this->belongsTo(Admin::class, 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
-    }
-
-
-    public function user()
-    {
-        return $this->belongsTo(User::class, 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
-    }
-}

+ 0 - 66
application/common/model/MobileSub.php

@@ -1,66 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use app\admin\model\Admin;
-use think\Db;
-use think\db\Query;
-use think\Model;
-
-/**
- * 配置模型
- * @method Query admin($adminId)
- */
-class MobileSub extends Model
-{
-    protected function scopeAdmin(Query $query,$adminId){
-        $query->where('admin_id',$adminId);
-    }
-
-    public static function getBy(Mobile $mobile,Admin $admin){
-        $one=self::where('mobile_id',$mobile['id'])->where('sub_admin_id',$admin['id'])->find();
-        if(!$one){
-            $sort=self::where('sub_admin_id',$admin['id'])->max('sub_sort')?:1;
-            $one=self::create([
-                'mobile_id'=>$mobile['id'],
-                'sub_sort'=>$sort,
-                'sub_admin_id'=>$admin['id'],
-                'sub_top_time'=>0,
-                'sub_rec_time'=>0,
-            ]);
-        }
-        return $one;
-    }
-
-    protected static function init()
-    {
-        self::beforeUpdate(function (self $mobileSub){
-            $change=$mobileSub->getChangedData();
-            if(isset($change['sub_sort'])){
-                $mobileSub->makeSort();
-            }
-            if($mobileSub['sub_rec_time']){
-                $mobileSub['sub_sort_line']=-10;
-            }
-            if($mobileSub['sub_top_time']){
-                $mobileSub['sub_sort_line']=-20;
-            }
-            if(!in_array($mobileSub['sub_sort_line'],[-10,-20])){
-                $mobileSub['sub_sort_line']=0;
-            }
-        });
-    }
-
-
-    public function makeSort()
-    {
-        $sort=$this['sub_sort'];
-        $has=self::where('mobile_sub_id','<>',$this['id'])->where('sub_sort',$sort)->find();
-        if($has) {
-            self::where('sort', '>=', $sort)->setInc('sub_sort');
-            self::where('sub_top_time',0)->where('sub_rec_time',0)->update([
-                'sub_sort_line'=>Db::raw('sub_sort')
-            ]);
-        }
-    }
-}

+ 0 - 253
application/service/EsMobileService.php

@@ -1,253 +0,0 @@
-<?php
-namespace app\service;
-
-use app\common\model\Mobile;
-use app\common\model\MobileId;
-
-class EsMobileService{
-    public static function mobile(){
-    }
-    public static function index(){
-        return 'mobiles';
-    }
-    public static function type(){
-        return 'mobile';
-    }
-    public static function body(){
-        return [
-            'mappings'=>[
-                'properties'=>[
-                        'id'=>['type'=>'long'],
-                        'status'=>['type'=>'byte'],
-                        'logo'=>['type'=>'text'],
-                        'name'=>['type'=>'text'],
-                        'brand'=>['type'=>'text'],
-                        'no'=>['type'=>'text'],
-                        'type'=>['type'=>'byte'],
-                        'network'=>['type'=>'text'],
-                        'proxy_id'=>['type'=>'long'],
-                        'city_id'=>['type'=>'long'],
-                        'city'=>['type'=>'text'],
-                        'province_id'=>['type'=>'long'],
-                        'province'=>['type'=>'text'],
-                        'amount_exists'=>['type'=>'double'],
-                        'amount_original'=>['type'=>'double'],
-                        'amount_base'=>['type'=>'double'],
-                        'amount_charge'=>['type'=>'double'],
-                        'amount_di'=>['type'=>'double'],
-                        'amount_proxy'=>['type'=>'double'],
-                        'amount_kill'=>['type'=>'double'],
-                        'amount'=>['type'=>'double'],
-                        'create_time'=>['type'=>'long'],
-                        'update_time'=>['type'=>'long'],
-                        'top_time'=>['type'=>'byte'],
-                        'rec_time'=>['type'=>'byte'],
-                        'summary'=>['type'=>'text'],
-                        'is_activity'=>['type'=>'byte'],
-                        'activity_time_end'=>['type'=>'long'],
-                        'filter_num_0'=>['type'=>'byte'],
-                        'filter_num_1'=>['type'=>'byte'],
-                        'filter_num_2'=>['type'=>'byte'],
-                        'filter_num_3'=>['type'=>'byte'],
-                        'filter_num_4'=>['type'=>'byte'],
-                        'filter_num_5'=>['type'=>'byte'],
-                        'filter_num_6'=>['type'=>'byte'],
-                        'filter_num_7'=>['type'=>'byte'],
-                        'filter_num_8'=>['type'=>'byte'],
-                        'filter_num_9'=>['type'=>'byte'],
-                        'filter_middle_3a'=>['type'=>'byte'],
-                        'filter_middle_4a'=>['type'=>'byte'],
-                        'filter_middle_5a'=>['type'=>'byte'],
-                        'filter_middle_6a'=>['type'=>'byte'],
-                        'filter_middle_7a'=>['type'=>'byte'],
-                        'filter_middle_8a'=>['type'=>'byte'],
-                        'filter_middle_abc'=>['type'=>'byte'],
-                        'filter_middle_abcd'=>['type'=>'byte'],
-                        'filter_middle_abcde'=>['type'=>'byte'],
-                        'filter_middle_abcdef'=>['type'=>'byte'],
-                        'filter_middle_abcdefg'=>['type'=>'byte'],
-                        'filter_middle_abcdefgh'=>['type'=>'byte'],
-                        'filter_middle_3ab'=>['type'=>'byte'],
-                        'filter_middle_4ab'=>['type'=>'byte'],
-                        'filter_middle_5ab'=>['type'=>'byte'],
-                        'filter_middle_6ab'=>['type'=>'byte'],
-                        'filter_middle_aabb'=>['type'=>'byte'],
-                        'filter_middle_aabbcc'=>['type'=>'byte'],
-                        'filter_middle_aabbccdd'=>['type'=>'byte'],
-                        'filter_middle_aaabb'=>['type'=>'byte'],
-                        'filter_middle_abbabb'=>['type'=>'byte'],
-                        'filter_middle_aabaab'=>['type'=>'byte'],
-                        'filter_middle_abcabc'=>['type'=>'byte'],
-                        'filter_middle_abba'=>['type'=>'byte'],
-                        'filter_middle_aaabbcc'=>['type'=>'byte'],
-                        'filter_middle_abababab'=>['type'=>'byte'],
-                        'filter_middle_abababa'=>['type'=>'byte'],
-                        'filter_middle_ababab'=>['type'=>'byte'],
-                        'filter_middle_ababa'=>['type'=>'byte'],
-                        'filter_middle_abab'=>['type'=>'byte'],
-                        'filter_no_pos_2'=>['type'=>'byte'],
-                        'filter_no_pos_3'=>['type'=>'byte'],
-                        'filter_no_pos_4'=>['type'=>'byte'],
-                        'filter_no_pos_5'=>['type'=>'byte'],
-                        'filter_no_pos_6'=>['type'=>'byte'],
-                        'filter_no_pos_7'=>['type'=>'byte'],
-                        'filter_no_pos_8'=>['type'=>'byte'],
-                        'filter_no_pos_9'=>['type'=>'byte'],
-                        'filter_no_pos_10'=>['type'=>'byte'],
-                        'filter_no_pos_11'=>['type'=>'byte'],
-                        'sort'=>['type'=>'long'],
-                        'sort_line'=>['type'=>'long'],
-                        'filter_tail_3a'=>['type'=>'byte'],
-                        'filter_tail_4a'=>['type'=>'byte'],
-                        'filter_tail_5a'=>['type'=>'byte'],
-                        'filter_tail_6a'=>['type'=>'byte'],
-                        'filter_tail_7a'=>['type'=>'byte'],
-                        'filter_tail_8a'=>['type'=>'byte'],
-                        'filter_tail_abc'=>['type'=>'byte'],
-                        'filter_tail_abcd'=>['type'=>'byte'],
-                        'filter_tail_abcde'=>['type'=>'byte'],
-                        'filter_tail_abcdef'=>['type'=>'byte'],
-                        'filter_tail_abcdefg'=>['type'=>'byte'],
-                        'filter_tail_abcdefgh'=>['type'=>'byte'],
-                        'filter_tail_3ab'=>['type'=>'byte'],
-                        'filter_tail_4ab'=>['type'=>'byte'],
-                        'filter_tail_5ab'=>['type'=>'byte'],
-                        'filter_tail_6ab'=>['type'=>'byte'],
-                        'filter_tail_aabb'=>['type'=>'byte'],
-                        'filter_tail_aabbcc'=>['type'=>'byte'],
-                        'filter_tail_aabbccdd'=>['type'=>'byte'],
-                        'filter_tail_aaabb'=>['type'=>'byte'],
-                        'filter_tail_abbabb'=>['type'=>'byte'],
-                        'filter_tail_aabaab'=>['type'=>'byte'],
-                        'filter_tail_abcabc'=>['type'=>'byte'],
-                        'filter_tail_abba'=>['type'=>'byte'],
-                        'filter_tail_aaabbcc'=>['type'=>'byte'],
-                        'filter_tail_abababab'=>['type'=>'byte'],
-                        'filter_tail_abababa'=>['type'=>'byte'],
-                        'filter_tail_ababab'=>['type'=>'byte'],
-                        'filter_tail_ababa'=>['type'=>'byte'],
-                        'filter_tail_abab'=>['type'=>'byte'],
-                        'remark'=>['type'=>'text'],
-                        'remark_me'=>['type'=>'text'],
-                        'hold_chan'=>['type'=>'long'],
-                        'hold_user'=>['type'=>'long'],
-                        'admin_id'=>['type'=>'long'],
-                        'activity_time'=>['type'=>'long'],
-                        'stock_num'=>['type'=>'integer'],
-                        'batch_no'=>['type'=>'text'],
-                        'describe'=>['type'=>'text'],
-                    ]
-            ]
-        ];
-    }
-    public static function mapping(){
-        es()->indices()->create([
-            'index'=>self::index(),
-            'body'=>self::body()
-        ]);
-    }
-    public static function delIndex(){
-        es()->indices()->delete([
-            'index'=>self::index(),
-        ]);
-    }
-    public static function addMobile(Mobile $mobile){
-        if($mobile['type']!=$mobile::BEAUTI){
-            return ;
-        }
-        $mobile->hidden([],true);
-        $mobile['describe']=$mobile['info']['describe'];
-        es()->index([
-            'index'=>self::index(),
-            'body'=>$mobile->toArray(),
-            'id'=>$mobile['id'],
-        ]);
-    }
-    public static function addMobiles(array $mobiles){
-        $body=[];
-        foreach ($mobiles as $mobile){
-            $mobile->hidden([],true);
-            $mobile['describe']=$mobile['info']['describe'];
-            $body[]=['create'=>['_index'=>self::index(),'_id'=>$mobile['id']]];
-            $body[]=$mobile->toArray();
-        }
-        es()->bulk([
-            'index'=>self::index(),
-            'body'=>$body
-        ]);
-    }
-    public static function delMobile(Mobile $mobile){
-        es()->deleteByQuery([
-            'index'=>self::index(),
-            'body'=>[
-                'query'=>[
-                    'term'=>[
-                        'id'=>$mobile['id'],
-                    ]
-                ]
-            ]
-        ]);
-    }
-    public static function delMobiles(array $mobiles){
-        if(empty($mobiles)){
-            return ;
-        }
-        $body=[];
-        foreach ($mobiles as $mobile){
-            $body[]=['delete'=>['_index'=>self::index(),'_id'=>$mobile]];
-        }
-        $make=es()->bulk([
-            'index'=>self::index(),
-            'body'=>$body,
-        ]);
-        return $make->asArray();
-    }
-    public static function delByMobile($limit=10000){
-        $mobileIds= MobileId::notExists()->limit($limit)->column('id');
-        self::delMobiles($mobileIds);
-        MobileId::destroy($mobileIds);
-        return count($mobileIds);
-    }
-    public static function updateById($ids,$columnArr){
-        if(is_string($ids)){
-            $ids=explode(',',$ids);
-        }
-        $ids=array_filter($ids);
-        if(empty($ids)){
-            return true;
-        }
-        $field=[];
-        foreach ($columnArr as $key=>$value){
-            $field[]=sprintf('ctx._source["%s"]="%s"',$key,$value);
-        }
-        es()->updateByQuery([
-            'index'=>self::index(),
-            'body'=>[
-                'query'=>[
-                    'terms'=>[
-                        'id'=>$ids
-                    ]
-                ],
-                'script'=>[
-                    'inline'=>implode(';',$field),
-                ]
-            ]
-        ]);
-    }
-    public static function clear(){
-        es()->deleteByQuery([
-            'index'=>self::index(),
-            'body'=>[
-                'query'=>[
-                    'match_all'=>new \stdClass()
-                ]
-            ]
-        ]);
-    }
-    public static function count(){
-        $count=es()->count([
-            'index'=>self::index(),
-        ]);
-        return $count->offsetGet('count');
-    }
-}

+ 0 - 6
application/service/mobile_get/ChinaMobileService.php

@@ -1,6 +0,0 @@
-<?php
-namespace app\service\mobile_get;
-
-class ChinaMobileService {
-
-}

+ 0 - 6
application/service/mobile_get/MobileGetService.php

@@ -1,6 +0,0 @@
-<?php
-namespace app\service\mobile_get;
-
-abstract class MobileGetService {
-
-}