/** * 更新生产单的状态 * @param $produce_order_id */ private function updateProduceOrderState($produce_order_id) { $order = SampleProduceOrder::findOneByPk($produce_order_id); //处理生产单状态 $has_no_finish_count = SampleProduceOrderMapSamples::find('produce_order_id=? AND state <> ?', $produce_order_id, SampleProduceOrderMapSamples::STATE_FINISH)->count(); //所有子项都完成了,改为完成 if (!$has_no_finish_count) { $ctrl = new SampleProduceOrderController(); $ctrl->state(array('id' => $produce_order_id, 'state' => SampleProduceOrder::STATE_FINISH)); } else { if ($order->state == SampleProduceOrder::STATE_FINISH) { $order->state = SampleProduceOrder::STATE_PRODUCING; $order->save(); } } }
public function update($get, $post) { $order = SampleProduceOrder::findOneByPk($get['id']) ?: new SampleProduceOrder(); if ($post) { if ($post['produce_type'] == SampleProduceOrder::TYPE_ORDER) { if ($post['business_order_no']) { $post['business_order_id'] = BusinessOrder::find('order_no=?', $post['business_order_no'])->ceil('id'); } if (!$post['business_order_id']) { return new Result('您输入的订单号没有对应的订单:' . $post['business_order_no']); } } $org_id = $order->boss_head_employee_id; $order->setValues($post); if (!$order->id) { $order->boss_head_employee_id = Auth::instance()->getLoginUserId(); } else { $order->boss_head_employee_id = $org_id; } $result = parent::update($get, $post); if ($result->isSuccess()) { return new Result('操作成功', true); } } $customer_list = Customer::find()->all(); $current_contact_list = array(); if ($order->id) { $current_contact_list = CustomerContact::find('customer_id =?', $order->contact->customer_id)->all(); } $all_contact_list = CustomerContact::find()->all(true); $all_contact_list = array_group($all_contact_list, 'customer_id'); return array('order' => $order, 'customer_list' => $customer_list, 'all_contact_list' => $all_contact_list, 'current_contact_list' => $current_contact_list); }