public function editorderstatusAction() { $result = array('success' => true, 'info' => ''); $request = $this->getRequest()->getParams(); $id = isset($request['id']) ? $request['id'] : null; $order_status = isset($request['order_status']) ? $request['order_status'] : null; if ($id && $order_status) { $order = new Erp_Model_Sale_Order(); $order->update(array('order_status' => $order_status), "id = " . $id); } else { $result['success'] = false; $result['info'] = '参数错误'; } echo Zend_Json::encode($result); exit; }
public function refreshOrderTotal($order_id) { $data = array('total' => 0, 'forein_total' => 0); if ($order_id) { $dataTmp = $this->fetchAll("order_id = " . $order_id); if ($dataTmp->count() > 0) { $items = $dataTmp->toArray(); foreach ($items as $item) { $data['total'] += $item['total']; } } } $order = new Erp_Model_Sale_Order(); $orderData = $order->getData(null, $order_id); // 如果不是本币(汇率不为1),则需要将外币换算为本币 if ($orderData['currency_rate'] != 1) { $data['forein_total'] = $data['total']; $data['total'] = $data['forein_total'] * $orderData['currency_rate']; } $order->update($data, "id = " . $order_id); }
public function edittypeAction() { // 返回值数组 $result = array('success' => true, 'info' => '编辑成功'); $request = $this->getRequest()->getParams(); $now = date('Y-m-d H:i:s'); $user_session = new Zend_Session_Namespace('user'); $user_id = $user_session->user_info['user_id']; $json = json_decode($request['json']); $updated = $json->updated; $inserted = $json->inserted; $deleted = $json->deleted; $type = new Erp_Model_Sale_Type(); if (count($updated) > 0) { foreach ($updated as $val) { $data = array('active' => $val->active, 'code' => $val->code, 'name' => $val->name, 'tpl_id' => $val->tpl_id, 'flow_id' => $val->flow_id, 'description' => $val->description, 'remark' => $val->remark, 'update_time' => $now, 'update_user' => $user_id); if ($type->fetchAll("id != " . $val->id . " and (name = '" . $val->name . "' or code = '" . $val->code . "')")->count() > 0) { $result['success'] = false; $result['info'] = '销售类别:' . $val->name . "已存在,请勿重复添加!"; } else { try { $type->update($data, "id = " . $val->id); } catch (Exception $e) { $result['success'] = false; $result['info'] = $e->getMessage(); echo Zend_Json::encode($result); exit; } } } } if (count($inserted) > 0) { foreach ($inserted as $val) { $data = array('active' => $val->active, 'code' => $val->code, 'name' => $val->name, 'tpl_id' => $val->tpl_id, 'flow_id' => $val->flow_id, 'description' => $val->description, 'remark' => $val->remark, 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id); if ($type->fetchAll("name = '" . $val->name . "' or code = '" . $val->code . "'")->count() > 0) { $result['success'] = false; $result['info'] = '销售类别:' . $val->name . "已存在,请勿重复添加!"; } else { try { $type->insert($data); } catch (Exception $e) { $result['success'] = false; $result['info'] = $e->getMessage(); echo Zend_Json::encode($result); exit; } } } } if (count($deleted) > 0) { $order = new Erp_Model_Sale_Order(); foreach ($deleted as $val) { if ($order->fetchAll("type_id = " . $val->id)->count() == 0) { try { $type->delete("id = " . $val->id); } catch (Exception $e) { $result['success'] = false; $result['info'] = $e->getMessage(); echo Zend_Json::encode($result); exit; } } else { $result['success'] = false; $result['info'] = '销售类别' . $val->name . '已使用,不能删除'; echo Zend_Json::encode($result); exit; } } } echo Zend_Json::encode($result); exit; }