public function goods_add() { if (isset($_POST['dosubmit'])) { $cateid = intval($_POST['cateid']); $brandid = intval($_POST['brand']); $title = _htmtocode($_POST['title']); $title_color = htmlspecialchars($_POST['title_style_color']); $title_bold = htmlspecialchars($_POST['title_style_bold']); $title2 = _htmtocode($_POST['title2']); $keywords = htmlspecialchars($_POST['keywords']); $description = htmlspecialchars($_POST['description']); $content = editor_safe_replace(stripslashes($_POST['content'])); $money = intval($_POST['money']); $yunjiage = intval($_POST['yunjiage']); $xiangou = intval($_POST['xiangou']); $thumb = htmlspecialchars($_POST['thumb']); $maxqishu = intval($_POST['maxqishu']); $canyurenshu = 0; $goods_key_pos = isset($_POST['goods_key']['pos']) ? 1 : 0; $goods_key_renqi = isset($_POST['goods_key']['renqi']) ? 1 : 0; $goods_key_bannershop = isset($_POST['goods_key']['bannershop']) ? 1 : 0; $renqipos = isset($_POST['goods_key']['renqipos']) ? 1 : 0; $newpos = isset($_POST['goods_key']['newpos']) ? 1 : 0; $posthumb = trim(htmlspecialchars($_POST['posthumb'])); if (!$cateid) { _message("请选择栏目"); } if (!$brandid) { _message("请选择品牌"); } if (!$title) { _message("标题不能为空"); } if (!$thumb) { _message("缩略图不能为空"); } $title_style = ''; if ($title_color) { $title_style .= 'color:' . $title_color . ';'; } if ($title_bold) { $title_style .= 'font-weight:' . $title_bold . ';'; } if (isset($_POST['uppicarr'])) { $picarr = serialize($_POST['uppicarr']); } else { $picarr = serialize(array()); } if ($_POST['xsjx_time'] != '') { $xsjx_time = strtotime($_POST['xsjx_time']) ? strtotime($_POST['xsjx_time']) : time(); $xsjx_time_h = intval($_POST['xsjx_time_h']) ? $_POST['xsjx_time_h'] : 36000; $xsjx_time += $xsjx_time_h; } else { $xsjx_time = '0'; } if ($maxqishu > 65535) { _message("最大雨数不能超过65535雨"); } if ($money < $yunjiage) { _message("商品价格不能小于购买价格"); } $zongrenshu = ceil($money / $yunjiage); $codes_len = ceil($zongrenshu / 3000); $shenyurenshu = $zongrenshu - $canyurenshu; if ($zongrenshu == 0 || $zongrenshu - $canyurenshu == 0) { _message("云购价格不正确"); } $time = time(); //商品添加时间 $this->db->Autocommit_start(); $query_1 = $this->db->Query("INSERT INTO `@#_shoplist` (`quyu`,`cateid`, `brandid`, `title`, `title_style`, `title2`, `keywords`, `description`, `money`, `yunjiage`, `xiangou`, `zongrenshu`, `canyurenshu`,`shenyurenshu`, `qishu`,`maxqishu`,`thumb`, `picarr`, `content`,`xsjx_time`,`renqi`,`pos`,`bannershop`,`renqipos`,`newpos`,`posthumb`, `time`) VALUES ('" . htmlspecialchars($_POST['quyu']) . "','{$cateid}', '{$brandid}', '{$title}', '{$title_style}', '{$title2}', '{$keywords}', '{$description}', '{$money}', '{$yunjiage}','{$xiangou}' ,'{$zongrenshu}', '{$canyurenshu}','{$shenyurenshu}', '1','{$maxqishu}', '{$thumb}', '{$picarr}', '{$content}','{$xsjx_time}','{$goods_key_renqi}', '{$goods_key_pos}','{$goods_key_bannershop}','{$renqipos}','{$newpos}','{$posthumb}','{$time}')"); $shopid = $this->db->insert_id(); System::load_app_fun("content"); $query_table = content_get_codes_table(); if (!$query_table) { $this->db->Autocommit_rollback(); _message("雨购码仓库不正确!"); } $query_2 = content_get_go_codes($zongrenshu, 3000, $shopid); $query_3 = $this->db->Query("UPDATE `@#_shoplist` SET `codes_table` = '{$query_table}',`sid` = '{$shopid}',`def_renshu` = '{$canyurenshu}' where `id` = '{$shopid}'"); if ($query_1 && $query_2 && $query_3) { $this->db->Autocommit_commit(); _message("商品添加成功!", WEB_PATH . '/' . ROUTE_M . '/content/goods_list/'); } else { $this->db->Autocommit_rollback(); _message("商品添加失败!"); } header("Cache-control: private"); } $cateid = intval($this->segment(4)); $categorys = $this->db->GetList("SELECT * FROM `@#_category` WHERE `model` = '1' order by `parentid` ASC,`cateid` ASC", array('key' => 'cateid')); $tree = System::load_sys_class('tree'); $tree->icon = array('│ ', '├─ ', '└─ '); $tree->nbsp = ' '; $categoryshtml = "<option value='\$cateid'>\$spacer\$name</option>"; $tree->init($categorys); $categoryshtml = $tree->get_tree(0, $categoryshtml); $categoryshtml = '<option value="0">≡ 请选择栏目 ≡</option>' . $categoryshtml; if ($cateid) { $cateinfo = $this->db->GetOne("SELECT * FROM `@#_category` WHERE `cateid` = '{$cateid}' LIMIT 1"); if (!$cateinfo) { _message("参数不正确,没有这个栏目", G_ADMIN_PATH . '/' . ROUTE_C . '/addarticle'); } $categoryshtml .= '<option value="' . $cateinfo['cateid'] . '" selected="true">' . $cateinfo['name'] . '</option>'; $BrandList = $this->db->GetList("SELECT * FROM `@#_brand` where `cateid`='{$cateid}'", array("key" => "id")); } else { $BrandList = $this->db->GetList("SELECT * FROM `@#_brand` where 1", array("key" => "id")); } $this->ment = array(array("lists", "商品管理", ROUTE_M . '/' . ROUTE_C . "/goods_list"), array("insert", "添加商品", ROUTE_M . '/' . ROUTE_C . "/goods_add")); include $this->tpl(ROUTE_M, 'shop.insert'); }
private function autolottery_install($shop = null) { if ($shop['qishu'] < $shop['maxqishu']) { $time = time(); System::load_app_fun("content", G_ADMIN_DIR); $goods = $shop; $qishu = $goods['qishu'] + 1; $shenyurenshu = $goods['zongrenshu'] - $goods['def_renshu']; $query_table = content_get_codes_table(); $q_1 = $this->db->Query("INSERT INTO `@#_shoplist` (`sid`,`cateid`, `brandid`, `title`, `title_style`, `title2`, `keywords`, `description`, `money`, `yunjiage`, `zongrenshu`, `canyurenshu`,`shenyurenshu`,`def_renshu`, `qishu`,`maxqishu`,`thumb`, `picarr`, `content`,`codes_table`,`xsjx_time`,`renqi`,`pos`, `time`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$goods['sid']}','{$goods['cateid']}','{$goods['brandid']}','{$goods['title']}','{$goods['title_style']}','{$goods['title2']}','{$goods['keywords']}','{$goods['description']}','{$goods['money']}','{$goods['yunjiage']}','{$goods['zongrenshu']}','{$goods['def_renshu']}','{$shenyurenshu}','{$goods['def_renshu']}','{$qishu}','{$goods['maxqishu']}','{$goods['thumb']}','{$goods['picarr']}','{$goods['content']}','{$query_table}','0','{$goods['renqi']}','{$goods['pos']}','{$time}')\n\t\t\t\t\t"); $id = $this->db->insert_id(); $q_2 = content_get_go_codes($goods['zongrenshu'], 3000, $id); if ($q_1 && $q_2) { return true; } else { return false; } } return true; }
function content_add_shop_install($info = null, $autocommit = true) { $db = System::load_sys_class("model"); if ($autocommit) { $db->Autocommit_start(); } unset($info['id']); unset($info['q_uid']); unset($info['q_user']); unset($info['q_user_code']); unset($info['q_content']); unset($info['q_counttime']); unset($info['q_end_time']); $info['xsjx_time'] = 0; $info['time'] = time(); $info['qishu'] = intval($info['qishu']); $info['qishu']++; $info['canyurenshu'] = '0'; $info['shenyurenshu'] = $info['zongrenshu']; $info['codes_table'] = content_get_codes_table(); $info['q_showtime'] = 'N'; $info['title'] = _htmtocode($info['title']); $info['title2'] = _htmtocode($info['title2']); $keys = $vals = '('; foreach ($info as $key => $val) { $keys .= "`{$key}`,"; $vals .= "'{$val}',"; } $keys = rtrim($keys, ','); $vals = rtrim($vals, ','); $keys .= ')'; $vals .= ')'; $sql = "INSERT INTO `@#_shoplist` " . $keys . " VALUES " . $vals; $q1 = $db->Query($sql); $id = $db->insert_id(); $q2 = content_get_go_codes($info['zongrenshu'], 3000, $id); if ($autocommit) { if ($q1 && $q2) { $db->Autocommit_commit(); return true; } else { $db->Autocommit_rollback(); return false; } } else { if ($q1 && $q2) { return true; } else { return false; } } }
function pay_insert_shop($shop = '', $type = '') { $time = sprintf("%.3f", microtime(true) + (int) System::load_sys_config('system', 'goods_end_time')); $db = System::load_sys_class("model"); if ($shop['xsjx_time'] != '0') { return $db->Query("UPDATE `@#_shoplist` SET `canyurenshu`=`zongrenshu`,\t`shenyurenshu` = '0' where `id` = '{$shop['id']}'"); } $tocode = System::load_app_class("tocode", "pay"); $tocode->shop = $shop; $tocode->run_tocode($time, 100, $shop['canyurenshu'], $shop); $code = $tocode->go_code; $content = $tocode->go_content; $counttime = $tocode->count_time; // hyu-modify if (empty($shop['q_uid_a'])) { $u_go_info = $db->GetOne("select * from `@#_member_go_record` \n\t\t\t\twhere `shopid` = '{$shop['id']}' \n\t\t\t\tand `shopqishu` = '{$shop['qishu']}' \n\t\t\t\tand `goucode` LIKE '%{$code}%'"); } else { $u_go_info = $db->GetOne("select * from `@#_member_go_record` \n where `shopid` = '{$shop['id']}' \n and `shopqishu` = '{$shop['qishu']}' \n and `goucode` LIKE '%{$shop['q_user_assign']}%'"); } $u_info = $db->GetOne("select * from `@#_member` where `uid` = '{$u_go_info['uid']}'"); $q_user = serialize($u_info); //更新商品 $query = true; if ($u_info) { $gtimes = (int) System::load_sys_config('system', 'goods_end_time'); if ($gtimes == 0 || $gtimes == 1) { $q_showtime = 'N'; } else { $q_showtime = 'Y'; } // hyu-modify if (empty($shop['q_uid_a'])) { $q = $db->Query("UPDATE `@#_shoplist` SET \n\t\t\t\t\t`canyurenshu`=`zongrenshu`,\n\t\t\t\t\t`shenyurenshu` = '0',\n\t\t\t\t\t`q_uid` = '{$u_info['uid']}',\n\t\t\t\t\t`q_user` = '{$q_user}',\n\t\t\t\t\t`q_user_code` = '{$code}',\n\t\t\t\t\t`q_content`\t= '{$content}',\n\t\t\t\t\t`q_counttime` ='{$counttime}',\n\t\t\t\t\t`q_end_time` = '{$time}',\n\t\t\t\t\t`q_showtime` = '{$q_showtime}'\n\t\t\t\t\t where `id` = '{$shop['id']}'"); } else { $q = $db->Query("UPDATE `@#_shoplist` SET \n `canyurenshu`=`zongrenshu`,\n `shenyurenshu` = '0',\n `q_uid` = '{$shop['q_uid_a']}',\n `q_user_code` = '{$shop['q_user_assign']}',\n `q_content` = '{$content}',\n `q_counttime` ='{$counttime}',\n `q_end_time` = '{$time}',\n `q_showtime` = '{$q_showtime}'\n where `id` = '{$shop['id']}'"); } if (!$q) { $query = false; } // hyu-modify if (empty($shop['q_uid_a'])) { $q = $db->Query("UPDATE `@#_member_go_record` SET \n\t\t\t\t\t`huode` = '{$code}' \n\t\t\t\twhere `id` = '{$u_go_info['id']}' \n\t\t\t\tand `code` = '{$u_go_info['code']}' \n\t\t\t\tand `uid` = '{$u_go_info['uid']}' \n\t\t\t\tand `shopid` = '{$shop['id']}' \n\t\t\t\tand `shopqishu` = '{$shop['qishu']}'"); } else { $q = $db->Query("UPDATE `@#_member_go_record` SET \n `huode` = '{$shop['q_user_assign']}' \n where `id` = '{$u_go_info['id']}' \n and `code` = '{$u_go_info['code']}' \n and `uid` = '{$u_go_info['uid']}' \n and `shopid` = '{$shop['id']}' \n and `shopqishu` = '{$shop['qishu']}'"); } if (!$q) { $query = false; } $post_arr = array("uid" => $u_info['uid'], "gid" => $shop['id'], "send" => 1); _g_triggerRequest(WEB_PATH . '/api/send/send_shop_code', false, $post_arr); } /******************************/ //新建 if ($shop['qishu'] < $shop['maxqishu']) { $time = time(); System::load_app_fun("content", G_ADMIN_DIR); $goods = $shop; $qishu = $goods['qishu'] + 1; $shenyurenshu = $goods['zongrenshu'] - $goods['def_renshu']; $query_table = content_get_codes_table(); $q = $db->Query("INSERT INTO `@#_shoplist` (`sid`,`cateid`, `brandid`, `title`, `title_style`, `title2`, `keywords`, `description`, `money`, `yunjiage`, `zongrenshu`, `canyurenshu`,`shenyurenshu`,`def_renshu`, `qishu`,`maxqishu`,`thumb`, `picarr`, `content`,`codes_table`,`xsjx_time`,`renqi`,`pos`, `time`)\n\t\t\t\tVALUES\n\t\t\t\t('{$goods['sid']}','{$goods['cateid']}','{$goods['brandid']}','{$goods['title']}','{$goods['title_style']}','{$goods['title2']}','{$goods['keywords']}','{$goods['description']}','{$goods['money']}','{$goods['yunjiage']}','{$goods['zongrenshu']}','{$goods['def_renshu']}','{$shenyurenshu}','{$goods['def_renshu']}','{$qishu}','{$goods['maxqishu']}','{$goods['thumb']}','{$goods['picarr']}','{$goods['content']}','{$query_table}','{$goods['xsjx_time']}','{$goods['renqi']}','{$goods['pos']}','{$time}')\n\t\t\t\t"); if (!$q) { return $query; } $id = $db->insert_id(); $q = content_get_go_codes($goods['zongrenshu'], 3000, $id); if (!$q) { return $query; } } return $query; }
function pay_insert_shop($shop = '', $type = '') { $time = sprintf("%.3f", microtime(true) + (int) System::load_sys_config('system', 'goods_end_time')); $db = System::load_sys_class("model"); if ($shop['xsjx_time'] != '0') { return $db->Query("UPDATE `@#_shoplist` SET `canyurenshu`=`zongrenshu`,\t`shenyurenshu` = '0' where `id` = '{$shop['id']}'"); } //增加以下代码,获取彩票的开奖结果 $kaicai = System::load_app_class("pay", "pay"); $kaicai->kaicai(); $kaicaidata = $kaicai->datas; //修改run_tocode函数里面的参数值,传入总需人数'zongrenshu'和彩票的结果'nums' //run_tocode函数修改为只传入获取的最后记录条数、总需人数和彩票开奖号码 $tocode = System::load_app_class("tocode", "pay"); $tocode->shop = $shop; $tocode->run_tocode(50, $shop['zongrenshu'], $kaicaidata['nums']); $code = $tocode->go_code; $content = $tocode->go_content; $counttime = $tocode->count_time; $u_go_info = $db->GetOne("select * from `@#_member_go_record` where `shopid` = '{$shop['id']}' and `shopqishu` = '{$shop['qishu']}' and `goucode` LIKE '%{$code}%'"); $u_info = $db->GetOne("select * from `@#_member` where `uid` = '{$u_go_info['uid']}'"); $q_user = serialize($u_info); //更新商品 $query = true; if ($u_info) { $gtimes = (int) System::load_sys_config('system', 'goods_end_time'); if ($gtimes == 0 || $gtimes == 1) { $q_showtime = 'N'; } else { $q_showtime = 'Y'; } //在数据库表shoplist中增加‘lottery_period’,‘lottery_num’两个字段,用来存入彩票开奖期数与结果 $q = $db->Query("UPDATE `@#_shoplist` SET \n\t\t\t\t\t\t\t`canyurenshu`=`zongrenshu`,\n\t\t\t\t\t\t\t`shenyurenshu` = '0',\n\t\t\t\t\t\t\t`q_uid` = '{$u_info['uid']}',\n\t\t\t\t\t\t\t`q_user` = '{$q_user}',\n\t\t\t\t\t\t\t`q_user_code` = '{$code}',\n\t\t\t\t\t\t\t`q_content`\t= '{$content}',\n\t\t\t\t\t\t\t`q_counttime` ='{$counttime}',\n\t\t\t\t\t\t\t`q_end_time` = '{$time}',\n\t\t\t\t\t\t\t`q_showtime` = '{$q_showtime}',\n\t\t\t\t\t\t\t`lottery_period` = '{$kaicaidata['qishu']}',\n\t\t\t\t\t\t\t`lottery_num` = '{$kaicaidata['nums']}'\n\t\t\t\t\t\t\t where `id` = '{$shop['id']}'"); if (!$q) { $query = false; } $q = $db->Query("UPDATE `@#_member_go_record` SET `huode` = '{$code}' where `id` = '{$u_go_info['id']}' and `code` = '{$u_go_info['code']}' and `uid` = '{$u_go_info['uid']}' and `shopid` = '{$shop['id']}' and `shopqishu` = '{$shop['qishu']}'"); if (!$q) { $query = false; } $post_arr = array("uid" => $u_info['uid'], "gid" => $shop['id'], "send" => 1); _g_triggerRequest(WEB_PATH . '/api/send/send_shop_code', false, $post_arr); } else { //增加没有中奖人的信息写入,q_uid等于0就表示无人中奖。 $gtimes = (int) System::load_sys_config('system', 'goods_end_time'); if ($gtimes == 0 || $gtimes == 1) { $q_showtime = 'N'; } else { $q_showtime = 'Y'; } $q = $db->Query("UPDATE `@#_shoplist` SET \n\t\t\t\t\t\t\t`canyurenshu`=`zongrenshu`,\n\t\t\t\t\t\t\t`shenyurenshu` = '0',\n\t\t\t\t\t\t\t`q_uid` = '0',\n\t\t\t\t\t\t\t`q_user` = '',\n\t\t\t\t\t\t\t`q_user_code` = '{$code}',\n\t\t\t\t\t\t\t`q_content`\t= '{$content}',\n\t\t\t\t\t\t\t`q_counttime` ='{$counttime}',\n\t\t\t\t\t\t\t`q_end_time` = '{$time}',\n\t\t\t\t\t\t\t`q_showtime` = '{$q_showtime}',\n\t\t\t\t\t\t\t`lottery_period` = '{$kaicaidata['qishu']}',\n\t\t\t\t\t\t\t`lottery_num` = '{$kaicaidata['nums']}'\n\t\t\t\t\t\t\t where `id` = '{$shop['id']}'"); if (!$q) { $query = false; } $q = $db->Query("UPDATE `@#_member_go_record` SET `huode` = '{$code}' where `id` = '{$u_go_info['id']}' and `code` = '{$u_go_info['code']}' and `uid` = '{$u_go_info['uid']}' and `shopid` = '{$shop['id']}' and `shopqishu` = '{$shop['qishu']}'"); if (!$q) { $query = false; } $post_arr = array("uid" => $u_info['uid'], "gid" => $shop['id'], "send" => 1); _g_triggerRequest(WEB_PATH . '/api/send/send_shop_code', false, $post_arr); } /******************************/ //新建 if ($shop['qishu'] < $shop['maxqishu']) { $time = time(); System::load_app_fun("content", G_ADMIN_DIR); $goods = $shop; $qishu = $goods['qishu'] + 1; $shenyurenshu = $goods['zongrenshu'] - $goods['def_renshu']; $query_table = content_get_codes_table(); $q = $db->Query("INSERT INTO `@#_shoplist` (`sid`,`cateid`, `brandid`, `title`, `title_style`, `title2`, `keywords`, `description`, `money`, `yunjiage`, `zongrenshu`, `canyurenshu`,`shenyurenshu`,`def_renshu`, `qishu`,`maxqishu`,`thumb`, `picarr`, `content`,`codes_table`,`xsjx_time`,`renqi`,`pos`, `time`)\n\t\t\t\tVALUES\n\t\t\t\t('{$goods['sid']}','{$goods['cateid']}','{$goods['brandid']}','{$goods['title']}','{$goods['title_style']}','{$goods['title2']}','{$goods['keywords']}','{$goods['description']}','{$goods['money']}','{$goods['yunjiage']}','{$goods['zongrenshu']}','{$goods['def_renshu']}','{$shenyurenshu}','{$goods['def_renshu']}','{$qishu}','{$goods['maxqishu']}','{$goods['thumb']}','{$goods['picarr']}','{$goods['content']}','{$query_table}','{$goods['xsjx_time']}','{$goods['renqi']}','{$goods['pos']}','{$time}')\n\t\t\t\t"); if (!$q) { return $query; } $id = $db->insert_id(); $q = content_get_go_codes($goods['zongrenshu'], 3000, $id); if (!$q) { return $query; } } return $query; }