xxxrrrdddd 3 年之前
父节点
当前提交
282f45c42b
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 9 0
      application/common/model/Mobile.php
  2. 1 0
      application/index/controller/Index.php

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

@@ -2,6 +2,7 @@
 
 namespace app\common\model;
 
+use app\common\service\MobileComputer;
 use think\Model;
 
 /**
@@ -41,6 +42,14 @@ class Mobile extends Model
     {
         self::beforeWrite(function (self $mobile){
             $mobile['amount']=$mobile['amount_base']+$mobile['amount_charge'];
+
+            $mobile->data(array_merge($mobile->getData(),MobileComputer::setMobile($mobile['no'])->filter()));
+        });
+
+        self::afterInsert(function (self $mobile){
+            if(!$mobile->info()->find()){
+                $mobile->info()->save([]);
+            }
         });
     }
 }

+ 1 - 0
application/index/controller/Index.php

@@ -3,6 +3,7 @@
 namespace app\index\controller;
 
 use app\common\controller\Frontend;
+use app\common\model\Mobile;
 use app\common\service\MobileComputer;
 use think\helper\Str;