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; }
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 = addslashes($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 uid,username,email,mobile,img from `@#_member` where `uid` = '{$u_go_info['uid']}'"); //更新商品 $query = true; if ($u_info) { $u_info['username'] = _htmtocode($u_info['username']); $q_user = serialize($u_info); $gtimes = (int) System::load_sys_config('system', 'goods_end_time'); if ($gtimes == 0 || $gtimes == 1) { $q_showtime = 'N'; } else { $q_showtime = 'Y'; } $sqlss = "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 where `id` = '{$shop['id']}'"; $q = $db->Query($sqlss); if (!$q) { $query = false; } if ($q) { $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; } else { $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 { $query = false; } } else { $query = false; } /******************************/ /*新建*/ if ($query) { if ($shop['qishu'] < $shop['maxqishu']) { $maxinfo = $db->GetOne("select * from `@#_shoplist` where `sid` = '{$shop['sid']}' order by `qishu` DESC LIMIT 1"); if (!$maxinfo) { $maxinfo = array("qishu" => $shop['qishu']); } System::load_app_fun("content", G_ADMIN_DIR); $intall = content_add_shop_install($maxinfo, false); if (!$intall) { 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']}'"); } $apidata = file_get_contents("http://api.caipiaokong.com/lottery/?name=xjssc&format=json&uid=195161&num=1&token=3a914fc3d237dd40f6ad71b57ef5ac61793af9d4&order=sort"); $apiarray = json_decode($apidata, true); foreach ($apiarray as $key => $value) { $apinumberstr = str_replace(",", "", $apiarray[$key]['number']); } $apinumber = intval($apinumberstr); $tocode = System::load_app_class("tocode", "pay"); $tocode->shop = $shop; $tocode->run_tocode($time, 50, $shop['canyurenshu'], $apinumber, $shop); $code = $tocode->go_code; $content = addslashes($tocode->go_content); $counttime = $tocode->count_time; //20140901新增,判断是否指定中奖// if ($shop['quyu_begin'] && $shop['quyu_end']) { $ex_info = $db->GetOne("select * from `@#_member_go_record` where `shopid` = '{$shop['id']}' and `shopqishu` = '{$shop['qishu']}' and `uid` >'{$shop['quyu_begin']}' and `uid` <'{$shop['quyu_end']}' order by rand() limit 1"); if ($ex_info['goucode']) { $ex_code = explode(",", $ex_info['goucode']); $ex_count = count($ex_code); $ex_rand = rand(0, $ex_count - 1); if (!empty($ex_code[$ex_rand])) { $chazhi = $ex_code[$ex_rand] - $code; if ($chazhi > 0) { $counttime = $counttime + $chazhi; } else { $counttime = $counttime - abs($chazhi); } $code = $ex_code[$ex_rand]; /* $tempinfo = $db->GetOne("select * from `@#_member_go_record` where `shopid` = '$shop[id]' and `shopqishu` = '$shop[qishu]' and `goucode` LIKE '%$code%'"); //本来的中奖码对应的记录 $str=str_replace($code,$ex_code[0],$tempinfo['goucode']); $db->Query("update `@#_member_go_record` set goucode='$str' where id='{$tempinfo['id']}'"); //将系统原来的中奖吗对应的购买记录换成指定中奖会员购买的code $str2=str_replace($ex_code[0],$code,$ex_info['goucode']); $db->Query("update `@#_member_go_record` set goucode='$str2' where id='{$ex_info['id']}'"); //将指定中奖会员的购买记录中的code换成系统计算出来的中奖吗 */ //添加时间校准 if (!empty($chazhi)) { $last_info = $db->GetOne("select * from `@#_member_go_record` where `shopid` = '{$shop['id']}' and `shopqishu` = '{$shop['qishu']}' order by id desc limit 1"); $time_t_str = str_replace('.', '', $last_info['time']); $time_str = bcadd($time_t_str, $chazhi); $time_arr = str_split($time_str, 10); $str_t_time = $time_arr[0] . '.' . $time_arr[1]; $db->Query("UPDATE `@#_member_go_record` SET `time`='{$str_t_time}' where `id` = '{$last_info['id']}'"); $tocode = System::load_app_class("tocode", "pay"); $tocode->shop = $shop; $tocode->run_tocode($time, 100, $shop['canyurenshu'], $shop); $content = addslashes($tocode->go_content); } } } } ///////////////// $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 uid,username,email,mobile,img from `@#_member` where `uid` = '{$u_go_info['uid']}'"); //更新商品 $query = true; if ($u_info) { $u_info['username'] = _htmtocode($u_info['username']); $q_user = serialize($u_info); $gtimes = (int) System::load_sys_config('system', 'goods_end_time'); if ($gtimes == 0 || $gtimes == 1) { $q_showtime = 'N'; } else { $q_showtime = 'Y'; } $sqlss = "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 where `id` = '{$shop['id']}'"; $q = $db->Query($sqlss); if (!$q) { $query = false; } if ($q) { $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; } else { $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 { $query = false; } } else { $query = false; } /******************************/ /*新建*/ if ($query) { if ($shop['qishu'] < $shop['maxqishu']) { $maxinfo = $db->GetOne("select * from `@#_shoplist` where `sid` = '{$shop['sid']}' order by `qishu` DESC LIMIT 1"); if (!$maxinfo) { $maxinfo = array("qishu" => $shop['qishu']); } if (!$maxinfo) { $maxinfo = array("qishu" => $shop['qishu']); System::load_app_fun("content", G_ADMIN_DIR); $intall = content_add_shop_install($maxinfo, false); if (!$intall) { return $query; } } else { if ($maxinfo['id'] == $shop['id']) { System::load_app_fun("content", G_ADMIN_DIR); $intall = content_add_shop_install($maxinfo, false); if (!$intall) { return $query; } } } } } return $query; }