public function save()
 {
     if (trim($_REQUEST['consignee']) == '') {
         showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE']);
     }
     if (trim($_REQUEST['address']) == '') {
         showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS']);
     }
     if (trim($_REQUEST['zip']) == '') {
         showErr($GLOBALS['lang']['FILL_CORRECT_ZIP']);
     }
     if (trim($_REQUEST['mobile']) == '') {
         showErr($GLOBALS['lang']['FILL_MOBILE_PHONE']);
     }
     if (!check_mobile($_REQUEST['mobile'])) {
         showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE']);
     }
     $consignee_data['user_id'] = $GLOBALS['user_info']['id'];
     $consignee_data['region_lv1'] = intval($_REQUEST['region_lv1']);
     $consignee_data['region_lv2'] = intval($_REQUEST['region_lv2']);
     $consignee_data['region_lv3'] = intval($_REQUEST['region_lv3']);
     $consignee_data['region_lv4'] = intval($_REQUEST['region_lv4']);
     $consignee_data['address'] = addslashes(trim(htmlspecialchars($_REQUEST['address'])));
     $consignee_data['mobile'] = addslashes(trim(htmlspecialchars($_REQUEST['mobile'])));
     $consignee_data['consignee'] = addslashes(trim(htmlspecialchars($_REQUEST['consignee'])));
     $consignee_data['zip'] = addslashes(trim(htmlspecialchars($_REQUEST['zip'])));
     $consignee_id = intval($_REQUEST['id']);
     if ($consignee_id == 0) {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data);
     } else {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data, "UPDATE", "id=" . $consignee_id);
     }
     rm_auto_cache("consignee_info", array("consignee_id" => intval($consignee_id)));
     showSuccess($GLOBALS['lang']['UPDATE_SUCCESS']);
 }
 public function set_effect()
 {
     $id = intval($_REQUEST['id']);
     $ajax = intval($_REQUEST['ajax']);
     $info = M(MODULE_NAME)->where("id=" . $id)->getField("name");
     $c_is_effect = M(MODULE_NAME)->where("id=" . $id)->getField("status");
     //当前状态
     $n_is_effect = $c_is_effect == 0 ? 1 : 0;
     //需设置的状态
     M(MODULE_NAME)->where("id=" . $id)->setField("status", $n_is_effect);
     save_log($info . l("SET_EFFECT_" . $n_is_effect), 1);
     rm_auto_cache("cache_nav_list");
     $this->ajaxReturn($n_is_effect, l("SET_EFFECT_" . $n_is_effect), 1);
 }
예제 #3
0
 public function done()
 {
     save_debug_log('cart done', 'request:' . json_encode($_REQUEST));
     $region4_id = intval($_REQUEST['region_lv4']);
     $region3_id = intval($_REQUEST['region_lv3']);
     $region2_id = intval($_REQUEST['region_lv2']);
     $region1_id = intval($_REQUEST['region_lv1']);
     if ($region4_id == 0) {
         if ($region3_id == 0) {
             if ($region2_id == 0) {
                 $region_id = $region1_id;
             } else {
                 $region_id = $region2_id;
             }
         } else {
             $region_id = $region3_id;
         }
     } else {
         $region_id = $region4_id;
     }
     $delivery_id = intval($_REQUEST['delivery']);
     $payment = intval($_REQUEST['payment']);
     $account_money = floatval($_REQUEST['account_money']);
     $all_account_money = intval($_REQUEST['all_account_money']);
     $ecvsn = $_REQUEST['ecvsn'] ? addslashes(trim($_REQUEST['ecvsn'])) : '';
     $ecvpassword = $_REQUEST['ecvpassword'] ? addslashes(trim($_REQUEST['ecvpassword'])) : '';
     $user_id = intval($GLOBALS['user_info']['id']);
     $session_id = es_session::id();
     $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cart where session_id='" . $session_id . "' and user_id=" . $user_id);
     if (!$goods_list) {
         showErr($GLOBALS['lang']['CART_EMPTY_TIP'], $ajax);
     }
     //验证购物车
     if (!$GLOBALS['user_info']) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax, url("shop", "user#login"));
     }
     $deal_ids = $GLOBALS['db']->getAll("select distinct(deal_id) as deal_id,number from " . DB_PREFIX . "deal_cart where session_id = '" . $session_id . "' and user_id = " . $user_id);
     foreach ($deal_ids as $row) {
         $checker = check_deal_time($row['deal_id']);
         if ($checker['status'] == 0) {
             showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax, url("shop", "cart#index"));
         }
         $check = check_user_bought_day($row['deal_id'], $row['number']);
         if ($check['status'] == 0) {
             $res = array('ret' => '-1', 'info' => $check['info']);
             showErr($check['info'], $ajax, url("shop", "cart#index"));
         }
         $checker = check_deal_number($row['deal_id']);
         if ($checker['status'] == 0) {
             showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax, url("shop", "cart#index"));
         }
         //验证支付方式的支持
         if ($GLOBALS['db']->getOne("select define_payment from " . DB_PREFIX . "deal where id = " . $row['deal_id']) == 1) {
             if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_payment where deal_id = " . $row['deal_id'] . " and payment_id = " . $payment)) {
                 showErr($GLOBALS['lang']['INVALID_PAYMENT'], $ajax, url("shop", "cart#index"));
             }
         }
     }
     //开始验证关于属性的库存
     $deal_attr_ids = $GLOBALS['db']->getAll("select deal_id,attr,name,attr_str from " . DB_PREFIX . "deal_cart where session_id = '" . es_session::id() . "' and user_id = " . $user_id);
     foreach ($deal_attr_ids as $row) {
         $attr_setting_str = '';
         if ($row['attr_str'] != '') {
             $attr_setting_str = $row['attr_str'];
         }
         if ($attr_setting_str != '') {
             $checker = check_deal_number_attr($row['deal_id'], $attr_setting_str);
             if ($checker['status'] == 0) {
                 if ($ajax == 1) {
                     showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']] . "|" . $row['deal_id'] . "|" . $checker['attr'], $ajax, url("shop", "cart#index"));
                 } else {
                     showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax, url("shop", "cart#index"));
                 }
             }
         }
     }
     //结束验证购物车
     //开始验证订单接交信息
     require_once APP_ROOT_PATH . "system/libs/cart.php";
     $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list);
     if ($data['is_delivery'] == 1) {
         // 如果服务站为空或者服务站为“暂不支持配送”
         $region4 = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "delivery_region where id=" . $region4_id);
         if ($region4 == false) {
             showErr($GLOBALS['lang']['DELIVERY_REGION_LV4_IS_NONE']);
         }
         if ($region4 == $GLOBALS['lang']['DELETERY_REGION_LV4_NOT_SUPPORT_STR']) {
             showErr($GLOBALS['lang']['DELETERY_REGION_LV4_NOT_SUPPORT']);
         }
         //配送验证
         if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS']);
         }
         if (trim($_REQUEST['consignee']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE']);
         }
         if (trim($_REQUEST['address']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS']);
         }
         //					if(trim($_REQUEST['zip'])=='')
         //					{
         //						showErr($GLOBALS['lang']['FILL_CORRECT_ZIP']);
         //					}
         if (trim($_REQUEST['mobile']) == '') {
             showErr($GLOBALS['lang']['FILL_MOBILE_PHONE']);
         }
         if (!check_mobile(trim($_REQUEST['mobile']))) {
             showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE']);
         }
         //					if(!$data['delivery_info'])
         //					{
         //						showErr($GLOBALS['lang']['PLEASE_SELECT_DELIVERY']);
         //					}
     }
     //TODO
     if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
         showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT']);
     }
     //结束验证订单接交信息
     //开始生成订单
     $now = get_gmtime();
     $order['type'] = 0;
     //普通订单
     $order['user_id'] = $user_id;
     $order['create_time'] = $now;
     $order['total_price'] = $data['pay_total_price'];
     //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
     $order['pay_amount'] = 0;
     $order['pay_status'] = 0;
     //新单都为零, 等下面的流程同步订单状态
     $order['delivery_status'] = $data['is_delivery'] == 0 ? 5 : 0;
     $order['order_status'] = 0;
     //新单都为零, 等下面的流程同步订单状态
     $order['return_total_score'] = $data['return_total_score'];
     //结单后送的积分
     $order['return_total_money'] = $data['return_total_money'];
     //结单后送的现金
     $order['memo'] = htmlspecialchars(addslashes(trim($_REQUEST['memo'])));
     $order['region_lv1'] = intval($_REQUEST['region_lv1']);
     $order['region_lv2'] = intval($_REQUEST['region_lv2']);
     $order['region_lv3'] = intval($_REQUEST['region_lv3']);
     $order['region_lv4'] = intval($_REQUEST['region_lv4']);
     $order['address'] = htmlspecialchars(addslashes(trim($_REQUEST['address'])));
     $order['mobile'] = htmlspecialchars(addslashes(trim($_REQUEST['mobile'])));
     $order['consignee'] = htmlspecialchars(addslashes(trim($_REQUEST['consignee'])));
     $order['zip'] = htmlspecialchars(addslashes(trim($_REQUEST['zip'])));
     $order['deal_total_price'] = $data['total_price'];
     //团购商品总价
     $order['discount_price'] = $data['user_discount'];
     $order['delivery_fee'] = $data['delivery_fee'];
     $order['ecv_money'] = 0;
     $order['account_money'] = 0;
     $order['ecv_sn'] = '';
     $order['delivery_id'] = $data['delivery_info']['id'];
     $order['payment_id'] = $data['payment_info']['id'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['bank_id'] = htmlspecialchars(addslashes(trim($_REQUEST['bank_id'])));
     foreach ($data['promote_description'] as $promote_item) {
         $order['promote_description'] .= $promote_item . "<br />";
     }
     //更新来路
     $order['referer'] = $GLOBALS['referer'];
     $user_info = es_session::get("user_info");
     $order['user_name'] = $user_info['user_name'];
     $coupon_mobile = htmlspecialchars(addslashes(trim($_REQUEST['coupon_mobile'])));
     if ($coupon_mobile != '') {
         $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $coupon_mobile . "' where id = " . intval($user_info['id']));
     }
     do {
         $order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
         $order_id = intval($GLOBALS['db']->insert_id());
     } while ($order_id == 0);
     //生成订单商品
     foreach ($goods_list as $k => $v) {
         $deal_info = load_auto_cache("cache_deal_cart", array("id" => $v['deal_id']));
         $goods_item = array();
         $goods_item['deal_id'] = $v['deal_id'];
         $goods_item['number'] = $v['number'];
         $goods_item['unit_price'] = $v['unit_price'];
         $goods_item['total_price'] = $v['total_price'];
         $goods_item['name'] = addslashes($v['name']);
         $goods_item['sub_name'] = addslashes($v['sub_name']);
         $goods_item['attr'] = $v['attr'];
         $goods_item['verify_code'] = $v['verify_code'];
         $goods_item['order_id'] = $order_id;
         $goods_item['return_score'] = $v['return_score'];
         $goods_item['return_total_score'] = $v['return_total_score'];
         $goods_item['return_money'] = $v['return_money'];
         $goods_item['return_total_money'] = $v['return_total_money'];
         $goods_item['buy_type'] = $v['buy_type'];
         $goods_item['attr_str'] = $v['attr_str'];
         $goods_item['balance_unit_price'] = $deal_info['balance_price'];
         $goods_item['balance_total_price'] = $deal_info['balance_price'] * $v['number'];
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $goods_item, 'INSERT', '', 'SILENT');
     }
     //开始更新订单表的deal_ids
     $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
     $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set deal_ids = '" . $deal_ids . "' where id = " . $order_id);
     $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_cart where session_id = '" . $session_id . "' and user_id = " . $user_id);
     if ($data['is_delivery'] == 1) {
         //保存收款人
         $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $user_id . " order by id desc");
         $user_consignee['region_lv1'] = intval($_REQUEST['region_lv1']);
         $user_consignee['region_lv2'] = intval($_REQUEST['region_lv2']);
         $user_consignee['region_lv3'] = intval($_REQUEST['region_lv3']);
         $user_consignee['region_lv4'] = intval($_REQUEST['region_lv4']);
         $user_consignee['address'] = htmlspecialchars(addslashes(trim($_REQUEST['address'])));
         $user_consignee['mobile'] = htmlspecialchars(addslashes(trim($_REQUEST['mobile'])));
         $user_consignee['consignee'] = htmlspecialchars(addslashes(trim($_REQUEST['consignee'])));
         $user_consignee['zip'] = htmlspecialchars(addslashes(trim($_REQUEST['zip'])));
         $user_consignee['user_id'] = $user_id;
         if (intval($user_consignee['id']) == 0) {
             //新增
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'INSERT', '', 'SILENT');
         } else {
             //更新
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'UPDATE', 'id=' . $user_consignee['id'], 'SILENT');
             rm_auto_cache("consignee_info", array("consignee_id" => intval($user_consignee['id'])));
         }
     }
     //生成order_id 后
     //1. 代金券支付
     $ecv_data = $data['ecv_data'];
     if ($ecv_data) {
         $ecv_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'");
         $payment_notice_id = make_payment_notice($ecv_data['money'], $order_id, $ecv_payment_id);
         require_once APP_ROOT_PATH . "system/payment/Voucher_payment.php";
         $voucher_payment = new Voucher_payment();
         $voucher_payment->direct_pay($ecv_data['sn'], $ecv_data['password'], $payment_notice_id);
     }
     //2. 余额支付
     $account_money = $data['account_money'];
     if (floatval($account_money) > 0) {
         $account_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Account'");
         $payment_notice_id = make_payment_notice($account_money, $order_id, $account_payment_id);
         require_once APP_ROOT_PATH . "system/payment/Account_payment.php";
         $account_payment = new Account_payment();
         $account_payment->get_payment_code($payment_notice_id);
     }
     //3. 相应的支付接口
     $payment_info = $data['payment_info'];
     if ($payment_info && $data['pay_price'] > 0) {
         $payment_notice_id = make_payment_notice($data['pay_price'], $order_id, $payment_info['id']);
         //创建支付接口的付款单
     }
     $rs = order_paid($order_id);
     save_debug_log('cart done', 'order_paid rs:' . $rs . 'order_id:' . $order_id);
     if ($rs) {
         app_redirect(url("shop", "payment#done", array("id" => $order_id)));
         //支付成功
     } else {
         app_redirect(url("shop", "payment#pay", array("id" => $payment_notice_id)));
     }
 }
예제 #4
0
 public function youhui_update()
 {
     B('FilterString');
     $data = M(MODULE_NAME)->create();
     $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name");
     //开始验证有效性
     $this->assign("jumpUrl", u(MODULE_NAME . "/youhui_edit", array("id" => $data['id'])));
     if (!check_empty($data['name'])) {
         $this->error(L("DEAL_YOUHUI_NAME_EMPTY_TIP"));
     }
     if (!check_empty($data['sub_name'])) {
         $this->error(L("DEAL_YOUHUI_SUB_NAME_EMPTY_TIP"));
     }
     if ($data['cate_id'] == 0) {
         $this->error(L("DEAL_YOUHUI_CATE_EMPTY_TIP"));
     }
     if ($data['city_id'] == 0) {
         $this->error(L("DEAL_YOUHUI_CITY_EMPTY_TIP"));
     }
     if ($data['max_bought'] < 0) {
         $this->error(L("DEAL_YOUHUI_MAX_BOUGHT_ERROR_TIP"));
     }
     if ($data['user_min_bought'] < 0) {
         $this->error(L("DEAL_USER_MIN_BOUGHT_ERROR_TIP"));
     }
     if ($data['user_max_bought'] < 0) {
         $this->error(L("DEAL_USER_MAX_BOUGHT_ERROR_TIP"));
     }
     if ($data['user_max_bought'] < $data['user_min_bought'] && $data['user_max_bought'] > 0) {
         $this->error(L("DEAL_USER_MAX_MIN_BOUGHT_ERROR_TIP"));
     }
     $data['is_shop'] = 2;
     $data['is_coupon'] = 1;
     if (intval($data['is_coupon']) == 1 && intval($data['is_refund']) == 1) {
         $data['expire_refund'] = intval($_REQUEST['expire_refund']);
         $data['any_refund'] = intval($_REQUEST['any_refund']);
     } else {
         $data['expire_refund'] = 0;
         $data['any_refund'] = 0;
     }
     $data['notice'] = intval($_REQUEST['notice']);
     $data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']);
     $data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']);
     $data['coupon_begin_time'] = trim($data['coupon_begin_time']) == '' ? 0 : to_timespan($data['coupon_begin_time']);
     $data['coupon_end_time'] = trim($data['coupon_end_time']) == '' ? 0 : to_timespan($data['coupon_end_time']);
     //将第一张图片设为团购图片
     $imgs = $_REQUEST['img'];
     foreach ($imgs as $k => $v) {
         if ($v != '') {
             $data['img'] = $v;
             break;
         }
     }
     $data['update_time'] = get_gmtime();
     $data['publish_wait'] = 0;
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if (false !== $list) {
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set expire_refund = " . $data['expire_refund'] . ",any_refund = " . $data['any_refund'] . ",supplier_id=" . $data['supplier_id'] . ",end_time=" . $data['coupon_end_time'] . ",begin_time=" . $data['coupon_begin_time'] . " where deal_id = " . $data['id']);
         //开始处理图片
         M("DealGallery")->where("deal_id=" . $data['id'])->delete();
         $imgs = $_REQUEST['img'];
         foreach ($imgs as $k => $v) {
             if ($v != '') {
                 $img_data['deal_id'] = $data['id'];
                 $img_data['img'] = $v;
                 $img_data['sort'] = $k;
                 M("DealGallery")->add($img_data);
             }
         }
         //end 处理图片
         M("DealPayment")->where("deal_id=" . $data['id'])->delete();
         if (intval($_REQUEST['define_payment']) == 1) {
             $payment_ids = $_REQUEST['payment_id'];
             foreach ($payment_ids as $k => $v) {
                 $payment_conf = array();
                 $payment_conf['payment_id'] = $payment_ids[$k];
                 $payment_conf['deal_id'] = $data['id'];
                 M("DealPayment")->add($payment_conf);
             }
         }
         //成功提示
         M("DealCateTypeDealLink")->where("deal_id=" . $data['id'])->delete();
         foreach ($_REQUEST['deal_cate_type_id'] as $type_id) {
             $link_data = array();
             $link_data['deal_cate_type_id'] = $type_id;
             $link_data['deal_id'] = $data['id'];
             M("DealCateTypeDealLink")->add($link_data);
         }
         M("DealLocationLink")->where("deal_id=" . $data['id'])->delete();
         foreach ($_REQUEST['location_id'] as $location_id) {
             $link_data = array();
             $link_data['location_id'] = $location_id;
             $link_data['deal_id'] = $data['id'];
             M("DealLocationLink")->add($link_data);
         }
         syn_deal_status($data['id']);
         foreach ($_REQUEST['location_id'] as $location_id) {
             recount_supplier_data_count($location_id, "daijin");
         }
         syn_deal_match($data['id']);
         rm_auto_cache("cache_deal_cart", array("id" => $data['id']));
         rm_auto_cache("static_goods_info", array("id" => $data['id']));
         //成功提示
         save_log($log_info . L("UPDATE_SUCCESS"), 1);
         $this->success(L("UPDATE_SUCCESS"));
     } else {
         //错误提示
         $dbErr = M()->getDbError();
         save_log($log_info . L("UPDATE_FAILED") . $dbErr, 0);
         $this->error(L("UPDATE_FAILED") . $dbErr, 0);
     }
 }
예제 #5
0
 public function order_done()
 {
     require_once APP_ROOT_PATH . "system/model/deal.php";
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     global_run();
     $ajax = 1;
     $user_info = $GLOBALS['user_info'];
     $id = intval($_REQUEST['id']);
     //订单号
     $order = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $id . " and is_delete = 0 and user_id = " . $user_info['id']);
     if (!$order) {
         showErr($GLOBALS['lang']['INVALID_ORDER_DATA'], $ajax);
     }
     if ($order['refund_status'] == 1) {
         showErr($GLOBALS['lang']['REFUNDING_CANNOT_PAY'], $ajax);
     }
     if ($order['refund_status'] == 2) {
         showErr($GLOBALS['lang']['REFUNDED_CANNOT_PAY'], $ajax);
     }
     $region4_id = intval($_REQUEST['region_lv4']);
     $region3_id = intval($_REQUEST['region_lv3']);
     $region2_id = intval($_REQUEST['region_lv2']);
     $region1_id = intval($_REQUEST['region_lv1']);
     if ($region4_id == 0) {
         if ($region3_id == 0) {
             if ($region2_id == 0) {
                 $region_id = $region1_id;
             } else {
                 $region_id = $region2_id;
             }
         } else {
             $region_id = $region3_id;
         }
     } else {
         $region_id = $region4_id;
     }
     $delivery_id = intval($_REQUEST['delivery']);
     $payment = intval($_REQUEST['payment']);
     $account_money = floatval($_REQUEST['account_money']);
     $all_account_money = intval($_REQUEST['all_account_money']);
     $ecvsn = $_REQUEST['ecvsn'] ? strim($_REQUEST['ecvsn']) : '';
     $ecvpassword = $_REQUEST['ecvpassword'] ? strim($_REQUEST['ecvpassword']) : '';
     $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order['id']);
     //验证购物车
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax, url("index", "user#login"));
     }
     //验证支付方式的支持
     foreach ($goods_list as $k => $row) {
         if ($GLOBALS['db']->getOne("select define_payment from " . DB_PREFIX . "deal where id = " . $row['deal_id']) == 1) {
             if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_payment where deal_id = " . $row['deal_id'] . " and payment_id = " . $payment)) {
                 showErr($GLOBALS['lang']['INVALID_PAYMENT'], $ajax);
             }
         }
     }
     //结束验证购物车
     $deal_s = $GLOBALS['db']->getAll("select distinct(deal_id) as deal_id from " . DB_PREFIX . "deal_order_item where order_id = " . $order['id']);
     //如果属于未支付的
     if ($order['pay_status'] == 0) {
         foreach ($deal_s as $row) {
             $checker = check_deal_number($row['deal_id'], 0);
             if ($checker['status'] == 0) {
                 showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax);
             }
         }
         foreach ($goods_list as $k => $v) {
             $checker = check_deal_number_attr($v['deal_id'], $v['attr_str'], 0);
             if ($checker['status'] == 0) {
                 showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax);
             }
         }
         //验证商品是否过期
         foreach ($deal_s as $row) {
             $checker = check_deal_time($row['deal_id']);
             if ($checker['status'] == 0) {
                 showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax);
             }
         }
     }
     //开始验证订单接交信息
     require_once APP_ROOT_PATH . "system/model/cart.php";
     $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list, $order['account_money'], $order['ecv_money']);
     if ($data['is_delivery'] == 1) {
         //配送验证
         if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'], $ajax);
         }
         if (trim($_REQUEST['consignee']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'], $ajax);
         }
         if (trim($_REQUEST['address']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS'], $ajax);
         }
         if (trim($_REQUEST['zip']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ZIP'], $ajax);
         }
         if (trim($_REQUEST['mobile']) == '') {
             showErr($GLOBALS['lang']['FILL_MOBILE_PHONE'], $ajax);
         }
         if (!check_mobile(trim($_REQUEST['mobile']))) {
             showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'], $ajax);
         }
         if (!$data['delivery_info']) {
             showErr($GLOBALS['lang']['PLEASE_SELECT_DELIVERY'], $ajax);
         }
     }
     if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
         showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT'], $ajax);
     }
     //结束验证订单接交信息
     //开始修正订单
     $now = NOW_TIME;
     $order['total_price'] = $data['pay_total_price'];
     //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
     $order['memo'] = strim($_REQUEST['memo']);
     $order['region_lv1'] = intval($_REQUEST['region_lv1']);
     $order['region_lv2'] = intval($_REQUEST['region_lv2']);
     $order['region_lv3'] = intval($_REQUEST['region_lv3']);
     $order['region_lv4'] = intval($_REQUEST['region_lv4']);
     $order['address'] = strim($_REQUEST['address']);
     $order['mobile'] = strim($_REQUEST['mobile']);
     $order['consignee'] = strim($_REQUEST['consignee']);
     $order['zip'] = strim($_REQUEST['zip']);
     $order['delivery_fee'] = $data['delivery_fee'];
     $order['delivery_id'] = $data['delivery_info']['id'];
     $order['payment_id'] = $data['payment_info']['id'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['discount_price'] = $data['user_discount'];
     $order['bank_id'] = strim($_REQUEST['bank_id']);
     $order['promote_description'] = "";
     foreach ($data['promote_description'] as $promote_item) {
         $order['promote_description'] .= $promote_item . "<br />";
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'UPDATE', 'id=' . $order['id'], 'SILENT');
     if ($data['is_delivery'] == 1) {
         //保存收款人
         $consignee_id = intval($_REQUEST['consignee_id']);
         $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $order['user_id'] . " and id = " . $consignee_id);
         $user_consignee['region_lv1'] = intval($_REQUEST['region_lv1']);
         $user_consignee['region_lv2'] = intval($_REQUEST['region_lv2']);
         $user_consignee['region_lv3'] = intval($_REQUEST['region_lv3']);
         $user_consignee['region_lv4'] = intval($_REQUEST['region_lv4']);
         $user_consignee['address'] = strim($_REQUEST['address']);
         $user_consignee['mobile'] = strim($_REQUEST['mobile']);
         $user_consignee['consignee'] = strim($_REQUEST['consignee']);
         $user_consignee['zip'] = strim($_REQUEST['zip']);
         $user_consignee['user_id'] = $order['user_id'];
         if (intval($user_consignee['id']) == 0) {
             //新增,修改订单不新增配送
             // 				$user_consignee['is_default'] = 1;
             // 				$GLOBALS['db']->autoExecute(DB_PREFIX."user_consignee",$user_consignee,'INSERT','','SILENT');
         } else {
             //更新
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'UPDATE', 'id=' . $user_consignee['id'], 'SILENT');
             rm_auto_cache("consignee_info", array("consignee_id" => intval($user_consignee['id'])));
         }
     }
     //生成order_id 后
     //1. 余额支付
     $account_money = $data['account_money'];
     if (floatval($account_money) > 0) {
         $account_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Account'");
         $payment_notice_id = make_payment_notice($account_money, $order['id'], $account_payment_id);
         require_once APP_ROOT_PATH . "system/payment/Account_payment.php";
         $account_payment = new Account_payment();
         $account_payment->get_payment_code($payment_notice_id);
     }
     //3. 相应的支付接口
     $payment_info = $data['payment_info'];
     if ($payment_info && $data['pay_price'] > 0) {
         $payment_notice_id = make_payment_notice($data['pay_price'], $order['id'], $payment_info['id']);
         //创建支付接口的付款单
     }
     $rs = order_paid($order['id']);
     if ($rs) {
         $data = array();
         $data['info'] = "";
         $data['jump'] = url("index", "payment#done", array("id" => $order['id']));
         ajax_return($data);
         //支付成功
     } else {
         distribute_order($order['id']);
         $data = array();
         $data['info'] = "";
         $data['jump'] = url("index", "payment#pay", array("id" => $payment_notice_id));
         ajax_return($data);
     }
 }
예제 #6
0
 public function index()
 {
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $money = floatval($user['money']);
     $root = array();
     $root['return'] = 1;
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //已登录
         $region4_id = intval($GLOBALS['request']['region_lv4']);
         $region3_id = intval($GLOBALS['request']['region_lv3']);
         $region2_id = intval($GLOBALS['request']['region_lv2']);
         $region1_id = intval($GLOBALS['request']['region_lv1']);
         if ($region4_id == 0) {
             if ($region3_id == 0) {
                 if ($region2_id == 0) {
                     $region_id = $region1_id;
                 } else {
                     $region_id = $region2_id;
                 }
             } else {
                 $region_id = $region3_id;
             }
         } else {
             $region_id = $region4_id;
         }
         $payment = $GLOBALS['request']['payment_id'] ? intval($GLOBALS['request']['payment_id']) : 17;
         $account_money = floatval($GLOBALS['request']['use_user_money']);
         $address = strim($GLOBALS['request']['delivery_detail']);
         $consignee_mobile = strim($GLOBALS['request']['phone']);
         $zip = strim($GLOBALS['request']['postcode']);
         $consignee = strim($GLOBALS['request']['consignee']);
         $ecvsn = $GLOBALS['request']['ecv_sn'] ? strim($GLOBALS['request']['ecv_sn']) : '';
         $ecvpassword = $GLOBALS['request']['ecv_pwd'] ? strim($GLOBALS['request']['ecv_pwd']) : '';
         $order_memo = strim($GLOBALS['request']['content']);
         $send_mobile = strim($GLOBALS['request']['send_mobile']);
         $delivery_id = intval($GLOBALS['request']['delivery_id']);
         $order_time = $GLOBALS['request']['order_time'];
         $technician_id = $GLOBALS['request']['tech_id'];
         if (empty($order_time)) {
             $root['status'] = 0;
             $root['info'] = '请选择预约时间';
             output($root);
         }
         $order_time .= ':00';
         $order_time = strtotime($order_time);
         //$delivery_id = intval($GLOBALS['m_config']['delivery_id']);
         $coupon_mobile = htmlspecialchars($send_mobile);
         if ($coupon_mobile != '') {
             $i = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where mobile = '" . $coupon_mobile . "' and id != " . intval($user_id)));
             if ($i > 0) {
                 $root['status'] = 0;
                 $root['info'] = '该手机号码,已经被占用';
                 output($root);
             }
         }
         $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'");
         if ($account_pay) {
             $all_account_money = 1;
         } else {
             $all_account_money = 0;
         }
         if ($GLOBALS['request']['from'] == "wap") {
             $cartdata = unserialize(base64_decode($GLOBALS['request']['cartdata']));
             $res = insertCartData($user_id, es_session::id(), $cartdata);
         } else {
             $cartdata = $GLOBALS['request']['cartdata'];
             $res = insertCartData($user_id, es_session::id(), $cartdata);
         }
         if ($res['info'] != '') {
             //失败有错误
             $root['status'] = 0;
             $root['info'] = $res['info'];
             output($root);
         } else {
             //可以提交订单
             $goods_list = $res['data'];
             require_once APP_ROOT_PATH . "system/model/cart.php";
             $GLOBALS['user_info']['id'] = $user_id;
             $ids = array();
             foreach ($goods_list as $cart_goods) {
                 array_push($ids, $cart_goods['deal_id']);
             }
             $ids_str = implode(",", $ids);
             $is_delivery = intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")"));
             if ($is_delivery == 0) {
                 $delivery_id = 0;
             }
             $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list);
             if ($data['is_delivery'] == 1) {
                 //配送验证
                 if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($address == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee_mobile == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!check_mobile(trim($consignee_mobile))) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!$data['delivery_info']) {
                     $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_DELIVERY'];
                     $root['status'] = 0;
                     output($root);
                 }
             }
             if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
                 $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
                 $root['status'] = 0;
                 output($root);
             } else {
                 //获取服务时间
                 foreach ($goods_list as $k => $v) {
                     $order['service_time'] = $v['service_time'];
                 }
                 //技师直约判断当前时间是否可约
                 if ($technician_id) {
                     $tech = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id=" . $technician_id);
                     $start_time = $order_time - $tech['distance_time'] * 60;
                     $end_time = $order_time + $tech['distance_time'] * 60 + $order['service_time'] * 60;
                     $order_able_sql = "SELECT \n                                                                * \n                                                              FROM\n                                                                " . DB_PREFIX . "deal_order DO \n                                                              WHERE  do.technician_id={$technician_id} \n                                                                  and order_status = 0 and is_delete = 0 and extra_status = 0 and after_sale = 0 and refund_status = 0 and  (\n                                                                  do.`order_time` + do.`service_time` * 60 BETWEEN " . $start_time . " \n                                                                  AND " . $end_time . " \n                                                                ) \n                                                                OR (\n                                                                  do.`order_time` BETWEEN " . $start_time . " \n                                                                  AND " . $end_time . "\n                                                                )";
                     $order_able = $GLOBALS['db']->getRow($order_able_sql);
                     if (!empty($order_able)) {
                         $root['info'] = "当前时间已被预约,请重新选择时间";
                         $root['status'] = 0;
                         output($root);
                     }
                 }
                 //验证成功
                 //开始生成订单
                 $now = time();
                 $order['type'] = 0;
                 //普通订单
                 $order['user_id'] = $user_id;
                 $order['user_name'] = $user['user_name'];
                 $order['create_time'] = $now;
                 $order['total_price'] = $data['pay_total_price'];
                 //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
                 $order['pay_amount'] = 0;
                 $order['pay_status'] = 0;
                 //新单都为零, 等下面的流程同步订单状态
                 $order['delivery_status'] = $data['is_delivery'] == 0 ? 5 : 0;
                 $order['order_status'] = 0;
                 //新单都为零, 等下面的流程同步订单状态
                 $order['return_total_score'] = $data['return_total_score'];
                 //结单后送的积分
                 $order['return_total_money'] = $data['return_total_money'];
                 //结单后送的现金
                 $order['memo'] = htmlspecialchars($order_memo);
                 $order['region_lv1'] = $region1_id;
                 $order['region_lv2'] = $region2_id;
                 $order['region_lv3'] = $region3_id;
                 $order['region_lv4'] = $region4_id;
                 $order['address'] = htmlspecialchars($address);
                 $order['mobile'] = htmlspecialchars($consignee_mobile);
                 $order['consignee'] = htmlspecialchars($consignee);
                 $order['zip'] = htmlspecialchars($zip);
                 $order['deal_total_price'] = $data['total_price'];
                 //团购商品总价
                 $order['discount_price'] = $data['user_discount'];
                 $order['delivery_fee'] = $data['delivery_fee'];
                 $order['ecv_money'] = 0;
                 $order['account_money'] = 0;
                 $order['ecv_sn'] = '';
                 $order['delivery_id'] = $data['delivery_info']['id'];
                 $order['payment_id'] = $data['payment_info']['id'];
                 $order['payment_fee'] = $data['payment_fee'];
                 $order['bank_id'] = 0;
                 $order['order_time'] = $order_time;
                 $order['technician_id'] = $technician_id == '' ? 0 : $technician_id;
                 $order['order_end_time'] = $order_time + $order['service_time'] * 60;
                 //if($send_mobile!='')
                 //	$GLOBALS['db']->query("update ".DB_PREFIX."user set mobile = '".$send_mobile."' where id = ".$user_id);
                 do {
                     $order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99);
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
                     $order_id = intval($GLOBALS['db']->insert_id());
                 } while ($order_id == 0);
                 //end 验证成功提交订单成功
                 //开始生成订单产品以及支付
                 //生成订单商品
                 foreach ($goods_list as $k => $v) {
                     $goods_item = array();
                     $goods_item['deal_id'] = $v['deal_id'];
                     $goods_item['number'] = $v['number'];
                     $goods_item['unit_price'] = $v['unit_price'];
                     $goods_item['total_price'] = $v['total_price'];
                     $goods_item['name'] = addslashes($v['name']);
                     $goods_item['sub_name'] = addslashes($v['sub_name']);
                     $goods_item['attr'] = $v['attr'];
                     $goods_item['verify_code'] = $v['verify_code'];
                     $goods_item['order_id'] = $order_id;
                     $goods_item['return_score'] = $v['return_score'];
                     $goods_item['return_total_score'] = $v['return_total_score'];
                     $goods_item['return_money'] = $v['return_money'];
                     $goods_item['return_total_money'] = $v['return_total_money'];
                     $goods_item['buy_type'] = $v['buy_type'];
                     $goods_item['attr_str'] = $v['attr_str'];
                     $goods_item['deal_icon'] = $v['icon'];
                     $goods_item['service_time'] = $v['service_time'];
                     $deal_info = load_auto_cache("cache_deal_cart", array("id" => $v['deal_id']));
                     $goods_item['balance_unit_price'] = $deal_info['balance_price'];
                     $goods_item['balance_total_price'] = $deal_info['balance_price'] * $v['number'];
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $goods_item, 'INSERT', '', 'SILENT');
                 }
                 //开始更新订单表的deal_ids
                 $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set deal_ids = '" . $deal_ids . "' where id = " . $order_id);
                 if ($data['is_delivery'] == 1) {
                     //保存收款人
                     $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $user_id . " order by id desc");
                     $user_consignee['region_lv1'] = $region1_id;
                     $user_consignee['region_lv2'] = $region2_id;
                     $user_consignee['region_lv3'] = $region3_id;
                     $user_consignee['region_lv4'] = $region4_id;
                     $user_consignee['address'] = htmlspecialchars($address);
                     $user_consignee['mobile'] = htmlspecialchars($consignee_mobile);
                     $user_consignee['consignee'] = htmlspecialchars($consignee);
                     $user_consignee['zip'] = htmlspecialchars($zip);
                     $user_consignee['user_id'] = $user_id;
                     if (intval($user_consignee['id']) == 0) {
                         //新增
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'INSERT', '', 'SILENT');
                     } else {
                         //更新
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'UPDATE', 'id=' . $user_consignee['id'], 'SILENT');
                         rm_auto_cache("consignee_info", array("consignee_id" => intval($user_consignee['id'])));
                     }
                 }
                 //生成order_id 后
                 //1. 代金券支付
                 $ecv_data = $data['ecv_data'];
                 if ($ecv_data) {
                     $ecv_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'");
                     $payment_notice_id = make_payment_notice($ecv_data['money'], $order_id, $ecv_payment_id);
                     require_once APP_ROOT_PATH . "system/payment/Voucher_payment.php";
                     $voucher_payment = new Voucher_payment();
                     $voucher_payment->direct_pay($ecv_data['sn'], $ecv_data['password'], $payment_notice_id);
                 }
                 //2. 余额支付
                 $account_money = $data['account_money'];
                 if (floatval($account_money) > 0) {
                     $GLOBALS['payment_lang'] = array('name' => '余额支付', 'account_credit' => '帐户余额', 'use_user_money' => '使用余额支付', 'use_all_money' => '全额支付', 'USER_ORDER_PAID' => '%s订单付款,付款单号%s');
                     $account_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Account'");
                     $payment_notice_id = make_payment_notice($account_money, $order_id, $account_payment_id);
                     require_once APP_ROOT_PATH . "system/payment/Account_payment.php";
                     $account_payment = new Account_payment();
                     $account_payment->get_payment_code($payment_notice_id);
                 }
                 $root['order_id'] = $order_id;
                 $rs = order_paid($order_id);
                 update_order_cache($order_id);
                 if ($rs) {
                     $root['pay_status'] = 1;
                 } else {
                     $root['pay_status'] = 0;
                 }
                 //end 订单产品生成及支付
                 $root['status'] = 1;
             }
             //end 提交订单
         }
     } else {
         $root['user_login_status'] = 0;
         $root['status'] = 0;
         $root['info'] = '请先登录';
         //未登录
     }
     output($root);
 }
예제 #7
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/user.php";
     if (strim($GLOBALS['request']['act_2']) == 'bm') {
         $root['status'] = 1;
         $city_name = strim($GLOBALS['request']['city_name']);
         //城市名称
         //检查用户,用户密码
         $user_data = $GLOBALS['user_info'];
         //报名
         if ($user_data) {
             $root['user_login_status'] = 1;
             $event_id = intval($GLOBALS['request']['event_id']);
             $user_id = intval($GLOBALS['user_info']['id']);
             require_once APP_ROOT_PATH . "system/model/event.php";
             // 				$event = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."event where id = ".$event_id." and is_effect = 1");
             $event = get_event($event_id);
             if ($event) {
                 if ($event['xpoint'] == '') {
                     $event['xpoint'] = 0;
                 }
                 if ($event['ypoint'] == '') {
                     $event['ypoint'] = 0;
                 }
                 if ($event['submit_begin_time'] > NOW_TIME) {
                     $root['return'] = 0;
                     $root['info'] = "活动未开始";
                 } elseif ($event['submit_end_time'] > 0 && $event['submit_end_time'] < NOW_TIME) {
                     $root['return'] = 0;
                     $root['info'] = "活动报名已结束";
                 } elseif ($event['submit_count'] >= $event['total_count'] && $event['total_count'] > 0) {
                     $root['return'] = 0;
                     $root['info'] = "活动名额已满";
                 } else {
                     //开始提交报名
                     $user_id = intval($GLOBALS['user_info']['id']);
                     $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_id . " and event_id = " . $event_id);
                     if ($user_submit) {
                         if ($user_submit['is_verify'] == 1) {
                             $root['return'] = 0;
                             $root['info'] = "您已经报过名了";
                         } elseif ($user_submit['is_verify'] == 2) {
                             $root['return'] = 0;
                             $root['info'] = "您的报名审核不通过";
                         } else {
                             //已经报名,仅作修改
                             $bm = $GLOBALS['request']['bm'];
                             $GLOBALS['db']->query("delete from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id']);
                             foreach ($bm as $field_id => $bm_result) {
                                 $field_data = array();
                                 $field_data['submit_id'] = $user_submit['id'];
                                 $field_data['field_id'] = $field_id;
                                 $field_data['event_id'] = $event_id;
                                 $field_data['result'] = strim($bm_result);
                                 $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT");
                             }
                             $root['return'] = 1;
                             $root['info'] = "报名修改成功";
                         }
                     } else {
                         $submit_data = array();
                         $submit_data['user_id'] = $user_id;
                         $submit_data['event_id'] = $event_id;
                         $submit_data['create_time'] = get_gmtime();
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit", $submit_data, "INSERT");
                         $submit_id = $GLOBALS['db']->insert_id();
                         if ($submit_id) {
                             $bm = $GLOBALS['request']['bm'];
                             //file_put_contents(APP_ROOT_PATH. "sjmapi/log/bm_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($GLOBALS['request'],true));
                             //$bm = (unserialize($GLOBALS['request']['bm']));
                             foreach ($bm as $field_id => $bm_result) {
                                 $field_data = array();
                                 $field_data['submit_id'] = $submit_id;
                                 $field_data['field_id'] = $field_id;
                                 $field_data['event_id'] = $event_id;
                                 $field_data['result'] = strim($bm_result);
                                 $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT");
                             }
                             $GLOBALS['db']->query("update " . DB_PREFIX . "event set submit_count = submit_count+1 where id=" . $event_id);
                             if ($event['is_auto_verify'] == 1) {
                                 //自动审核,发券
                                 $sn = verify_event_submit($submit_id);
                             }
                             //同步分享
                             // 								$title = "报名参加了".$event['name'];
                             // 								$content = "报名参加了".$event['name']." - ".$event['brief'];
                             // 								$url_route = array(
                             // 										'rel_app_index'	=>	'youhui',
                             // 										'rel_route'	=>	'edetail',
                             // 										'rel_param' => 'id='.$event['id']
                             // 								);
                             // 								$tid = insert_topic($content,$title,$type="eventsubmit",$group="", $relay_id = 0, $fav_id = 0,$group_data ="",$attach_list=array(),$url_route);
                             // 								if($tid)
                             // 								{
                             // 									$GLOBALS['db']->query("update ".DB_PREFIX."topic set source_name = '".$GLOBALS['request']['source']."' where id = ".intval($tid));
                             // 								}
                             //同步分享
                             $title = "报名参加了" . $event['name'];
                             $content = "报名参加了" . $event['name'] . " - " . $event['brief'];
                             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'event#' . $event['id'], 'rel_param' => '');
                             require_once APP_ROOT_PATH . "system/model/topic.php";
                             $tid = insert_topic($content, $title, $type = "eventsubmit", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route);
                             if ($tid) {
                                 $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $GLOBALS['request']['source'] . "' where id = " . intval($tid));
                             }
                             require_once APP_ROOT_PATH . "system/model/user.php";
                             modify_account(array("score" => "-" . $event['score_limit']), $user_id, "活动报名:" . $event['name']);
                             $root['return'] = 1;
                             $root['info'] = "报名成功";
                             if ($sn) {
                                 $root['info'] .= " 验证码:" . $sn;
                             } else {
                                 $root['info'] .= " 请等待审核";
                             }
                             rm_auto_cache("event", array("id" => $event['id']));
                         } else {
                             $root['return'] = 0;
                             $root['info'] = "报名失败";
                         }
                     }
                 }
             } else {
                 $root['return'] = 0;
                 $root['info'] = "没有该活动数据";
             }
         } else {
             $root['return'] = 0;
             $root['user_login_status'] = 0;
             $root['info'] = "请先登录";
         }
         output($root);
         //报名
     }
     //报名结束
     $page = intval($GLOBALS['request']['page']);
     //分页,无用
     if ($page == 0) {
         $page = 1;
     }
     $event_id = intval($GLOBALS['request']['event_id']);
     if ($event_id) {
         $user_data = $GLOBALS['user_info'];
         require_once APP_ROOT_PATH . "system/model/event.php";
         $event = get_event($event_id);
         if ($event['xpoint'] == '') {
             $event['xpoint'] = 0;
         }
         if ($event['ypoint'] == '') {
             $event['ypoint'] = 0;
         }
         $pattern = "/<img([^>]*)\\/>/i";
         $replacement = "<img width=300 \$1 />";
         $event['icon'] = get_abs_img_root($event['icon']);
         $pattern = "/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/i";
         //$replacement = "<img width=300 $1 />";
         $replacement = "<img src='\$1' width='278' />";
         $event['content'] = get_abs_img_root(preg_replace($pattern, $replacement, $event['content']));
         //$event['content'] = get_abs_img_root(get_spec_image($event['content'], 278,168,1));
         $event['content'] = preg_replace($pattern, $replacement, $event['content']);
         $event['event_begin_time'] = to_date($event['event_begin_time'], 'Y-m-d');
         $event['event_end_time'] = to_date($event['event_end_time'], 'Y-m-d');
         //验证是否报名
         //$is_submit = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."event_submit where user_id = ".intval($GLOBALS['user_info']['id'])." and event_id = ".$event['id']);
         // 			$event_fields = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."event_field where event_id = ".$event_id." order by sort asc");
         // 			foreach($event_fields as $k=>$v)
         // 			{
         // 				$event_fields[$k]['value_scope'] = explode(" ",$v['value_scope']);
         // 			}
         // 			$event['field_list'] = $event_fields;
         // 			$event['is_submit'] = $is_submit;
         // 			$event['field_list_json']=json_encode($event_fields);
         $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_data['id'] . " and event_id = " . $event_id);
         if ($user_submit) {
             if ($user_submit['is_verify'] == 1) {
                 $event['is_submit'] = 1;
                 //已报名
                 $event['is_verify'] = 1;
                 //已审核
             } elseif ($user_submit['is_verify'] == 2) {
                 $event['is_submit'] = 1;
                 //已报名
                 $event['is_verify'] = 2;
                 //审核失败
             } else {
                 //未审核
                 $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $event_id . " order by sort asc");
                 foreach ($event_fields as $k => $v) {
                     $event_fields[$k]['result'] = $GLOBALS['db']->getOne("select result from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id'] . " and field_id = " . $v['id'] . " and event_id = " . $event_id);
                     $event_fields[$k]['value_scope'] = explode(" ", $v['value_scope']);
                 }
                 $event['event_fields'] = $event_fields;
                 $event['is_submit'] = 1;
                 //已报名
                 $event['is_verify'] = 0;
                 //未审核
                 // 					$GLOBALS['tmpl']->assign("event_fields",$event_fields);
                 // 					$GLOBALS['tmpl']->assign("user_submit",$user_submit);  //表示修改已报名记录
                 // 					$GLOBALS['tmpl']->assign("btn_name","修改报名");
             }
         } else {
             $event_fields = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_field where event_id = " . $event_id . " order by sort asc");
             foreach ($event_fields as $k => $v) {
                 $event_fields[$k]['value_scope'] = explode(" ", $v['value_scope']);
             }
             $event['event_fields'] = $event_fields;
             $event['is_submit'] = 0;
             //已报名
         }
     }
     //$res = m_get_event_reply($event_id,$page);
     //$event['comments'] =  $res['list'];
     //$root['page'] = $res['page'];
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list(3, $param = array("deal_id" => 0, "youhui_id" => 0, "event_id" => $event_id, "location_id" => 0, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     $root['return'] = 1;
     $root['item'] = $event;
     $root['page_title'] = "活动详情";
     $root['city_name'] = $city_name;
     output($root);
 }
예제 #8
0
 public function save()
 {
     global_run();
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         $result['status'] = 2;
         ajax_return($result);
     }
     $consignee_id = intval($_REQUEST['region_id']);
     $region_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_consignee where user_id = " . $GLOBALS['user_info']['id']);
     if ($region_count >= 5 && $consignee_id == 0) {
         $result['status'] = 3;
         ajax_return($result);
     }
     if (strim($_REQUEST['consignee']) == '') {
         showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'], 1);
     }
     if (strim($_REQUEST['address']) == '') {
         showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS'], 1);
     }
     if (strim($_REQUEST['zip']) == '') {
         showErr($GLOBALS['lang']['FILL_CORRECT_ZIP'], 1);
     }
     if (strim($_REQUEST['mobile']) == '') {
         showErr($GLOBALS['lang']['FILL_MOBILE_PHONE'], 1);
     }
     if (!check_mobile($_REQUEST['mobile'])) {
         showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'], 1);
     }
     $consignee_data['user_id'] = $GLOBALS['user_info']['id'];
     $consignee_data['region_lv1'] = intval($_REQUEST['region_lv1']);
     $consignee_data['region_lv2'] = intval($_REQUEST['region_lv2']);
     $consignee_data['region_lv3'] = intval($_REQUEST['region_lv3']);
     $consignee_data['region_lv4'] = intval($_REQUEST['region_lv4']);
     $consignee_data['address'] = strim($_REQUEST['address']);
     $consignee_data['mobile'] = strim($_REQUEST['mobile']);
     $consignee_data['consignee'] = strim($_REQUEST['consignee']);
     $consignee_data['zip'] = strim($_REQUEST['zip']);
     $consignee_count = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_consignee where user_id = " . $GLOBALS['user_info']['id']));
     if ($consignee_count == 0) {
         $consignee_data['is_default'] = 1;
     }
     if ($consignee_id == 0) {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data);
     } else {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data, "UPDATE", "id=" . $consignee_id . " and user_id=" . $GLOBALS['user_info']['id']);
     }
     rm_auto_cache("consignee_info", array("consignee_id" => intval($consignee_id)));
     $result['status'] = 1;
     $result['url'] = url('index', 'uc_consignee');
     ajax_return($result);
 }
예제 #9
0
 public function set_sort()
 {
     $id = intval($_REQUEST['id']);
     $sort = intval($_REQUEST['sort']);
     $log_info = M(MODULE_NAME)->where("id=" . $id)->getField('name');
     if (!check_sort($sort)) {
         $this->error(l("SORT_FAILED"), 1);
     }
     M(MODULE_NAME)->where("id=" . $id)->setField("sort", $sort);
     rm_auto_cache("cache_deal_cart", array("id" => $id));
     save_log($log_info . l("SORT_SUCCESS"), 1);
     $this->success(l("SORT_SUCCESS"), 1);
 }
예제 #10
0
 public function toogle_status()
 {
     $id = intval($_REQUEST['id']);
     $ajax = intval($_REQUEST['ajax']);
     $field = $_REQUEST['field'];
     $info = $id . "_" . $field;
     $c_is_effect = M(MODULE_NAME)->where("id=" . $id)->getField($field);
     //当前状态
     $n_is_effect = $c_is_effect == 0 ? 1 : 0;
     //需设置的状态
     //推荐、置顶、精华增加积分等
     if ($field == 'is_top' || $field == 'is_best' || $field == 'is_recommend') {
         if (!$c_is_effect) {
             if ($field == 'is_top') {
                 $log_txt = '管理员操作置顶';
             }
             if ($field == 'is_best') {
                 $log_txt = '管理员操作精华';
             }
             if ($field == 'is_recommend') {
                 $log_txt = '管理员操作推荐';
             }
             $money = doubleval(app_conf("USER_ADD_MONEY"));
             $score = intval(app_conf("USER_ADD_SCORE"));
             $point = intval(app_conf("USER_ADD_POINT"));
         } else {
             if ($field == 'is_top') {
                 $log_txt = '管理员操作取消置顶';
             }
             if ($field == 'is_best') {
                 $log_txt = '管理员操作取消精华';
             }
             if ($field == 'is_recommend') {
                 $log_txt = '管理员操作取消推荐';
             }
             $money = -doubleval(app_conf("USER_ADD_MONEY"));
             $score = -intval(app_conf("USER_ADD_SCORE"));
             $point = -intval(app_conf("USER_ADD_POINT"));
         }
         if ($money != 0 || $score != 0 || $point != 0) {
             $user_id = M(MODULE_NAME)->where("id=" . $id)->getField('user_id');
             require_once APP_ROOT_PATH . "system/model/user.php";
             modify_account(array("money" => $money, "score" => $score, "point" => $point), $user_id, $log_txt);
         }
     }
     M(MODULE_NAME)->where("id=" . $id)->setField($field, $n_is_effect);
     save_log($info . l("SET_EFFECT_" . $n_is_effect), 1);
     rm_auto_cache("recommend_forum_topic");
     $this->ajaxReturn($n_is_effect, l("SET_EFFECT_" . $n_is_effect), 1);
 }
예제 #11
0
 public function set_effect()
 {
     $id = intval($_REQUEST['id']);
     $ajax = intval($_REQUEST['ajax']);
     $info = M("User")->where("id=" . $id)->getField("name");
     $c_vip_state = M("User")->where("id=" . $id)->getField("vip_state");
     //当前状态
     $n_vip_state = $c_vip_state == 0 ? 1 : 0;
     //需设置的状态
     M("User")->where("id=" . $id)->setField("vip_state", $n_vip_state);
     save_log($info . l("SET_EFFECT_" . $n_vip_state), 1);
     rm_auto_cache("cache_vip_user");
     $this->ajaxReturn($n_vip_state, l("SET_EFFECT_" . $n_vip_state), 1);
 }
 public function check_platform_get_pre_auth_code()
 {
     //若在有效期 则直接调用
     //		if(get_gmtime()<$this->platform_pre_auth_code_expire){
     //			 return $this->platform_pre_auth_code;
     //		}
     $data = array("component_appid" => $this->platform_appid);
     $result = $this->http_post(self::API_URL_PREFIX . self::PLATFORM_GET_PRE_AUTH_CODE . $this->platform_component_access_token, json_encode($data));
     if ($result) {
         $json = json_decode($result, true);
         if (!$json || isset($json['errcode'])) {
             $this->errCode = $json['errcode'];
             $this->errMsg = $json['errmsg'];
             return false;
         }
         $this->platform_pre_auth_code = $json['pre_auth_code'];
         $expire = $json['expires_in'] ? intval($json['expires_in']) - 100 : 3600;
         $expire = $expire + get_gmtime();
         $GLOBALS['db']->query("update " . DB_PREFIX . "weixin_conf set value='" . $this->platform_pre_auth_code . "' where name='platform_pre_auth_code' ");
         $GLOBALS['db']->query("update " . DB_PREFIX . "weixin_conf set value='" . $expire . "' where name='platform_pre_auth_code_expire' ");
         rm_auto_cache("weixin_conf");
         //load_auto_cache("weixin_conf");
         return $this->platform_pre_auth_code;
     }
     return false;
 }
예제 #13
0
 public function toogle_status()
 {
     $id = intval($_REQUEST['id']);
     $ajax = intval($_REQUEST['ajax']);
     $field = $_REQUEST['field'];
     $info = $id . "_" . $field;
     $c_is_effect = M(MODULE_NAME)->where("id=" . $id)->getField($field);
     //当前状态
     $n_is_effect = $c_is_effect == 0 ? 1 : 0;
     //需设置的状态
     M(MODULE_NAME)->where("id=" . $id)->setField($field, $n_is_effect);
     save_log($info . l("SET_EFFECT_" . $n_is_effect), 1);
     rm_auto_cache("recommend_forum_topic");
     $this->ajaxReturn($n_is_effect, l("SET_EFFECT_" . $n_is_effect), 1);
 }
예제 #14
0
 public function index()
 {
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     $money = floatval($user['money']);
     $root = array();
     $root['return'] = 1;
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //已登录
         $region4_id = intval($GLOBALS['request']['region_lv4']);
         $region3_id = intval($GLOBALS['request']['region_lv3']);
         $region2_id = intval($GLOBALS['request']['region_lv2']);
         $region1_id = intval($GLOBALS['request']['region_lv1']);
         if ($region4_id == 0) {
             if ($region3_id == 0) {
                 if ($region2_id == 0) {
                     $region_id = $region1_id;
                 } else {
                     $region_id = $region2_id;
                 }
             } else {
                 $region_id = $region3_id;
             }
         } else {
             $region_id = $region4_id;
         }
         $payment = intval($GLOBALS['request']['payment_id']);
         $account_money = floatval($GLOBALS['request']['use_user_money']);
         $address = strim($GLOBALS['request']['delivery_detail']);
         $consignee_mobile = strim($GLOBALS['request']['phone']);
         $zip = strim($GLOBALS['request']['postcode']);
         $consignee = strim($GLOBALS['request']['consignee']);
         $ecvsn = $GLOBALS['request']['ecv_sn'] ? strim($GLOBALS['request']['ecv_sn']) : '';
         $ecvpassword = $GLOBALS['request']['ecv_pwd'] ? strim($GLOBALS['request']['ecv_pwd']) : '';
         $order_memo = strim($GLOBALS['request']['content']);
         $send_mobile = strim($GLOBALS['request']['send_mobile']);
         $delivery_id = intval($GLOBALS['request']['delivery_id']);
         //$delivery_id = intval($GLOBALS['m_config']['delivery_id']);
         $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'");
         if ($account_pay) {
             $all_account_money = 1;
         } else {
             $all_account_money = 0;
         }
         $res = insertCartData($user_id, session_id(), $GLOBALS['request']['cartdata']);
         if ($res['info'] != '') {
             //失败有错误
             $root['status'] = 0;
             $root['info'] = $res['info'];
             output($root);
         } else {
             //可以提交订单
             $goods_list = $res['data'];
             require_once APP_ROOT_PATH . "system/libs/cart.php";
             $GLOBALS['user_info']['id'] = $user_id;
             $ids = array();
             foreach ($goods_list as $cart_goods) {
                 array_push($ids, $cart_goods['deal_id']);
             }
             $ids_str = implode(",", $ids);
             $is_delivery = intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")"));
             if ($is_delivery == 0) {
                 $delivery_id = 0;
             }
             $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list);
             if ($data['is_delivery'] == 1) {
                 //配送验证
                 if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($address == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($zip == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ZIP'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee_mobile == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!check_mobile(trim($consignee_mobile))) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!$data['delivery_info']) {
                     $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_DELIVERY'];
                     $root['status'] = 0;
                     output($root);
                 }
             }
             if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
                 $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
                 $root['status'] = 0;
                 output($root);
             } else {
                 //验证成功
                 //开始生成订单
                 $now = get_gmtime();
                 $order['type'] = 0;
                 //普通订单
                 $order['user_id'] = $user_id;
                 $order['create_time'] = $now;
                 $order['total_price'] = $data['pay_total_price'];
                 //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
                 $order['pay_amount'] = 0;
                 $order['pay_status'] = 0;
                 //新单都为零, 等下面的流程同步订单状态
                 $order['delivery_status'] = $data['is_delivery'] == 0 ? 5 : 0;
                 $order['order_status'] = 0;
                 //新单都为零, 等下面的流程同步订单状态
                 $order['return_total_score'] = $data['return_total_score'];
                 //结单后送的积分
                 $order['return_total_money'] = $data['return_total_money'];
                 //结单后送的现金
                 $order['memo'] = htmlspecialchars($order_memo);
                 $order['region_lv1'] = $region1_id;
                 $order['region_lv2'] = $region2_id;
                 $order['region_lv3'] = $region3_id;
                 $order['region_lv4'] = $region4_id;
                 $order['address'] = htmlspecialchars($address);
                 $order['mobile'] = htmlspecialchars($consignee_mobile);
                 $order['consignee'] = htmlspecialchars($consignee);
                 $order['zip'] = htmlspecialchars($zip);
                 $order['deal_total_price'] = $data['total_price'];
                 //团购商品总价
                 $order['discount_price'] = $data['user_discount'];
                 $order['delivery_fee'] = $data['delivery_fee'];
                 $order['ecv_money'] = 0;
                 $order['account_money'] = 0;
                 $order['ecv_sn'] = '';
                 $order['delivery_id'] = $data['delivery_info']['id'];
                 $order['payment_id'] = $data['payment_info']['id'];
                 $order['payment_fee'] = $data['payment_fee'];
                 $order['payment_fee'] = $data['payment_fee'];
                 $order['bank_id'] = 0;
                 if ($send_mobile != '') {
                     $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $send_mobile . "' where id = " . $user_id);
                 }
                 do {
                     $order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99);
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
                     $order_id = intval($GLOBALS['db']->insert_id());
                 } while ($order_id == 0);
                 //end 验证成功提交订单成功
                 //开始生成订单产品以及支付
                 //生成订单商品
                 foreach ($goods_list as $k => $v) {
                     $goods_item = array();
                     $goods_item['deal_id'] = $v['deal_id'];
                     $goods_item['number'] = $v['number'];
                     $goods_item['unit_price'] = $v['unit_price'];
                     $goods_item['total_price'] = $v['total_price'];
                     $goods_item['name'] = addslashes($v['name']);
                     $goods_item['sub_name'] = addslashes($v['sub_name']);
                     $goods_item['attr'] = $v['attr'];
                     $goods_item['verify_code'] = $v['verify_code'];
                     $goods_item['order_id'] = $order_id;
                     $goods_item['return_score'] = $v['return_score'];
                     $goods_item['return_total_score'] = $v['return_total_score'];
                     $goods_item['return_money'] = $v['return_money'];
                     $goods_item['return_total_money'] = $v['return_total_money'];
                     $goods_item['buy_type'] = $v['buy_type'];
                     $goods_item['attr_str'] = $v['attr_str'];
                     $deal_info = load_auto_cache("cache_deal_cart", array("id" => $v['deal_id']));
                     $goods_item['balance_unit_price'] = $deal_info['balance_price'];
                     $goods_item['balance_total_price'] = $deal_info['balance_price'] * $v['number'];
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $goods_item, 'INSERT', '', 'SILENT');
                 }
                 //开始更新订单表的deal_ids
                 $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set deal_ids = '" . $deal_ids . "' where id = " . $order_id);
                 if ($data['is_delivery'] == 1) {
                     //保存收款人
                     $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $user_id . " order by id desc");
                     $user_consignee['region_lv1'] = $region1_id;
                     $user_consignee['region_lv2'] = $region2_id;
                     $user_consignee['region_lv3'] = $region3_id;
                     $user_consignee['region_lv4'] = $region4_id;
                     $user_consignee['address'] = htmlspecialchars($address);
                     $user_consignee['mobile'] = htmlspecialchars($consignee_mobile);
                     $user_consignee['consignee'] = htmlspecialchars($consignee);
                     $user_consignee['zip'] = htmlspecialchars($zip);
                     $user_consignee['user_id'] = $user_id;
                     if (intval($user_consignee['id']) == 0) {
                         //新增
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'INSERT', '', 'SILENT');
                     } else {
                         //更新
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'UPDATE', 'id=' . $user_consignee['id'], 'SILENT');
                         rm_auto_cache("consignee_info", array("consignee_id" => intval($user_consignee['id'])));
                     }
                 }
                 //生成order_id 后
                 //1. 代金券支付
                 $ecv_data = $data['ecv_data'];
                 if ($ecv_data) {
                     $ecv_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'");
                     $payment_notice_id = make_payment_notice($ecv_data['money'], $order_id, $ecv_payment_id);
                     require_once APP_ROOT_PATH . "system/payment/Voucher_payment.php";
                     $voucher_payment = new Voucher_payment();
                     $voucher_payment->direct_pay($ecv_data['sn'], $ecv_data['password'], $payment_notice_id);
                 }
                 //2. 余额支付
                 $account_money = $data['account_money'];
                 if (floatval($account_money) > 0) {
                     $GLOBALS['payment_lang'] = array('name' => '余额支付', 'account_credit' => '帐户余额', 'use_user_money' => '使用余额支付', 'use_all_money' => '全额支付', 'USER_ORDER_PAID' => '%s订单付款,付款单号%s');
                     $account_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Account'");
                     $payment_notice_id = make_payment_notice($account_money, $order_id, $account_payment_id);
                     require_once APP_ROOT_PATH . "system/payment/Account_payment.php";
                     $account_payment = new Account_payment();
                     $account_payment->get_payment_code($payment_notice_id);
                 }
                 $root['order_id'] = $order_id;
                 $rs = order_paid($order_id);
                 if ($rs) {
                     $root['pay_status'] = 1;
                 } else {
                     $root['pay_status'] = 0;
                 }
                 //end 订单产品生成及支付
                 $root['status'] = 1;
             }
             //end 提交订单
         }
     } else {
         $root['user_login_status'] = 1;
         $root['status'] = 0;
         //未登录
     }
     output($root);
 }
예제 #15
0
 /**
  * 清空浏览历史
  */
 public function clear_history()
 {
     global_run();
     $type = strim($_REQUEST['type']);
     if ($type == "alldeal") {
         rm_auto_cache("cache_history", array("type" => "deal", "city_id" => $GLOBALS['city']['id']));
         rm_auto_cache("cache_history", array("type" => "shop", "city_id" => $GLOBALS['city']['id']));
     } else {
         rm_auto_cache("cache_history", array("type" => $type, "city_id" => $GLOBALS['city']['id']));
     }
     $data['status'] = 1;
     ajax_return($data);
 }
 public function saveconfig()
 {
     $config = $_POST['config'];
     $has_ids = null;
     foreach ($config['id'] as $k => $v) {
         if (intval($v) > 0) {
             $has_ids[] = $v;
         }
     }
     M()->query("DELETE FROM " . DB_PREFIX . "user_carry_config WHERE id not in (" . implode(",", $has_ids) . ")");
     foreach ($config['id'] as $k => $v) {
         if (intval($v) > 0) {
             $config_data = array();
             $config_data['id'] = $v;
             $config_data['name'] = trim($config['name'][$k]);
             $config_data['min_price'] = floatval($config['min_price'][$k]);
             $config_data['max_price'] = floatval($config['max_price'][$k]);
             $config_data['fee'] = floatval($config['fee'][$k]);
             $config_data['fee_type'] = intval($config['fee_type'][$k]);
             M("UserCarryConfig")->save($config_data);
         }
     }
     $aconfig = $_POST['aconfig'];
     foreach ($aconfig['name'] as $k => $v) {
         if (trim($v) != "") {
             $config_data = array();
             $config_data['name'] = trim($v);
             $config_data['min_price'] = floatval($aconfig['min_price'][$k]);
             $config_data['max_price'] = floatval($aconfig['max_price'][$k]);
             $config_data['fee'] = floatval($aconfig['fee'][$k]);
             $config_data['fee_type'] = intval($aconfig['fee_type'][$k]);
             M("UserCarryConfig")->add($config_data);
         }
     }
     rm_auto_cache("user_carry_config");
     $this->success(L("UPDATE_SUCCESS"));
 }
 public function delete()
 {
     //彻底删除指定记录
     $ajax = intval($_REQUEST['ajax']);
     $id = $_REQUEST['id'];
     if (isset($id)) {
         $condition = array('id' => array('in', explode(',', $id)), 'status' => array('eq', 0));
         $rel_data = M("UserCreditType")->where($condition)->findAll();
         foreach ($rel_data as $data) {
             $info[] = $data['type_name'];
         }
         if ($info) {
             $info = implode(",", $info);
         }
         $list = M("UserCreditType")->where($condition)->delete();
         if ($list !== false) {
             save_log($info . l("FOREVER_DELETE_SUCCESS"), 1);
             rm_auto_cache("credit_type");
             $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax);
         } else {
             save_log($info . l("FOREVER_DELETE_FAILED"), 0);
             $this->error(l("FOREVER_DELETE_FAILED"), $ajax);
         }
     } else {
         $this->error(l("INVALID_OPERATION"), $ajax);
     }
 }
예제 #18
0
 public function do_submit()
 {
     global_run();
     if (empty($GLOBALS['user_info'])) {
         $data['status'] = 1000;
         ajax_return($data);
     }
     $event_id = intval($_REQUEST['event_id']);
     require_once APP_ROOT_PATH . "system/model/event.php";
     $event = get_event($event_id);
     if (!$event) {
         $data['status'] = 0;
         $data['info'] = "活动不存在";
         ajax_return($data);
     }
     if ($event['submit_begin_time'] > NOW_TIME) {
         $data['status'] = 0;
         $data['info'] = "活动报名未开始";
         ajax_return($data);
     }
     if ($event['submit_end_time'] > 0 && $event['submit_end_time'] < NOW_TIME) {
         $data['status'] = 0;
         $data['info'] = "活动报名已结束";
         ajax_return($data);
     }
     if ($event['submit_count'] >= $event['total_count'] && $event['total_count'] > 0) {
         $data['status'] = 0;
         $data['info'] = "活动名额已满";
         ajax_return($data);
     }
     $user_id = intval($GLOBALS['user_info']['id']);
     $user_submit = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where user_id = " . $user_id . " and event_id = " . $event_id);
     if ($user_submit) {
         if ($user_submit['is_verify'] == 1) {
             $data['status'] = 0;
             $data['info'] = "您已经报名";
             ajax_return($data);
         } elseif ($user_submit['is_verify'] == 2) {
             $data['status'] = 0;
             $data['info'] = "您的报名审核不通过";
             ajax_return($data);
         } else {
             //已经报名,仅作修改
             $GLOBALS['db']->query("delete from " . DB_PREFIX . "event_submit_field where submit_id = " . $user_submit['id']);
             $field_ids = $_REQUEST['field_id'];
             foreach ($field_ids as $field_id) {
                 $current_result = strim($_REQUEST['result'][$field_id]);
                 $field_data = array();
                 $field_data['submit_id'] = $user_submit['id'];
                 $field_data['field_id'] = $field_id;
                 $field_data['event_id'] = $event_id;
                 $field_data['result'] = $current_result;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT");
             }
             $result['status'] = 1;
             $result['info'] = "报名修改成功";
             ajax_return($result);
         }
     } else {
         $GLOBALS['db']->query("update " . DB_PREFIX . "event set submit_count = submit_count+1 where id=" . $event_id . " and submit_count + 1 <= total_count and total_count > 0");
         if (!$GLOBALS['db']->affected_rows()) {
             $data['status'] = 0;
             $data['info'] = "活动名额已满";
             ajax_return($data);
         }
         if ($event['score_limit'] > 0 || $event['point_limit'] > 0) {
             $c_user_info = $GLOBALS['user_info'];
             if ($c_user_info['score'] < $event['score_limit']) {
                 $data['status'] = 0;
                 $data['info'] = "积分不足,不能报名";
                 ajax_return($data);
             }
             if ($c_user_info['point'] < $event['point_limit']) {
                 $data['status'] = 0;
                 $data['info'] = "经验不足,不能报名";
                 ajax_return($data);
             }
         }
         $submit_data = array();
         $submit_data['user_id'] = $user_id;
         $submit_data['event_id'] = $event_id;
         $submit_data['create_time'] = NOW_TIME;
         $submit_data['event_begin_time'] = $event['event_begin_time'];
         $submit_data['event_end_time'] = $event['event_end_time'];
         $submit_data['return_money'] = $event['return_money'];
         $submit_data['return_score'] = $event['return_score'];
         $submit_data['return_point'] = $event['return_point'];
         $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit", $submit_data, "INSERT");
         $submit_id = $GLOBALS['db']->insert_id();
         if ($submit_id) {
             $field_ids = $_REQUEST['field_id'];
             foreach ($field_ids as $field_id) {
                 $current_result = strim($_REQUEST['result'][$field_id]);
                 $field_data = array();
                 $field_data['submit_id'] = $submit_id;
                 $field_data['field_id'] = $field_id;
                 $field_data['event_id'] = $event_id;
                 $field_data['result'] = $current_result;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "event_submit_field", $field_data, "INSERT");
             }
             if ($event['is_auto_verify'] == 1) {
                 //自动审核,发券
                 $sn = verify_event_submit($submit_id);
             }
             //同步分享
             $title = "报名参加了" . $event['name'];
             $content = "报名参加了" . $event['name'] . " - " . $event['brief'];
             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'event#' . $event['id'], 'rel_param' => '');
             require_once APP_ROOT_PATH . "system/model/topic.php";
             $tid = insert_topic($content, $title, $type = "eventsubmit", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route);
             if ($tid) {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid));
             }
             require_once APP_ROOT_PATH . "system/model/user.php";
             modify_account(array("score" => "-" . $event['score_limit']), $user_id, "活动报名:" . $event['name']);
             $data['status'] = 1;
             $data['info'] = "报名成功";
             if ($sn) {
                 $data['info'] .= ",验证码:" . $sn;
             }
             rm_auto_cache("event", array("id" => $event['id']));
             ajax_return($data);
         } else {
             $data['status'] = 0;
             $data['info'] = "报名失败";
             ajax_return($data);
         }
     }
 }
 public function foreverdelete()
 {
     //彻底删除指定记录
     $ajax = intval($_REQUEST['ajax']);
     $id = $_REQUEST['id'];
     if (isset($id)) {
         $condition = array('id' => array('in', explode(',', $id)));
         if (M("Deal")->where(array('type_id' => array('in', explode(',', $id))))->count() > 0) {
             $this->error(l("SUB_DEAL_EXIST"), $ajax);
         }
         $rel_data = M(MODULE_NAME)->where($condition)->findAll();
         foreach ($rel_data as $data) {
             $info[] = $data['name'];
         }
         if ($info) {
             $info = implode(",", $info);
         }
         $list = M(MODULE_NAME)->where($condition)->delete();
         if ($list !== false) {
             save_log($info . l("FOREVER_DELETE_SUCCESS"), 1);
             rm_auto_cache("deal_loan_type_list");
             $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax);
         } else {
             save_log($info . l("FOREVER_DELETE_FAILED"), 0);
             $this->error(l("FOREVER_DELETE_FAILED"), $ajax);
         }
     } else {
         $this->error(l("INVALID_OPERATION"), $ajax);
     }
 }
예제 #20
0
파일: event.php 프로젝트: macall/jsd
/**
 * 拒绝审核
 * @param unknown_type $submit_id
 */
function refuse_event_submit($submit_id)
{
    $submit_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event_submit where id = " . $submit_id);
    if ($submit_data) {
        $GLOBALS['db']->query("update " . DB_PREFIX . "event_submit set sn = '',is_verify = 2 where id = " . $submit_id);
        if ($GLOBALS['db']->affected_rows()) {
            $GLOBALS['db']->query("update " . DB_PREFIX . "event set submit_count = submit_count-1 where id=" . $submit_data['event_id']);
            rm_auto_cache("event", array("id" => $submit_data['event_id']));
            return true;
        }
    }
    return false;
}