예제 #1
0
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;
}
예제 #2
0
 public function goods_max_qishu()
 {
     if ($this->segment(4) != 'dosubmit') {
         echo json_encode(array("meg" => "not key", "err" => "-1"));
         exit;
     }
     if (!isset($_POST['gid']) || !isset($_POST['qishu']) || !isset($_POST['money']) || !isset($_POST['onemoney'])) {
         echo json_encode(array("meg" => "参数不正确!", "err" => "-1"));
         exit;
     }
     $gid = abs(intval($_POST['gid']));
     $qishu = abs(intval($_POST['qishu']));
     $money = abs(intval($_POST['money']));
     $onemoney = abs(intval($_POST['onemoney']));
     if (!$gid || !$qishu || !$money || !$onemoney) {
         echo json_encode(array("meg" => "参数不正确!", "err" => "-1"));
         exit;
     }
     if ($money < $onemoney) {
         echo json_encode(array("meg" => " 总价不能小于云购价!", "err" => "-1"));
         exit;
     }
     $info = $this->db->GetOne("SELECT * FROM `@#_shoplist` where `id` = '{$gid}' and `q_end_time` is not null");
     if (!$info || $info['qishu'] != $info['maxqishu']) {
         echo json_encode(array("meg" => "没有该商品或还有剩余雨数!", "err" => "-1"));
         exit;
     }
     if ($qishu <= $info['qishu']) {
         echo json_encode(array("meg" => "雨数不正确!", "err" => "-1"));
         exit;
     }
     $ret = $this->db->Query("UPDATE `@#_shoplist` SET `maxqishu` = '{$qishu}' where `sid` = '{$info['sid']}'");
     if (!$ret) {
         echo json_encode(array("meg" => "雨数更新失败!", "err" => "-1"));
         exit;
     }
     $info['maxqishu'] = $qishu;
     $info['money'] = $money;
     $info['yunjiage'] = $onemoney;
     $info['zongrenshu'] = ceil($money / $onemoney);
     System::load_app_fun("content");
     $ret = content_add_shop_install($info);
     if ($ret) {
         echo json_encode(array("meg" => "新建商品成功!", "err" => "1"));
         exit;
     } else {
         echo json_encode(array("meg" => "更新失败失败!", "err" => "-1"));
         exit;
     }
 }
예제 #3
0
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;
}