| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\models\common\admin\order;
- use app\models\Option;
- use app\models\Order;
- use app\utils\Validator;
- class CommonUpdateAddress
- {
- public $data;//更新的数据
- public function updateAddress()
- {
- $orderId = $this->data['orderId'];
- $name = $this->data['name'];
- $mobile = $this->data['mobile'];
- $address = $this->data['address'];
- $province = $this->data['province'];
- $city = $this->data['city'];
- $district = $this->data['district'];
- if (!isset($orderId)) {
- return [
- 'code' => 1,
- 'msg' => '请传入订单ID'
- ];
- }
- if (!isset($name)) {
- return [
- 'code' => 1,
- 'msg' => '请填写收件人姓名'
- ];
- }
- if (!Validator::phone($mobile)) {
- return [
- 'code' => 1,
- 'msg' => '请输入正确的手机号'
- ];
- }
- if (!isset($mobile)) {
- return [
- 'code' => 1,
- 'msg' => '请填写收件人手机号'
- ];
- }
- if (!isset($address)) {
- return [
- 'code' => 1,
- 'msg' => '请填写收件人地址'
- ];
- }
- $order = Order::findOne($orderId);
- $arr = [
- 'province' => $province,
- 'city' => $city,
- 'district' => $district,
- 'detail' => $address
- ];
- $order->name = $name;
- $order->mobile = $mobile;
- $order->address = $province . $city . $district . $address;
- $order->address_data = json_encode($arr);
- if ($order->save()) {
- return [
- 'code' => 0,
- 'msg' => '更新成功'
- ];
- }
- return [
- 'code' => 1,
- 'msg' => '更新失败'
- ];
- }
- public function updateAddress2()
- {
- $orderId = $this->data['orderId'];
- $name = $this->data['name'];
- $mobile = $this->data['mobile'];
- $address = $this->data['address'];
- $province = $this->data['province'];
- $city = $this->data['city'];
- $district = $this->data['district'];
- if (!isset($orderId)) {
- return [
- 'code' => 1,
- 'msg' => '请传入订单ID'
- ];
- }
- if (!isset($name)) {
- return [
- 'code' => 1,
- 'msg' => '请填写收件人姓名'
- ];
- }
- if (!Validator::phone($mobile)) {
- return [
- 'code' => 1,
- 'msg' => '请输入正确的手机号'
- ];
- }
- if (!isset($mobile)) {
- return [
- 'code' => 1,
- 'msg' => '请填写收件人手机号'
- ];
- }
- if (!isset($address)) {
- return [
- 'code' => 1,
- 'msg' => '请填写收件人地址'
- ];
- }
- $order = Order::findOne($orderId);
- $arr = [
- 'province' => $province,
- 'city' => $city,
- 'district' => $district,
- 'detail' => $address
- ];
- $order->name = $name;
- $order->mobile = $mobile;
- $order->address = $province . $city . $district . $address;
- $order->address_data = json_encode($arr);
- if ($order->save()) {
- return [
- 'code' => 0,
- 'msg' => '更新成功'
- ];
- }
- return [
- 'code' => 1,
- 'msg' => '更新失败'
- ];
- }
- }
|