0) { Dever::setInput('set_product_id', $product_id); } //$data['product'] = $product; $data['cate_id'] = $cate_id; $data['product_id'] = $product_id; $data['type'] = $type; $db = Dever::db('code/info'); if ($product_id > 0) { $code = $db->insert($data, $num); $code = $this->view($code, true); return $code; } else { for ($i = 0; $i < $num; $i++) { $data['i'] = $i; $id = $db->insert($data); if ($id) { $code = $this->view($id, false); $db->update(array('code' => $code, 'where_id' => $id)); } } return $code; } } public function view($id, $state) { if ($state) { $code = Dever::uid($id * 10000000); $code = 'M' . $code; } else { $code = Dever::rand(4); $code = 'T' . $code . $id; } return $code; } }