'EXPRESS'], [['order_id'], 'required', 'on' => 'PEISONG'], [['order_id'], 'required'], [['express', 'express_no',], 'string',], [['express', 'express_no',], 'default', 'value' => ''], ]; } public function attributeLabels() { return [ 'express' => '快递公司', 'express_no' => '快递单号', 'words' => '商家留言', ]; } public function save() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $order = Order::findOne([ 'is_delete' => 0, 'store_id' => $this->store_id, 'id' => $this->order_id, ]); if (!$order) { return [ 'code' => 1, 'msg' => '订单不存在或已删除', ]; } if ($order->is_pay == 0 && $order->pay_type != 2) { return [ 'code' => 1, 'msg' => '订单未支付' ]; } if ($order->apply_delete == Order::ORDER_APPLY_DELETE) { return [ 'code' => 1, 'msg' => '该订单正在申请取消操作,请先处理' ]; } $expressList = Express::getExpressList(); $ok = false; foreach ($expressList as $value) { if ($value['name'] == $this->express) { $ok = true; break; } } if (!$ok && $this->scenario == "EXPRESS") { return [ 'code' => 1, 'msg' => '快递公司不正确' ]; } $order->express = $this->express; $order->express_no = $this->express_no; $order->words = $this->words; $order->trade_status = Order::ORDER_FLOW_SEND; $order->send_time = time(); if ($order->save()) { $goods = Goods::findOne(OrderDetail::findOne(['order_id' => $order->id])->goods_id); if($order->giving_gifts_received_user_id){ NoticeSend::OrderSend($order->giving_gifts_received_user_id, $order->mobile, $order->order_no, $goods->name, $this->express, $this->express_no, $order->order_type); }else{ NoticeSend::OrderSend($order->user_id, $order->mobile, $order->order_no, $goods->name, $this->express, $this->express_no); } return [ 'code' => 0, 'msg' => '发货成功', ]; } else { return [ 'code' => 1, 'msg' => '操作失败', ]; } } }