/** * @param $get */ public function ajaxGetCustomerConTactList($get) { $customer_id = $get['customer_id']; $customer_contact_list = CustomerContact::find("customer_id = ?", $customer_id)->select('id, chinese_name, tel, email ')->order('id asc')->all(true); echo json_encode($customer_contact_list); exit; }
/** * @param $get * @return array */ public function info($get) { $id = $get['id']; $customer = Customer::findOneByPk($id); $customer_contact_list = CustomerContact::find('customer_id = ?', $id)->all(); $customer_qualification_list = CustomerQualification::find('customer_id = ?', $id)->all(); $customer_financial_list = CustomerFinancial::find('customer_id = ?', $id)->all(); return array('customer' => $customer, 'customer_contact_list' => $customer_contact_list, 'customer_qualification_list' => $customer_qualification_list, 'customer_financial_list' => $customer_financial_list); }
public function __construct($data = array()) { parent::__construct($data); $this->setPropertiesDefine(array('customer_id' => array('options' => function (SampleProduceOrder $item = null) { if ($item && $item->customer_id) { $company_alias_name = Customer::findOneByPk($item->customer_id)->company_alias_name; return array($item->customer_id => $company_alias_name); } return null; }, 'alias' => '客户'), 'customer' => array('getter' => function (self $item) { if ($item) { return Customer::findOneByPk($item->customer_id); } return null; }), 'contact' => array('getter' => function (SampleProduceOrder $item) { if ($item->contact_id) { return CustomerContact::findOneByPk($item->contact_id); } return null; }), 'contact_id' => array('options' => function (SampleProduceOrder $item = null) { if ($item && $item->contact_id) { $contact_name = CustomerContact::findOneByPk($item->contact_id)->chinese_name; return array($item->contact_id => $contact_name); } return null; }, 'alias' => '联系人'), 'boss_head_employee_id' => array('options' => function () { $tmp = Employee::find('state=?', Employee::STATE_ENABLED)->all(true); return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name')); }, 'display' => function (self $item) { $tmp = Employee::findOneByPk($item->boss_head_employee_id); if (!$tmp) { return ''; } return $tmp->state == Employee::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>'; }, 'alias' => '负责人'), 'produce_finish_date' => array('default' => date('Y-m-d')), 'currency_id' => array('options' => function () { $tmp = Currency::find()->all(true); return array_combine(array_column($tmp, 'id'), array_column($tmp, 'unit_name')); }, 'display' => function (self $item) { if ($item) { $tmp = Currency::find()->all(true); $tmp = array_group($tmp, 'id', true); return $tmp[$item->currency_id]['unit_name']; } return ''; }), 'product_fee' => array('description' => 'RMB'), 'business_order' => array('getter' => function (self $item) { return BusinessOrder::findOneByPk($item->business_order_id); }))); }
public function __construct($data = array()) { parent::__construct($data); $this->setPropertiesDefine(array('customer_id' => array('display' => function (BusinessOrder $item) { return Customer::findOneByPk($item->customer_id)->company_alias_name; }, 'alias' => '公司简称'), 'customer_contact_id' => array('display' => function (BusinessOrder $item) { return CustomerContact::findOneByPk($item->customer_contact_id)->chinese_name; }, 'alias' => '联系人'), 'pay_type_id' => array('options' => function () { $tmp = PayType::find('state=?', PayType::STATE_ENABLED)->all(true); return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name')); }, 'display' => function (self $item) { $tmp = PayType::findOneByPk($item->pay_type_id); if (!$tmp) { return ''; } return $tmp->state == PayType::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>'; }), 'settle_currency_name' => array('getter' => function (BusinessOrder $item) { return $item->getPropertiesDefine('settle_currency')['options'][$item->settle_currency]; }), 'sample_produce_order' => array('getter' => function (self $item) { return SampleProduceOrder::find('business_order_id=?', $item->id)->one(); }))); }
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); }
/** * @param $get * @param $post * @return array * @throws Exception */ public function addSampleProduceOrder($get, $post) { $business_order_id = $get['id']; $business_order = BusinessOrder::findOneByPk($business_order_id); $sample_produce_order = new SampleProduceOrder(); if ($post) { $sample_list = BusinessOrderSamples::find('business_order_id=?', $business_order_id)->all(); if (empty($sample_list)) { throw new BizException('样品列表为空,您必须先添加样品'); } $exception = Model::transaction(function () use($sample_produce_order, $post, $sample_list, $business_order) { $sample_produce_order->setValues($post); $sample_produce_order->save(); $data = array(); /** @var BusinessOrderSamples $sm */ foreach ($sample_list as $sm) { $data[] = array('produce_order_id' => $sample_produce_order->id, 'sample_id' => $sm->sample_id, 'produce_num' => BusinessOrder::DEFAULT_PRODUCE_NUM, 'produce_request' => '无', 'produce_process_state' => 0, 'produce_employee_id' => 0); } SampleProduceOrderMapSamples::insertMany($data, false); }); if ($exception) { dump($exception, 1); throw new BizException($exception); } return new Result('送样成功', true); } $sample_produce_order = new SampleProduceOrder(); $customer = Customer::find('id = ?', $business_order->customer_id)->one(); $current_contact = CustomerContact::find('id =?', $business_order->customer_contact_id)->one(); return array('sample_produce_order' => $sample_produce_order, 'business_order' => $business_order, 'customer' => $customer, 'current_contact' => $current_contact); }