public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     $deal_id = intval($GLOBALS['request']['deal_id']);
     //团购商品id
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $sql = "update " . DB_PREFIX . "message set is_read = 1 where is_read = 0 and rel_id = " . $deal_id . " and rel_table = 'deal' and pid = 0 and is_buy = 1";
         //$root['sql'] = $sql;
         $GLOBALS['db']->query($sql);
         $root['return'] = 1;
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Beispiel #2
0
 public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     $deal_id = intval($GLOBALS['request']['deal_id']);
     //团购商品id
     if ($supplier_id > 0) {
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
         $list = $GLOBALS['db']->getAll("select d.sn,d.password,d.confirm_time from " . DB_PREFIX . "deal_coupon as d where d.confirm_account > 0 and d.is_valid = 1 and d.is_delete = 0 and d.deal_id = " . $deal_id . " and d.supplier_id = " . $supplier_id . " order by d.confirm_time desc limit " . $limit);
         foreach ($list as $k => $v) {
             $list[$k]['confirm_time_format'] = to_date($v['confirm_time'], 'Y-m-d H:i');
         }
         $count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon as d where d.confirm_account > 0 and d.is_valid = 1 and d.is_delete = 0 and d.deal_id = " . $deal_id . " and  d.supplier_id = " . $supplier_id);
         $root['page'] = array("page" => $page, "page_total" => ceil($count / PAGE_SIZE), "page_size" => PAGE_SIZE);
         $root['item'] = $list;
         $root['return'] = 1;
     }
     output($root);
 }
Beispiel #3
0
 public function index()
 {
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $root['page_title'] = '验证及消费登记';
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['return'] = 1;
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商家登陆成功";
         $root['status'] = 1;
         $root['biz_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
     } else {
         $root['info'] = "请先登陆";
         $root['return'] = 0;
         $root['status'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['biz_login_status'] = 0;
         $root['uid'] = 0;
         $root['user_name'] = $email;
     }
     $root['city_name'] = $city_name;
     output($root);
 }
Beispiel #4
0
 public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     $type = strim($GLOBALS['request']['type']);
     //0:全部评价;1:差评;2:未读
     $deal_id = strim($GLOBALS['request']['deal_id']);
     //团购商品id
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
         $sql = "select m.id,m.content,m.create_time,m.update_time, m.point,m.admin_reply,m.admin_id,u.user_name from " . DB_PREFIX . "message m left join fanwe_user u on u.id = m.user_id where m.rel_id = " . $deal_id . " and m.rel_table = 'deal' and m.pid = 0 and m.is_buy = 1";
         $count_sql = "select count(*) from " . DB_PREFIX . "message m left join fanwe_user u on u.id = m.user_id where m.rel_id = " . $deal_id . " and m.rel_table = 'deal' and m.pid = 0 and m.is_buy = 1";
         //0:全部评价;1:差评;2:未读
         if ($type == 1) {
             $sql .= " and m.point <= 2 ";
             $count_sql .= " and m.point <= 2 ";
         } else {
             if ($type == 2) {
                 $sql .= " and m.is_read = 0 ";
                 $count_sql .= " and m.is_read = 0 ";
             }
         }
         $count = $GLOBALS['db']->getOne($count_sql);
         $sql .= " order by m.create_time desc limit " . $limit;
         $deal_list = $GLOBALS['db']->getAll($sql);
         //$root['sql'] = $sql;
         //echo $sql; exit;
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['create_time_format'] = to_date($v['create_time'], 'Y-m-d H:i');
             $deal_list[$k]['update_time_format'] = to_date($v['update_time'], 'Y-m-d H:i');
         }
         $root['page'] = array("page" => $page, "page_total" => ceil($count / PAGE_SIZE), "page_size" => PAGE_SIZE);
         if ($deal_list == false || $deal_list == null) {
             $deal_list = array();
         }
         //$root['count'] = count($deal_list);
         //$root['22'] = print_r($deal_list,1);
         $root['item'] = $deal_list;
         $root['return'] = 1;
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Beispiel #5
0
 public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $title = strim($GLOBALS['request']['title']);
         //前台,老板,财务,其它
         $content = strim($GLOBALS['request']['content']);
         //意见反馈
         $contact = strim($GLOBALS['request']['contact']);
         //联系方式
         $reply_data = array();
         $reply_data['title'] = $title;
         $reply_data['content'] = $content;
         $reply_data['create_time'] = get_gmtime();
         $reply_data['rel_table'] = 'feedback';
         $reply_data['rel_id'] = 0;
         $reply_data['user_id'] = 0;
         $reply_data['pid'] = 0;
         $reply_data['is_effect'] = 1;
         $reply_data['city_id'] = 0;
         $reply_data['is_buy'] = 0;
         $reply_data['contact_name'] = 0;
         $reply_data['contact'] = $contact;
         $reply_data['point'] = 0;
         $reply_data['is_read'] = 0;
         $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $reply_data);
         $msg_id = intval($GLOBALS['db']->insert_id());
         if ($msg_id > 0) {
             $root['return'] = 1;
             $root['info'] = "反馈成功";
         } else {
             $root['return'] = 0;
             $root['info'] = "反馈失败";
         }
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Beispiel #6
0
 public function index()
 {
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $root['page_title'] = '商户登陆';
     $root['city_name'] = $city_name;
     if (empty($email) || empty($pwd)) {
         $root['return'] = 0;
         output($root);
         exit;
     }
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['return'] = 1;
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商家登陆成功";
         $root['supplier_id'] = $biz_user['supplier_id'];
         $root['supplier_name'] = $biz_user['name'];
         $root['account_name'] = $biz_user['account_name'];
         $root['biz_email'] = $email;
         $root['biz_pwd'] = $biz_user['account_password'];
         $root['status'] = 1;
         $root['biz_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
     } else {
         $err = "商户不存在或密码错误";
         $root['return'] = 0;
         $root['status'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['biz_login_status'] = 0;
         $root['info'] = $err;
         $root['uid'] = 0;
         $root['user_name'] = $email;
     }
     output($root);
 }
Beispiel #7
0
 public function index()
 {
     $GLOBALS['lang'] = (require APP_ROOT_PATH . "app/Lang/zh-cn/lang.php");
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         require_once APP_ROOT_PATH . "system/model/biz_verify.php";
         //$sn = htmlspecialchars(addslashes(trim($GLOBALS['request']['coupon_sn'])));
         $pwd = htmlspecialchars(addslashes(trim($GLOBALS['request']['coupon_pwd'])));
         //$result = biz_check_coupon($biz_user,null,$pwd);
         $location_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "supplier_location where supplier_id=" . $supplier_id . " and is_main=1 and is_effect=1");
         $result = biz_check_coupon($biz_user, $pwd, $location_id);
         $root['return'] = 1;
         $root['status'] = $result['status'];
         if ($result['status'] == 1) {
             $root['info'] = $result['sub_msg'];
             //可消费的团购券数量,现按单发短信时,只能一次性消费掉所有的团购券
             $root['max_num'] = $result['number'];
             $root['min_num'] = $result['number'];
         } else {
             $root['info'] = $result['msg'];
             //'此密码错误,不能接待。请与消费者确认提供的密码是否正确';
             //可消费的团购券数量
             $root['max_num'] = 0;
             $root['min_num'] = 0;
         }
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
 public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     $id = intval($GLOBALS['request']['id']);
     //消息id
     $deal_id = intval($GLOBALS['request']['deal_id']);
     //团购商品id
     $admin_reply = strim($GLOBALS['request']['admin_reply']);
     //回复内容
     if (empty($admin_reply)) {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "回复不能为空";
     } else {
         if ($supplier_id > 0) {
             $root['user_login_status'] = 1;
             //用户登陆状态:1:成功登陆;0:未成功登陆
             $sql = "update " . DB_PREFIX . "message set admin_reply = '" . $admin_reply . "',admin_id={$supplier_id},update_time=" . get_gmtime() . " where id = " . $id . " and rel_id = " . $deal_id . " and rel_table = 'deal' and pid = 0 and is_buy = 1";
             //echo $sql;exit;
             //$root['sql'] = $sql;
             $GLOBALS['db']->query($sql);
             $root['return'] = 1;
         } else {
             $root['return'] = 0;
             $root['user_login_status'] = 0;
             //用户登陆状态:1:成功登陆;0:未成功登陆
             $root['info'] = "商户不存在或密码错误";
         }
     }
     output($root);
 }
Beispiel #9
0
 public function index()
 {
     $GLOBALS['lang'] = (require APP_ROOT_PATH . "app/Lang/zh-cn/lang.php");
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         require_once APP_ROOT_PATH . "system/model/biz_verify.php";
         //使用数量
         $use_num = intval($GLOBALS['request']['use_num']);
         if ($use_num <= 0) {
             $use_num = 1;
         }
         $pwd = htmlspecialchars(addslashes(trim($GLOBALS['request']['coupon_pwd'])));
         $result = biz_use_coupon($biz_user, null, $pwd, $use_num);
         $root['return'] = 1;
         $root['status'] = $result['status'];
         if ($result['status'] == 1) {
             $root['info'] = $result['sub_msg'];
         } else {
             $root['info'] = $result['msg'];
         }
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Beispiel #10
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/model/user.php";
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     $type = strim($GLOBALS['request']['type']);
     //0:消费者评价;1:消费统计
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $page = intval($GLOBALS['request']['page']);
         if ($page == 0) {
             $page = 1;
         }
         $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
         if ($type == 1) {
             $sql = "select DISTINCT d.id,d.begin_time,d.current_price,d.sub_name,d.name,d.img from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where d.is_shop in (0,2) and l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id . " order by d.id desc limit " . $limit;
         } else {
             $sql = "select DISTINCT d.id,d.begin_time,d.current_price,d.sub_name,d.name,d.img from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where d.is_shop = 0 and l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id . " order by d.id desc limit " . $limit;
         }
         //print_r($biz_user);
         //echo $sql; exit;
         $deal_list = $GLOBALS['db']->getAll($sql);
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['begin_time_format'] = to_date($v['begin_time'], 'Y-m-d');
             $deal_list[$k]['current_price_format'] = format_price($v['current_price']);
             //$deal_list[$k]['begin_time_format'] = to_date($v['begin_time'], 'Y-m-d');
             if ($type == 1) {
                 //已售团购券数量
                 $deal_list[$k]['coupon_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon as dc where dc.deal_id = " . $v['id'] . " and dc.is_valid = 1 and dc.is_delete = 0 "));
                 //已消费团购券数量
                 $deal_list[$k]['confirm_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon as dc where dc.deal_id = " . $v['id'] . " and dc.is_valid = 1 and dc.is_delete = 0 and dc.confirm_account <> 0"));
                 $deal_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 160, 160, 0));
                 //$deal_list[$k]['img2'] = get_domain().APP_ROOT;
             } else {
                 //购买点评数量
                 $deal_list[$k]['buy_dp_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1"));
                 //购买点评未读数
                 $deal_list[$k]['buy_dp_no_read_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1 and is_read = 0"));
                 //购买差评数
                 $deal_list[$k]['buy_dp_low_point_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1 and point <= 2"));
                 //星级点评数
                 $deal_list[$k]['star_1'] = 0;
                 $deal_list[$k]['star_2'] = 0;
                 $deal_list[$k]['star_3'] = 0;
                 $deal_list[$k]['star_4'] = 0;
                 $deal_list[$k]['star_5'] = 0;
                 $buy_dp_sum = 0.0;
                 $buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from " . DB_PREFIX . "message where rel_id = " . $v['id'] . " and rel_table = 'deal' and pid = 0 and is_buy = 1 group by point");
                 foreach ($buy_dp_group as $dp_k => $dp_v) {
                     $star = intval($dp_v['point']);
                     if ($star >= 1 && $star <= 5) {
                         $deal_list[$k]['star_' . $star] = $dp_v['num'];
                         $buy_dp_sum += $star * $dp_v['num'];
                     }
                 }
                 //点评平均分
                 $deal_list[$k]['buy_dp_avg'] = round($buy_dp_sum / $deal_list[$k]['buy_dp_count'], 1);
             }
         }
         $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id);
         $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / PAGE_SIZE), "page_size" => PAGE_SIZE);
         if ($deal_list == false || $deal_list == null) {
             $deal_list = array();
         }
         $root['item'] = $deal_list;
         $root['return'] = 1;
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }
Beispiel #11
0
 public function index()
 {
     //file_put_contents("../auto_order.txt",print_r($GLOBALS['request']));
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     $user_qrcode = strim($GLOBALS['request']['user_qrcode']);
     //会员二维码
     $num = intval($GLOBALS['request']['num']);
     //购买数量
     if ($num == 0) {
         $num = 1;
     }
     $deal_id = intval($GLOBALS['request']['deal_id']);
     //购买的商品id
     $money = floatval($GLOBALS['request']['money']);
     //消费总金额;
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         $time = get_gmtime();
         $sql = "select id, user_name, user_qrcode, qrcode_end from " . DB_PREFIX . "user where user_qrcode = '" . $user_qrcode . "' limit 1";
         $user = $GLOBALS['db']->getRow($sql);
         if (!$user) {
             $root['return'] = 0;
             $root['info'] = "会员卡不存在";
             output($root);
         } else {
             if ($user['qrcode_end'] < $time) {
                 $root['return'] = 0;
                 $root['info'] = "会员卡已过期";
                 output($root);
             }
         }
         $sql = "select d.id,d.name,d.sub_name,d.icon, d.buy_type, d.current_price, d.return_score, d.return_qrcode_money from " . DB_PREFIX . "deal as d where d.supplier_id =" . $supplier_id . " and d.id = " . $deal_id;
         $deal = $GLOBALS['db']->getRow($sql);
         if (!$deal) {
             $root['return'] = 0;
             $root['info'] = "商品不存在:" . $deal_id;
             output($root);
         }
         $user_id = $user['id'];
         if ($money == 0) {
             $money = $deal['current_price'] * $num;
         }
         $root['status'] = 1;
         //验证成功
         //开始生成订单
         $now = get_gmtime();
         $order['type'] = 0;
         //普通订单
         $order['user_id'] = $user_id;
         $order['user_name'] = $user['user_name'];
         $order['create_time'] = $now;
         $order['total_price'] = $money;
         //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
         $order['pay_amount'] = $money;
         $order['pay_status'] = 2;
         //线下支付,直接支付成功
         $order['delivery_status'] = 5;
         $order['order_status'] = 0;
         //新单都为零, 等下面的流程同步订单状态
         $order['return_total_score'] = 0;
         //结单后送的积分
         $order['return_total_money'] = $deal['return_qrcode_money'] * $num;
         //结单后送的现金
         $order['memo'] = '会员卡扫描下单,金额为:' . format_price($money);
         $order['deal_total_price'] = $money;
         //团购商品总价
         $order['discount_price'] = 0;
         $order['delivery_fee'] = 0;
         $order['ecv_money'] = 0;
         $order['account_money'] = 0;
         $order['ecv_sn'] = '';
         $order['delivery_id'] = 0;
         //线下支付
         $order['payment_id'] = 0;
         $order['payment_fee'] = 0;
         $order['bank_id'] = 0;
         $order['is_auto_order'] = 1;
         //门店自主下单标识
         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);
         if ($order_id > 0) {
             $deal_id = intval($deal['id']);
             $goods_item = array();
             $goods_item['deal_id'] = $deal_id;
             $goods_item['number'] = $num;
             $goods_item['unit_price'] = $money;
             $goods_item['total_price'] = $money;
             $goods_item['name'] = $deal['name'];
             $goods_item['sub_name'] = $deal['sub_name'];
             $goods_item['attr'] = '0';
             $goods_item['verify_code'] = md5($deal_id . "_0");
             $goods_item['order_id'] = $order_id;
             $goods_item['return_score'] = $deal['return_score'];
             $goods_item['return_total_score'] = $order['return_total_score'];
             $goods_item['return_money'] = $deal['return_qrcode_money'];
             $goods_item['return_total_money'] = $order['return_total_money'];
             $goods_item['buy_type'] = $deal['buy_type'];
             $goods_item['attr_str'] = '';
             //$deal['attr_str'];
             $goods_item['balance_unit_price'] = 0;
             $goods_item['balance_total_price'] = 0;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $goods_item, 'INSERT', '', 'SILENT');
             if ($order['return_total_money'] != 0) {
                 $msg = sprintf($GLOBALS['lang']['ORDER_RETURN_MONEY'], $order['order_sn']);
                 modify_account(array('money' => $order['return_total_money'], 'score' => 0), $order['user_id'], $msg);
             }
             if ($order['return_total_score'] != 0) {
                 $msg = sprintf($GLOBALS['lang']['ORDER_RETURN_SCORE'], $order['order_sn']);
                 modify_account(array('money' => 0, 'score' => $order['return_total_score']), $order['user_id'], $msg);
             }
             $sql = "update " . DB_PREFIX . "deal set buy_count = buy_count + " . $num . ",user_count = user_count + 1 where id=" . $deal_id;
             $GLOBALS['db']->query($sql);
             //增加商品的发货量
         }
         $root['order_id'] = $order_id;
         $root['info'] = '交易完成,共获得:' . format_price($order['return_total_money']) . " 返利";
     } else {
         $root['user_login_status'] = 0;
         $root['info'] = '请先登陆';
     }
     output($root);
 }
Beispiel #12
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     $root = array();
     $email = strim($GLOBALS['request']['biz_email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['biz_pwd']);
     //密码
     $user_qrcode = strim($GLOBALS['request']['user_qrcode']);
     //会员二维码
     $page = intval($GLOBALS['request']['page']);
     //分页
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE;
     $keyword = strim($GLOBALS['request']['keyword']);
     //查询关键字
     //检查用户,用户密码
     $biz_user = biz_check($email, $pwd);
     $supplier_id = intval($biz_user['supplier_id']);
     if ($supplier_id > 0) {
         $root['user_login_status'] = 1;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $time = get_gmtime();
         $sql = "select id, user_name, user_qrcode, qrcode_end from " . DB_PREFIX . "user where user_qrcode = '" . $user_qrcode . "' limit 1";
         $user = $GLOBALS['db']->getRow($sql);
         if (!$user) {
             $root['return'] = 0;
             $root['info'] = "会员卡不存在";
             output($root);
         } else {
             if ($user['qrcode_end'] < $time) {
                 $root['return'] = 0;
                 $root['info'] = "会员卡已过期";
                 output($root);
             }
         }
         $root['user_id'] = $user['id'];
         $root['user_qrcode'] = $user['user_qrcode'];
         $root['user_name'] = $user['user_name'];
         $sql = "select d.id,d.name,d.sub_name,d.icon, d.current_price,d.return_qrcode_money from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where ";
         $count_sql = "select count(d.id) from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where ";
         $condition = " d.is_shop in (0,1) and l.location_id in (" . implode(",", $biz_user['location_ids']) . ") and d.is_delete = 0 and d.supplier_id = " . $supplier_id . " and d.buy_type = 0 and d.publish_wait = 0  ";
         $condition .= " and ((" . $time . ">= d.begin_time or d.begin_time = 0) and (" . $time . "< d.end_time or d.end_time = 0) and d.buy_status <> 2) ";
         //$condition .= " and d.return_qrcode_money > 0";
         if ($keyword) {
             $kws_div = div_str($keyword);
             foreach ($kws_div as $k => $item) {
                 $kws[$k] = str_to_unicode_string($item);
             }
             $ukeyword = implode(" ", $kws);
             $condition .= " and (match(d.tag_match,d.name_match,d.locate_match,d.deal_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or d.name like '%" . $keyword . "%') ";
         }
         $sql .= $condition . " order by d.id desc limit " . $limit;
         //$root['sql'] = $sql;
         $count_sql .= $condition;
         //print_r($biz_user);
         //echo $sql; exit;
         $deal_list = $GLOBALS['db']->getAll($sql);
         foreach ($deal_list as $k => $v) {
             $deal_list[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 360, 288, 0));
             $deal_list[$k]['current_price_format'] = format_price($v['current_price']);
             $deal_list[$k]['return_qrcode_money_format'] = format_price($v['return_qrcode_money']);
             $deal_list[$k]['allow_edit_total_money'] = 1;
             //允许下单时,直接编辑商品总价
         }
         $deal_count = $GLOBALS['db']->getOne($count_sql);
         $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / PAGE_SIZE), "page_size" => PAGE_SIZE);
         if ($deal_list == false || $deal_list == null) {
             $deal_list = array();
         }
         $root['item'] = $deal_list;
         $root['return'] = 1;
         $root['info'] = "商品列表";
     } else {
         $root['return'] = 0;
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         $root['info'] = "商户不存在或密码错误";
     }
     output($root);
 }