/** * 重置商品价格 **/ public function goods_set_money() { $this->ment = array(array("lists", "商品管理", ROUTE_M . '/' . ROUTE_C . "/goods_list"), array("add", "添加商品", ROUTE_M . '/' . ROUTE_C . "/goods_add"), array("renqi", "人气商品", ROUTE_M . '/' . ROUTE_C . "/goods_list/renqi"), array("xsjx", "限时揭晓商品", ROUTE_M . '/' . ROUTE_C . "/goods_list/xianshi"), array("qishu", "雨数倒序", ROUTE_M . '/' . ROUTE_C . "/goods_list/qishu"), array("danjia", "单价倒序", ROUTE_M . '/' . ROUTE_C . "/goods_list/danjia"), array("money", "商品价格倒序", ROUTE_M . '/' . ROUTE_C . "/goods_list/money"), array("money", "已揭晓", ROUTE_M . '/' . ROUTE_C . "/goods_list/jiexiaook"), array("money", "<font color='#f00'>雨数已满商品</font>", ROUTE_M . '/' . ROUTE_C . "/goods_list/maxqishu")); $this->db->Autocommit_start(); $gid = abs(intval($this->segment(4))); $shopinfo = $this->db->GetOne("SELECT * FROM `@#_shoplist` where `id` = '{$gid}' for update"); if (!$shopinfo || !empty($shopinfo['q_uid'])) { _message("参数不正确!"); exit; } if (isset($_POST['money']) || isset($_POST['yunjiage'])) { $new_money = abs(intval($_POST['money'])); $new_one_m = abs(intval($_POST['yunjiage'])); if ($new_one_m > $new_money) { _message("单人次购买价格不能大于商品总价格!"); } if (!$new_one_m || !$new_money) { _message("价格填写错误!"); } if ($new_one_m == $shopinfo['yunjiage'] && $new_money == $shopinfo['money']) { _message("价格没有改变!"); } System::load_app_fun("content"); $table = $shopinfo['codes_table']; $this->db->Autocommit_start(); $q1 = $this->db->Query("DELETE FROM `@#_member_go_record` WHERE `shopid` = '{$gid}'"); $q2 = $this->db->Query("DELETE FROM `@#_{$table}` WHERE `s_id` = '{$gid}'"); $zongrenshu = ceil($new_money / $new_one_m); $q3 = content_get_go_codes($zongrenshu, 3000, $gid); $q4 = $this->db->Query("UPDATE `@#_shoplist` SET \r\n\t\t\t`canyurenshu` = '0',\r\n\t\t\t`zongrenshu` = '{$zongrenshu}', \r\n\t\t\t`money` = '{$new_money}', \r\n\t\t\t`yunjiage` = '{$new_one_m}', \r\n\t\t\t`shenyurenshu` = `zongrenshu`\r\n\t\t\twhere `id` = '{$gid}'"); if ($q1 && $q2 && $q3 && $q4) { $this->db->Autocommit_commit(); _message("更新成功!", WEB_PATH . '/' . ROUTE_M . '/content/goods_list/'); } else { $this->db->Autocommit_rollback(); _message("更新失败!"); } } include $this->tpl(ROUTE_M, 'shop.set_money'); }
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 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 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']}'"); } //增加以下代码,获取彩票的开奖结果 $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; }
/** * 添加信息 */ public function add() { if ($_POST) { $flags = $_POST['flags']; if ($_POST['flags']) { $_POST['flags'] = implode(',', $_POST['flags']); } else { $_POST['flags'] = ''; } //分类处理 $model = D('Category'); $tdata['id'] = $_POST['tid']; $vv = $model->where($tdata)->find(); $_POST['type_name'] = $vv['name']; if ($vv['pid']) { $tdata['id'] = $vv['pid']; $vv = $model->where($tdata)->find(); if ($vv['pid']) { $tdata['id'] = $vv['pid']; $vv = $model->where($tdata)->find(); } $_POST['toptid'] = $vv['id']; } else { $_POST['toptid'] = $vv['id']; } //图片处理处理 if ($_FILES) { $this->upload(); } $model = D(CONTROLLER_NAME); $model->startTrans(); //启用事务 $_POST['create_time'] = time(); $_POST['zongrenshu'] = $_POST['shenyurenshu'] = ceil($_POST['money'] / $_POST['yunjiage']); if (false === $model->create()) { $this->error($model->getError()); } // 更新数据 $id = $model->add(); if (false !== $id) { //sid处理 $s_data['sid'] = $id; $w_data['id'] = $id; $model->where($w_data)->save($s_data); //验证码生成 $result = 1; $smodel = M('shopcodes_2015'); $zongrenshu = ceil($_POST['money'] / $_POST['yunjiage']); $base_num = 200; $codes_len = ceil($zongrenshu / $base_num); if ($zongrenshu == 0 || $zongrenshu - $canyurenshu == 0) { $this->error("云购价格不正确"); } $codes = content_get_go_codes($zongrenshu, $base_num); foreach ($codes as $key => $code) { $s_add_data['s_id'] = $id; $s_add_data['s_cid'] = $key + 1; $s_add_data['s_len'] = count($code); $s_add_data['s_codes'] = serialize($code); $s_add_data['s_codes_tmp'] = serialize($code); if ($result) { $result = $smodel->add($s_add_data); } } if ($result) { $model->commit(); } else { $model->rollback(); $this->error('新增失败'); exit; } //成功提示 $this->history($id); //相关属性表修改 $amodel = D('flag_list'); if ($flags) { $data1['source'] = $name; $data1['sourceid'] = $result; $data1['sort'] = 200; $flagss = $this->get_moudel_flags(); foreach ($flags as $fid) { $data1['fid'] = $fid; $data1['fname'] = $flagss[$fid]['name']; $data1['create_time'] = time(); $amodel->add($data1); } } $this->success('新增成功!'); } else { $this->error('新增失败!'); } exit; } else { //$arr = content_get_go_codes(88,20); $this->other_msg(); $flags = $this->get_moudel_flags(); $this->assign('flags', $flags); $hash = md5($_SESSION[C('USER_AUTH_KEY')] . time()); $this->assign('imgurl', C('IMG_URL')); $this->assign('hash', $hash); $this->display(); } }