data) { foreach ($this->data as $val) { if (count($val['list']) > 0) { $res = Option::verifyData($val['list'], $val['key']); if ($res && $res['code'] > 0) { return $res; } } } } $t = \Yii::$app->db->beginTransaction(); foreach ($this->data as $val) { $res = Option::setGroup($val['key'],$val['list'], $store_id ?: \get_store_id()); if ( $res !== true) { $t->rollBack(); return [ 'code' => 1, 'msg' => '保存失败', 'err' => $res ]; } } $this->upStore($store_id); $t->commit(); \app\utils\UpdateAfter::UpdateQQMapKey($oldQQMapKey); return [ 'code' => 0, 'msg' => '保存成功' ]; } private function upStore($store_id = 0){ $store_id = $store_id ? $store_id : get_store_id(); $store = Store::findOne($store_id); $name = Option::get('name', $store->id); $logo = Option::get('logo', $store->id); $coordinate = Option::get('coordinate', $store->id); $address_info = Option::get('address_info', $store->id); $address = Option::get('address', $store->id); $address_info = json_decode($address_info['value'], true); if (!empty($address_info)) { $store->province_id = $address_info['province_id']; $store->city_id = $address_info['city_id']; $store->district_id = $address_info['district_id']; } if (!empty($address['value'])) { $store->address = $address['value']; } if (!empty($coordinate['value'])) { $store->coordinate = $coordinate['value']; $coordinate = explode(',', $coordinate['value']); $store->longitude = $coordinate[1]; $store->latitude = $coordinate[0]; } if ($name['value']) { $store->name = $name['value']; } if ($logo['value']) { $store->logo = $logo['value']; } $contact_tel = Option::get('contact_tel', $store->id)['value']; $store->contact_tel = $contact_tel; $store->save(); $admin = Admin::findOne(['OR', ['type' => 'store', 'type_id' => $store->id, 'is_delete' => 0], ['id' => $store->admin_id]]); if ($admin) { $admin->mobile = $contact_tel; $admin->save(); } } public static function staticUpStore($store_id) { $self = new self(); $self->upStore($store_id); } }