最新服务器上的版本,以后用这个
zhangmeng
2023-04-19 e3f5aa12f58d986098a9de0f5cb38060e403036d
commit | author | age
2207d6 1 <?php
W 2
3 namespace app\models;
4
5 use Yii;
6
7 /**
8  * This is the model class for table "{{%order_send_template_address}}".
9  *
10  * @property int $id
11  * @property int $mall_id
12  * @property int $mch_id
13  * @property string $name 网点名称
14  * @property string $username 联系人
15  * @property string $mobile 联系电话
16  * @property string $code 网点邮编
17  * @property string $address 地址
18  * @property string $created_at
19  * @property string $updated_at
20  * @property string $deleted_at
21  * @property int $is_delete
22  */
23 class OrderSendTemplateAddress extends ModelActiveRecord
24 {
25     /**
26      * {@inheritdoc}
27      */
28     public static function tableName()
29     {
30         return '{{%order_send_template_address}}';
31     }
32
33     /**
34      * {@inheritdoc}
35      */
36     public function rules()
37     {
38         return [
39             [['mall_id', 'mch_id', 'created_at', 'updated_at', 'deleted_at'], 'required'],
40             [['mall_id', 'mch_id', 'is_delete', 'is_delete'], 'integer'],
41             [['created_at', 'updated_at', 'deleted_at'], 'safe'],
42             [['name', 'username', 'mobile', 'code'], 'string', 'max' => 60],
43             [['address'], 'string', 'max' => 255],
44         ];
45     }
46
47     /**
48      * {@inheritdoc}
49      */
50     public function attributeLabels()
51     {
52         return [
53             'id' => 'ID',
54             'mall_id' => 'Mall ID',
55             'mch_id' => 'Mch ID',
56             'name' => '网点名称',
57             'username' => '联系人',
58             'mobile' => '联系电话',
59             'code' => '网点邮编',
60             'address' => '地址',
61             'created_at' => 'Created At',
62             'updated_at' => 'Updated At',
63             'deleted_at' => 'Deleted At',
64             'is_delete' => 'Is Delete',
65         ];
66     }
67
68     /**
69      * @param OrderSendTemplateAddress $templateAddress
70      * @return array
71      */
72     public function getNewData($templateAddress)
73     {
74         $newAddress = json_decode($templateAddress->address);
75         return [
76             'id' => $templateAddress->id,
77             'name' => $templateAddress->name,
78             'username' => $templateAddress->username,
79             'mobile' => $templateAddress->mobile,
80             'code' => $templateAddress->code,
81             'province' => $newAddress->province,
82             'city' => $newAddress->city,
83             'district' => $newAddress->district,
84             'address' => $newAddress->address,
85         ];
86     }
87 }