validate()) { return $this->getErrorSummary(false)[0]; } $order = Order::findOne([ //'store_id' => $this->store_id, 'saas_id' => $this->saas_id, 'id' => $this->order_id, // 'trade_status' => Order::ORDER_FLOW_SEND, 'is_delete' => 0, ]); if (!$order) { return [ 'code' => 1, 'msg' => '订单不存在' ]; } $delivery_info = DeliveryInfo::findOne(['order_no' => $order->order_no]); $courier = LocalDeliveryCourier::findOne(['id' => $delivery_info->rider_id, 'is_delete' => 0, 'state' => 2]); if($delivery_info->is_local == DeliveryInfo::IS_LOCAL_YSE) { if($delivery_info->local_status == DeliveryInfo::LOCAL_STATUS_CONFIRM) { /* 骑手完成订单后发放收入 */ //同城配送设置相关 $store_id = 0; if (intval($delivery_info->is_store_delivery_type)) { $store_id = get_store_id(); } $values = Option::find()->where([ 'store_id' => $store_id, 'group' => OptionSetting::LOCAL_DELIVERY_GROUP_NAME, 'name' => OptionSetting::LOCAL_DELIVERY_SETTING ])->select('value')->one(); $local_setting = json_decode($values->value, true); if (!empty($courier)) { if ($store_id > 0) { $local_setting['default_cost']['value'] = -1; } $amount = (float)$local_setting['default_cost']['value'] == -1 ? $delivery_info->fee : (float)$local_setting['default_cost']['value']; $log = LocalDeliveryLog::saveLog($courier->saas_user_id, $amount, 1, 1, $order->id, "骑手配送收入:" . $amount . "元"); if (!$log) { return [ 'code' => 1, 'msg' => '发放骑手佣金出现异常' ]; } } } else { return [ 'code' => 1, 'msg' => '当前订单为平台自配,配送员未送达不可优先确认收货' ]; } } else { if ($order->trade_status != Order::ORDER_FLOW_SEND) { return [ 'code' => 1, 'msg' => '订单不存在' ]; } } $order->trade_status = Order::ORDER_FLOW_CONFIRM; $order->confirm_time = time(); if ($order->pay_type == 2) { $order->is_pay = 1; $order->pay_time = time(); } if ($order->save()) { return [ 'code' => 0, 'msg' => '已确认收货', ]; } else { return [ 'code' => 1, 'msg' => '确认收货失败' ]; } } }