* 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ define('IN_QISHI', true); require_once 'shop_common.php'; $act = $_GET['act'] ? trim($_GET['act']) : "check"; if ($act == 'check') { $id = intval($_GET['id']); //商品id $num = $_GET['num'] ? intval($_GET['num']) : 1; //兑换数目 $uid = intval($_SESSION['uid']); // 获取企业积分 $uesr_points = get_user_points($uid); // 获取商品信息 $shop_one = get_shop_one($id); if (empty($shop_one)) { exit('<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableall"> <tr> <td width="20" align="right"></td> <td style="padding-bottom:10px"> 商品id丢失! </td> </tr> </table>'); } if ($_SESSION['username'] == '') { $smarty->assign('verify_userlogin', $captcha['verify_userlogin']); $smarty->display('plus/ajax_login.htm'); exit; }
function set_order($id, $state) { global $db; $state = intval($state); if (!is_array($id)) { $id = array($id); } $return = 0; foreach ($id as $value) { $order_show = get_order_one($value); if ($order_show['state'] != 0) { continue; } $shop_one = get_shop_one($order_show['shop_id']); // 审核不通过 退回企业积分 if ($state == 2) { $exchange_arr['state'] = 2; $db->updatetable(table("shop_exchange"), $exchange_arr, array("order_id" => $order_show['id'], "shop_id" => $order_show['shop_id'], "company_uid" => $order_show['uid'])); report_deal($order_show['uid'], 1, $order_show['order_points']); //写入日志 $user_points = get_user_points($order_show['uid']); write_memberslog($order_show['uid'], 1, 9001, $order_show['company_name'], $order_show['company_name'] . "积分兑换商品:<strong>{$setarr['shop_title']}</strong>未通过审核,并且返回积分:({$order_show['order_points']})。", 1, 2008, "返回积分", "+{$order_show['order_points']}", "{$user_points}"); } else { $shop_stock = $shop_one['shop_stock'] - $order_show['shop_num']; $click = $shop_one['click'] + $order_show['shop_num']; $db->query("update " . table("shop_goods") . " set shop_stock={$shop_stock},click={$click} where id={$order_show['shop_id']}"); $exchange_arr['state'] = 1; $db->updatetable(table("shop_exchange"), $exchange_arr, array("order_id" => $order_show['id'], "shop_id" => $order_show['shop_id'], "company_uid" => $order_show['uid'])); } if ($db->query("update " . table("shop_order") . " set state={$state} where id={$value}")) { $return++; } } return $return; }
$offset = ($currenpage - 1) * $perpage; $list = get_shop($offset, $perpage, $wheresql . $oederbysql); $smarty->assign('list', $list); $smarty->assign('total', $total); $smarty->assign('page', $page->show(3)); $smarty->assign('pageheader', "积分商城"); $smarty->display('shop/admin_shop_list.htm'); } elseif ($act == 'shop_add') { get_token(); $smarty->assign('pageheader', "积分商城 "); $smarty->display('shop/admin_shop_add.htm'); } elseif ($act == 'shop_edit') { get_token(); $id = intval($_GET['id']); $smarty->assign('pageheader', "积分商城 "); $smarty->assign('show', get_shop_one($id)); $smarty->display('shop/admin_shop_add.htm'); } elseif ($act == 'shop_save') { check_token(); $id = intval($_POST['id']); $setarr["shop_title"] = $_POST["shop_title"] ? trim($_POST["shop_title"]) : adminmsg("请输入商品名称"); $setarr["shop_brand"] = $_POST["shop_brand"] ? trim($_POST["shop_brand"]) : adminmsg("请输入品牌"); $setarr["scategory"] = $_POST["scategory"] ? trim($_POST["scategory"]) : adminmsg("请选择所属分类"); $scategory_arr = explode(",", $setarr["scategory"]); $setarr["category"] = $scategory_arr[0]; $setarr["scategory"] = $scategory_arr[1]; $setarr["category_cn"] = $scategory_arr[2]; $setarr["shop_stock"] = $_POST["shop_stock"] ? intval($_POST["shop_stock"]) : adminmsg("请输入商品库存"); $setarr["shop_customer"] = intval($_POST["shop_customer"]); $setarr["shop_points"] = $_POST["shop_points"] ? intval($_POST["shop_points"]) : adminmsg("请输入商品兑换所需积分"); $setarr["content"] = $_POST["content"] ? trim($_POST["content"]) : adminmsg("请输入商品描述");
$shop_show = get_shop_one($id); $smarty->assign("show", $shop_show); $need_points = $num * $shop_show['shop_points']; //所需积分 $smarty->assign("num", $num); $smarty->assign("need_points", $need_points); if ($_SESSION['utype'] == '1') { $smarty->assign("com_profile", get_company($_SESSION['uid'])); } elseif ($_SESSION['utype'] == '2') { $smarty->assign("per_profile", get_personal($_SESSION['uid'])); } $smarty->display($mypage['tpl'] . 'shop_order_add.htm'); } elseif ($act == 'order_save') { $setarr['shop_id'] = $_POST['shop_id'] ? intval($_POST['shop_id']) : showmsg("ID丢失", 1); $setarr['shop_num'] = $_POST['num'] ? intval($_POST['num']) : showmsg("兑换数量丢失", 1); $shop_one = get_shop_one($setarr['shop_id']); $setarr['shop_title'] = $shop_one['shop_title']; $setarr['shop_points'] = $shop_one['shop_points']; $setarr['order_points'] = $shop_one['shop_points'] * $setarr['shop_num']; $setarr['contact'] = $_POST['contact'] ? trim($_POST['contact']) : showmsg("请输入联系人!", 1); $setarr['mobile'] = $_POST['mobile'] ? trim($_POST['mobile']) : showmsg("请输入联系电话!", 1); $setarr['address'] = $_POST['address'] ? trim($_POST['address']) : showmsg("请输入地址!", 1); $setarr['addtime'] = time(); $setarr['uid'] = intval($_SESSION['uid']); if ($_SESSION['utype'] == '1') { $com_info = get_company($_SESSION['uid']); $setarr['company_name'] = $com_info['companyname']; } elseif ($_SESSION['utype'] == '2') { $per_info = get_personal($_SESSION['uid']); $setarr['company_name'] = $per_info['realname']; }