$operation = $_GP['op']; if ($operation == 'post') { $id = intval($_GP['id']); $data = array('openid' => $openid, 'realname' => $_GP['realname'], 'mobile' => $_GP['mobile'], 'province' => $_GP['province'], 'city' => $_GP['city'], 'area' => $_GP['area'], 'address' => $_GP['address']); if (empty($_GP['realname']) || empty($_GP['mobile']) || empty($_GP['address'])) { message('请输完善您的资料!'); } if (!empty($id)) { unset($data['openid']); mysqld_update('shop_address', $data, array('id' => $id)); message($id, '', 'ajax'); } else { mysqld_update('shop_address', array('isdefault' => 0), array('openid' => $openid)); $data['isdefault'] = 1; mysqld_insert('shop_address', $data); $id = mysqld_insertid(); if (!empty($id)) { message($id, '', 'ajax'); } else { message(0, '', 'ajax'); } } } elseif ($operation == 'default') { $id = intval($_GP['id']); mysqld_update('shop_address', array('isdefault' => 0), array('openid' => $openid)); mysqld_update('shop_address', array('isdefault' => 1), array('id' => $id)); message(1, '', 'ajax'); } elseif ($operation == 'detail') { $id = intval($_GP['id']); $row = mysqld_select("SELECT id, realname, mobile, province, city, area, address FROM " . table('shop_address') . " WHERE id = :id", array(':id' => $id)); message($row, '', 'ajax');
} mkdirs($destination); $handle = dir($source); while ($entry = $handle->read()) { if ($entry != "." && $entry != "..") { if (is_dir($source . "/" . $entry)) { if ($child) { xCopy($source . "/" . $entry, $destination . "/" . $entry, $child); } } else { copy($source . "/" . $entry, $destination . "/" . $entry); } } } return 1; } $tmpfoldername = random(15); $tmpfolder = 'addon10/' . $tmpfoldername . '/style13/'; $page_tmpfolder = 'addon10\\/' . $tmpfoldername . '\\/style13\\/'; xCopy(ADDONS_ROOT . 'addon10/demo/style13/', WEB_ROOT . '/attachment/' . $tmpfolder, 1); $list_data = array('title' => '您的家庭摄影师', 'theme' => 'style13', 'iden' => 'style13', 'cover' => '', 'share_title' => '您的家庭摄影师', 'share_thumb' => $tmpfolder . 'share.jpg', 'share_content' => '您的家庭摄影师', 'reply_title' => '您的家庭摄影师', 'reply_thumb' => $tmpfolder . 'default_cover.jpg', 'reply_description' => '您的家庭摄影师', 'isadvanced' => 0, 'first_type' => 0, 'bg_music_switch' => 1, 'bg_music_icon' => 1, 'bg_music_url' => $tmpfolder . 'sound.mp3', 'hits' => 0, 'isyuyue' => 0, 'iscomment' => 0); mysqld_insert('addon10_scene_list', $list_data); $list_id = mysqld_insertid(); $pagestr = ' [{"listorder":"0","m_type":"11","thumb":"' . $page_tmpfolder . 'default_bg.jpg","param":"a:3:{s:4:\\"str1\\";s:19:\\"Gift for the Future\\";s:4:\\"str2\\";s:24:\\"\\u56de\\u5fc6\\uff0c\\u5b58\\u4e88\\u672a\\u6765...\\";s:6:\\"thumbs\\";a:28:{i:0;s:74:\\"' . $page_tmpfolder . 'page1\\/1.jpg\\";i:1;s:74:\\"' . $page_tmpfolder . 'page1\\/2.jpg\\";i:2;s:74:\\"' . $page_tmpfolder . 'page1\\/3.jpg\\";i:3;s:74:\\"' . $page_tmpfolder . 'page1\\/4.jpg\\";i:4;s:74:\\"' . $page_tmpfolder . 'page1\\/5.jpg\\";i:5;s:74:\\"' . $page_tmpfolder . 'page1\\/6.jpg\\";i:6;s:74:\\"' . $page_tmpfolder . 'page1\\/7.jpg\\";i:7;s:74:\\"' . $page_tmpfolder . 'page1\\/8.jpg\\";i:8;s:74:\\"' . $page_tmpfolder . 'page1\\/9.jpg\\";i:9;s:75:\\"' . $page_tmpfolder . 'page1\\/10.jpg\\";i:10;s:75:\\"' . $page_tmpfolder . 'page1\\/11.jpg\\";i:11;s:75:\\"' . $page_tmpfolder . 'page1\\/12.jpg\\";i:12;s:75:\\"' . $page_tmpfolder . 'page1\\/13.jpg\\";i:13;s:75:\\"' . $page_tmpfolder . 'page1\\/14.jpg\\";i:14;s:75:\\"' . $page_tmpfolder . 'page1\\/15.jpg\\";i:15;s:75:\\"' . $page_tmpfolder . 'page1\\/16.jpg\\";i:16;s:75:\\"' . $page_tmpfolder . 'page1\\/17.jpg\\";i:17;s:75:\\"' . $page_tmpfolder . 'page1\\/18.jpg\\";i:18;s:75:\\"' . $page_tmpfolder . 'page1\\/19.jpg\\";i:19;s:75:\\"' . $page_tmpfolder . 'page1\\/20.jpg\\";i:20;s:75:\\"' . $page_tmpfolder . 'page1\\/21.jpg\\";i:21;s:75:\\"' . $page_tmpfolder . 'page1\\/22.jpg\\";i:22;s:75:\\"' . $page_tmpfolder . 'page1\\/23.jpg\\";i:23;s:75:\\"' . $page_tmpfolder . 'page1\\/24.jpg\\";i:24;s:75:\\"' . $page_tmpfolder . 'page1\\/25.jpg\\";i:25;s:75:\\"' . $page_tmpfolder . 'page1\\/26.jpg\\";i:26;s:75:\\"' . $page_tmpfolder . 'page1\\/27.jpg\\";i:27;s:75:\\"' . $page_tmpfolder . 'page1\\/28.jpg\\";}}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '1.jpg","param":"a:3:{s:3:\\"top\\";s:2:\\"20\\";s:4:\\"str1\\";s:26:\\"Tick tock, time passing\\u2026\\";s:4:\\"str2\\";s:38:\\"\\u4f60\\u7684\\u5230\\u6765, \\u8ba9\\u65f6\\u5149\\u66f4\\u663e\\u5306\\u5306\\u2026\\";}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '2.jpg","param":"a:3:{s:3:\\"top\\";s:2:\\"20\\";s:4:\\"str1\\";s:34:\\"You are just like the little me\\u2026\\";s:4:\\"str2\\";s:51:\\"\\u671b\\u7740\\u5c0f\\u5c0f\\u7684\\u4f60\\uff0c\\u4eff\\u4f5b\\u770b\\u5230\\u81ea\\u5df1\\u5c0f\\u65f6\\u5019\\u2026\\";}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '3.jpg","param":"a:3:{s:3:\\"top\\";s:1:\\"5\\";s:4:\\"str1\\";s:41:\\"In my eyes, you are the one so special\\u2026\\";s:4:\\"str2\\";s:34:\\" \\u5728\\u6211\\u773c\\u4e2d\\uff0c\\u4f60\\u5982\\u6b64\\u72ec\\u7279\\u2026\\";}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '4.jpg","param":"a:3:{s:3:\\"top\\";s:2:\\"75\\";s:4:\\"str1\\";s:23:\\"Let me accompany you\\u2026\\";s:4:\\"str2\\";s:40:\\" \\u53ea\\u60f3\\u966a\\u4f60\\uff0c\\u518d\\u4e00\\u6b21\\u4eb2\\u5386\\u7ae5\\u5e74\\u2026\\";}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '5.jpg","param":"a:3:{s:3:\\"top\\";s:2:\\"75\\";s:4:\\"str1\\";s:42:\\"We play, we laugh, we explore the world\\u2026\\";s:4:\\"str2\\";s:45:\\"\\u6211\\u4eec\\u73a9\\u800d\\uff0c\\u6211\\u4eec\\u6b22\\u7b11\\uff0c\\u6211\\u4eec\\u63a2\\u7d22\\u2026\\";}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '6.jpg","param":"a:3:{s:3:\\"top\\";s:2:\\"15\\";s:4:\\"str1\\";s:22:\\"One day, in the future\\";s:4:\\"str2\\";s:23:\\" \\u672a\\u6765\\u7684\\u67d0\\u4e00\\u5929\\uff0c \\";}","create_time":"0"},{"listorder":"0","m_type":"12","thumb":"' . $page_tmpfolder . '7.jpg","param":"a:3:{s:3:\\"top\\";s:2:\\"16\\";s:4:\\"str1\\";s:27:\\"We will review the moments.\\";s:4:\\"str2\\";s:34:\\"\\u6211\\u4eec\\u5c06\\u91cd\\u6e29 \\u201c\\u6b64\\u65f6\\u5f7c\\u523b\\u201d\\";}","create_time":"0"},{"listorder":"0","m_type":"13","thumb":"' . $page_tmpfolder . 'default_bg.jpg","param":"a:5:{s:4:\\"logo\\";s:71:\\"' . $page_tmpfolder . 'logo.png\\";s:4:\\"str1\\";s:16:\\"NOT JUST A PHOTO\\";s:4:\\"str2\\";s:24:\\"\\u60a8\\u7684\\u573a\\u666f\\u5236\\u4f5c\\u4e13\\u5bb6\\";s:4:\\"str3\\";s:15:\\"40039885@qq.com\\";s:6:\\"qrcode\\";s:53:\\"' . $page_tmpfolder . 'qrcode.jpg\\";}","create_time":"0"}]'; $pageArr = json_decode($pagestr, true); foreach ($pageArr as $v) { $page_data = array('list_id' => $list_id, 'listorder' => $v['listorder'], 'm_type' => $v['m_type'], 'thumb' => $v['thumb'], 'param' => $v['param'], 'create_time' => time()); mysqld_insert('addon10_scene_page', $page_data); } message("范例创建成功", create_url('site', array('name' => 'addon10', 'do' => 'scene', 'op' => 'display')), "success");
$idsarr = explode("_", $ids); $newids = array(); foreach ($idsarr as $key => $ida) { foreach ($spec_items as $it) { if ($it['get_id'] == $ida) { $newids[] = $it['id']; break; } } } $newids = implode("_", $newids); $a = array("title" => $_GP['option_title_' . $ids][0], "productprice" => $_GP['option_productprice_' . $ids][0], "costprice" => $_GP['option_costprice_' . $ids][0], "marketprice" => $_GP['option_marketprice_' . $ids][0], "stock" => $_GP['option_stock_' . $ids][0], "weight" => $_GP['option_weight_' . $ids][0], "goodsid" => $id, "specs" => $newids); $totalstocks += $a['stock']; if (empty($get_option_id)) { mysqld_insert("shop_goods_option", $a); $option_id = mysqld_insertid(); } else { mysqld_update("shop_goods_option", $a, array('id' => $get_option_id)); $option_id = $get_option_id; } $optionids[] = $option_id; } if (count($optionids) > 0) { mysqld_query("delete from " . table('shop_goods_option') . " where goodsid={$id} and id not in ( " . implode(',', $optionids) . ")"); } else { mysqld_query("delete from " . table('shop_goods_option') . " where goodsid={$id}"); } //总库存 if ($totalstocks > 0) { mysqld_update("shop_goods", array("total" => $totalstocks), array("id" => $id)); }
if (checksubmit('submit')) { if (empty($article['id'])) { $data = array('createtime' => time(), 'pcate' => intval($_GP['pcate']), 'ccate' => intval($_GP['ccate']), 'iscommend' => intval($_GP['iscommend']), 'ishot' => intval($_GP['ishot']), 'mobileTheme' => intval($_GP['mobileTheme']), 'title' => $_GP['title'], 'readcount' => intval($_GP['readcount']), 'description' => $_GP['description'], 'content' => htmlspecialchars_decode($_GP['content']), 'displayorder' => intval($_GP['displayorder'])); if (!empty($_GP['thumb_del'])) { $data['thumb'] = ''; } if (!empty($_FILES['thumb']['tmp_name'])) { file_delete($_GP['thumb_old']); $upload = file_upload($_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['thumb'] = $upload['path']; } mysqld_insert('addon8_article', $data); message("添加成功", create_url('site', array('name' => 'addon8', 'do' => 'article', 'op' => 'post', 'id' => mysqld_insertid())), "success"); } else { $data = array('createtime' => time(), 'pcate' => intval($_GP['pcate']), 'ccate' => intval($_GP['ccate']), 'iscommend' => intval($_GP['iscommend']), 'ishot' => intval($_GP['ishot']), 'mobileTheme' => intval($_GP['mobileTheme']), 'title' => $_GP['title'], 'readcount' => intval($_GP['readcount']), 'description' => $_GP['description'], 'content' => htmlspecialchars_decode($_GP['content']), 'displayorder' => intval($_GP['displayorder'])); if (!empty($_GP['thumb_del'])) { $data['thumb'] = ''; } if (!empty($_FILES['thumb']['tmp_name'])) { file_delete($_GP['thumb_old']); $upload = file_upload($_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['thumb'] = $upload['path']; } mysqld_update('addon8_article', $data, array('id' => $_GP['id'])); message("修改成功", "refresh", "success");
public function do_getaward() { global $_GP; $reply = mysqld_select("SELECT * FROM " . table("bigwheel_reply") . " ORDER BY `id` DESC"); $member = get_member_account(true, intval($reply['needreg']) == 1); $openid = $member['openid']; $from_user = $openid; if ($reply == false) { $this->message(); } if ($reply['isshow'] != 1) { //活动已经暂停,请稍后... $this->message(array("success" => 2, "msg" => '活动暂停,请稍后...'), ""); } if ($reply['starttime'] > time()) { $this->message(array("success" => 2, "msg" => '活动还没有开始呢,请等待...'), ""); } $endtime = $reply['endtime'] + 68399; if ($endtime < time()) { $this->message(array("success" => 2, "msg" => '活动已经结束了,下次再来吧!'), ""); } $fansID = 0; //第一步,判断有没有已经领取奖品了,如果领取了,则不能再领取了 $fans = mysqld_select("SELECT * FROM " . table("bigwheel_fans") . " WHERE from_user='******'"); if ($fans == false) { //不存在false的情况,如果是false,则表明是非法 //$this->message(); $fans = array('fansID' => $fansID, 'from_user' => $openid, 'todaynum' => 0, 'totalnum' => 0, 'awardnum' => 0, 'createtime' => time()); mysqld_insert("bigwheel_fans", $fans); $fans['id'] = mysqld_insertid(); } //更新当日次数 $nowtime = mktime(0, 0, 0); if ($fans['last_time'] < $nowtime) { $fans['todaynum'] = 0; } //判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试 if ($fans['totalnum'] >= $reply['number_times'] && $reply['number_times'] > 0) { // $this->message('', '超过抽奖总限制次数'); $this->message(array("success" => 2, "msg" => '您超过抽奖总次数了,不能抽奖了!'), ""); } //判断当日是否超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试 if ($fans['todaynum'] >= $reply['most_num_times'] && $reply['most_num_times'] > 0) { //$this->message('', '超过当日限制次数'); $this->message(array("success" => 2, "msg" => '您超过当日抽奖次数了,不能抽奖了!'), ""); } $last_time = strtotime(date("Y-m-d", mktime(0, 0, 0))); //当天抽奖次数 mysqld_update('bigwheel_fans', array('todaynum' => $fans['todaynum'] + 1, 'last_time' => $last_time), array('id' => $fans['id'])); //总抽奖次数 mysqld_update('bigwheel_fans', array('totalnum' => $fans['totalnum'] + 1), array('id' => $fans['id'])); $gifts = array("one" => array("name" => $reply['c_name_one'], "type" => $reply['c_type_one'], "probalilty" => $reply['c_rate_one'], "total" => $reply['c_num_one'], "draw" => $reply['c_draw_one']), "two" => array("name" => $reply['c_name_two'], "type" => $reply['c_type_two'], "probalilty" => $reply['c_rate_two'], "total" => $reply['c_num_two'], "draw" => $reply['c_draw_two']), "three" => array("name" => $reply['c_name_three'], "type" => $reply['c_type_three'], "probalilty" => $reply['c_rate_three'], "total" => $reply['c_num_three'], "draw" => $reply['c_draw_three']), "four" => array("name" => $reply['c_name_four'], "type" => $reply['c_type_four'], "probalilty" => $reply['c_rate_four'], "total" => $reply['c_num_four'], "draw" => $reply['c_draw_four']), "five" => array("name" => $reply['c_name_five'], "type" => $reply['c_type_five'], "probalilty" => $reply['c_rate_five'], "total" => $reply['c_num_five'], "draw" => $reply['c_draw_five']), "six" => array("name" => $reply['c_name_six'], "type" => $reply['c_type_six'], "probalilty" => $reply['c_rate_six'], "total" => $reply['c_num_six'], "draw" => $reply['c_draw_six'])); //计算每个礼物的概率 $probability = 0; $rate = 1; $award = array(); $awards = array(); //奖品名字 (同时可中多个奖品,然后随机派奖) foreach ($gifts as $name => $gift) { if ($gift['total'] - $gift['draw'] <= 0) { continue; } if (empty($gift['probalilty'])) { continue; } $probability = $gift['probalilty']; if ($probability < 1) { $temp = explode('.', $probability); $temp = pow(10, strlen($temp[1])); $rate = $temp < $rate ? $rate : $temp; $probability = $probability * $rate; } $award[] = array('prizetype' => $name, 'name' => $gift['name'], 'probalilty' => $probability, 'total' => $gift['total']); } $all = 100 * $rate; mt_srand((double) microtime() * 1000000); $rand = mt_rand(1, $all); foreach ($award as $gift) { if ($rand > 0 && $rand <= $gift['probalilty'] && $gift['total'] > 0) { $awards[] = $gift['prizetype']; } } $prizetype = ""; $awardtype = ""; $awardname = ""; if (count($awards) > 0) { mt_srand((double) microtime() * 1000000); $randid = mt_rand(0, count($awards) - 1); $prizetype = $awards[$randid]; $awardtype = $gifts[$prizetype]['type']; $awardname = $gifts[$prizetype]['name']; } if (!empty($prizetype) && (!empty($reply['award_times']) && $fans['awardnum'] < $reply['award_times']) || empty($reply['award_times'])) { //中奖 $sn = random(16); mysqld_update('bigwheel_reply', array('c_draw_' . $prizetype => $reply['c_draw_' . $prizetype] + 1), array('id' => $reply['id'])); //保存sn到award中 $insert = array('fansID' => $fansID, 'from_user' => $from_user, 'name' => $awardtype, 'description' => $awardname, 'prizetype' => $prizetype, 'award_sn' => $sn, 'createtime' => time(), 'status' => 1); $temp = mysqld_insert('bigwheel_award', $insert); //保存中奖人信息到fans中 mysqld_update('bigwheel_fans', array('awardnum' => $fans['awardnum'] + 1), array('id' => $fans['id'])); $k = 0; if ($prizetype == 'one') { $k = 1; } else { if ($prizetype == 'two') { $k = 2; } } if ($prizetype == 'three') { $k = 3; } if ($prizetype == 'four') { $k = 4; } if ($prizetype == 'five') { $k = 5; } if ($prizetype == 'six') { $k = 6; } $data = array('name' => $reply['c_type_' . $prizetype], 'award' => $reply['c_name_' . $prizetype], 'sn' => $sn, 'success' => 1, 'prizetype' => $k); $this->message($data); } $this->message(); }
message($upload['message'], '', 'error'); } $data['cover2'] = $upload['path']; } if (!empty($_GP['bg_music_url_del'])) { $data['bg_music_url'] = ''; } if (!empty($_FILES['bg_music_url']['tmp_name'])) { $upload = file_upload($_FILES['bg_music_url'], 'music'); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['bg_music_url'] = $upload['path']; } mysqld_insert('addon10_scene_list', $data); message("添加成功", create_url('site', array('name' => 'addon10', 'do' => 'scene', 'op' => 'setting', 'id' => mysqld_insertid())), "success"); } else { $fields = array('title', 'reply_title', 'reply_description', 'share_title', 'share_content', 'share_cb_url', 'share_cb_tel', 'first_type', 'first_btn_select', 'first_btn_url', 'first_btn_tel', 'bg_music_switch', 'bg_music_icon', 'cover_title', 'cover_subtitle', 'tongji'); $data = array(); foreach ($_GP as $k => $v) { if (in_array($k, $fields)) { $data[$k] = $_GP[$k]; } } if (!empty($theme)) { $data['theme'] = $theme; } if (!empty($_GP['reply_thumb_del'])) { $data['reply_thumb'] = ''; } if (!empty($_FILES['reply_thumb']['tmp_name'])) {
} } } $ordersns = date('md') . random(6, 1); $randomorder = mysqld_select("SELECT * FROM " . table('shop_order') . " WHERE ordersn=:ordersn limit 1", array(':ordersn' => $ordersns)); if (!empty($randomorder['ordersn'])) { $ordersns = date('md') . random(6, 1); } $payment = mysqld_select("select * from " . table("payment") . " where enabled=1 and code=:payment", array(':payment' => $_GP['payment'])); if (empty($payment['id'])) { message("没有获取到付款方式"); } $paytype = $this->getPaytypebycode($payment['code']); $data = array('openid' => $openid, 'ordersn' => $ordersns, 'price' => $goodsprice + $dispatchprice, 'dispatchprice' => $dispatchprice, 'goodsprice' => $goodsprice, 'credit' => $goodscredit, 'status' => 0, 'paytype' => $paytype, 'sendtype' => intval($dispatchitem['sendtype']), 'dispatchexpress' => $dispatchitem['express'], 'dispatch' => $dispatchid, 'paytypecode' => $payment['code'], 'paytypename' => $payment['name'], 'remark' => $_GP['remark'], 'address_mobile' => $address['mobile'], 'address_realname' => $address['realname'], 'address_province' => $address['province'], 'address_city' => $address['city'], 'address_area' => $address['area'], 'address_address' => $address['address'], 'createtime' => time()); mysqld_insert('shop_order', $data); $orderid = mysqld_insertid(); //插入订单商品 foreach ($allgoods as $row) { if (empty($row)) { continue; } $d = array('goodsid' => $row['id'], 'orderid' => $orderid, 'total' => $row['total'], 'price' => $row['marketprice'], 'createtime' => time(), 'optionid' => $row['optionid']); $o = mysqld_select("select title from " . table('shop_goods_option') . " where id=:id limit 1", array(":id" => $row['optionid'])); if (!empty($o)) { $d['optionname'] = $o['title']; } //获取商品id $ccate = $row['ccate']; mysqld_insert('shop_order_goods', $d); } //清空购物车