OrderAddress.php 894 字节
<?php

namespace app\api\model;

use think\Model;


class OrderAddress extends Model
{
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function insertData($data){
        $areaModel = new Area();
        $province = $areaModel->where('id',$data['province_id'])->field('name,pinyin')->find();
        $city = $areaModel->where('id',$data['city_id'])->field('name,pinyin')->find();
        $county = $areaModel->where('id',$data['county_id'])->field('name,pinyin')->find();


        $data['ch_province_name'] = $province['name'];
        $data['ch_city_name'] = $city['name'];
        $data['ch_county_name'] = $county['name'];
        $res = $this->insertGetId($data);
        if ($res) return $res;
        else return false;
    }
}