public function before() { parent::before(); $action = $this->request->action(); /*if($action == 'article') { $param = $this->params['action']; $right = array( 'read'=>'slook', 'save'=>'smodify', 'delete'=>'sdelete', 'update'=>'smodify' ); $user_action = $right[$param]; if(!empty($user_action)) Common::getUserRight('article',$user_action); } else if($action == 'add') { Common::getUserRight('article','sadd'); } else if($action == 'edit') { Common::getUserRight('article','smodify'); } else if($action == 'ajax_save') { Common::getUserRight('article','smodify'); }*/ $this->assign('parentkey', $this->params['parentkey']); $this->assign('itemid', $this->params['itemid']); $this->assign('weblist', Common::getWebList()); $this->addmodule = ORM::factory('model')->where("id>13")->get_all(); $this->typeid = $this->params['typeid']; $this->modulename = Model_Model::getModuleName($this->typeid); $this->assign('typeid', $this->typeid); $this->assign('modulename', $this->modulename); foreach (self::$kind as $key => $row) { self::$kind[$key]['url'] = str_replace('{#typeid#}', $this->typeid, $row['url']); self::$kind[$key]['itemid'] = str_replace('{#typeid#}', $this->typeid, $row['itemid']); } }
public function action_index() { $action = $this->params['action']; $typeid = $this->params['typeid']; $webid = Arr::get($_GET, 'webid'); $this->assign('typeid', $typeid); //订单模板 //$channelname = self::$channelArr[$typeid]; $channelname = Model_Model::getModuleName($typeid); if (empty($action)) { $this->assign('paysources', Model_Member_Order::getPaySources()); $this->assign('statusnames', Model_Member_Order::getStatusNamesJs()); $this->assign('position', $channelname . '订单'); $this->assign('channelname', $channelname); $this->display('stourtravel/order/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $status = $_GET['status']; $paysource = $_GET['paysource']; $order = 'order by a.addtime desc'; $w = "where a.typeid = {$typeid}"; if ($status != '') { $w .= ' and a.status=' . $status; } if (!empty($paysource)) { $w .= " and a.paysource='{$paysource}'"; } if (!empty($keyword)) { $w .= " and (a.ordersn like '%{$keyword}%' or a.linkman like '%{$keyword}%' or a.linktel like '%{$keyword}%' or a.productname like '%{$keyword}%')"; $start = 0; } $w .= empty($webid) ? ' and a.webid=0' : " and a.webid={$webid}"; $sql = "select a.* from sline_member_order as a {$w} {$order} limit {$start},{$limit}"; $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_member_order a {$w} ")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['addtime'] = Common::myDate('Y-m-d H:i:s', $v['addtime']); if ($v['pid'] != 0) { $v['productname'] = $v['productname'] . "[<span style='color:red'>子订单</span>]"; } $new_list[] = $v; } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('order', $id); Model_member_Order::refundStorage($id, 'plus'); $model->delete(); } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); if (is_numeric($id)) { $model = ORM::factory('order')->where('id', '=', $id)->find(); } if ($model->id) { $oldstatus = $model->status; $model->{$field} = $val; $model->update(); if ($model->saved()) { echo 'ok'; if ($field == 'status' && $val == 2) { // Model_Member_Order::refundJifen($id); Common::paySuccess($model->ordersn); } if ($field == 'status' && $val == 3) { Model_member_Order::refundStorage($id, 'plus'); } else { if ($field == 'status' && $oldstatus == 3 && $val == 1) { Model_Member_Order::refundStorage($id, 'minus'); //订单增加,库存减少 } } } else { echo 'no'; } } } } } } } }
public function action_extendlist() { $action = $this->params['action']; $typeid = $this->params['typeid']; //栏目id. $extend_table = 'sline_extend_field'; //当前操作表 $this->assign('typeid', $typeid); $isextendmodel = intval($typeid) > 13 ? 1 : 0; $this->assign('isextendmodel', $isextendmodel); if (empty($action)) { $channelname = Model_Model::getModuleName($typeid); //产品名 //$menu = self::$product_arr[$typeid].'kind'; $this->assign('typeid', $typeid); //$this->assign('menu',$menu); $this->assign('channelname', $channelname); $this->display('stourtravel/attr/extendfield'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $sql = "select a.* from {$extend_table} as a where typeid='{$typeid}' order by addtime desc limit {$start},{$limit}"; $list = DB::query(1, $sql, false)->execute()->as_array(); $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from {$extend_table} where typeid='{$typeid}' ")->execute()->as_array(); $result['total'] = $totalcount_arr[0]['count']; $result['lists'] = $list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'add') { $this->display('stourtravel/attr/addfield'); } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; $fieldname = $data->fieldname; $typeid = $this->params['typeid']; //$extend_table = self::$extend_table_arr[$typeid]; $extend_table = 'sline_' . Model_Model::getExtendTable($typeid); //扩展表名称 if (is_numeric($id)) { $flag = ORM::factory('extend_field', $id)->delete(); Common::delField($extend_table, $fieldname); } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); if (is_numeric($id)) { $model = ORM::factory('extend_field')->where('id', '=', $id)->find(); } if ($model->id) { $model->{$field} = $val; $model->update(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } }