public function get_index() { //echo md5('qieyou');exit; f61e83b9c803be5003ceddacfc6010ba $name = input_mobilenum($this->input->get('name'), '1004'); $password = $this->input->get('password'); $device = $this->input->get('device'); $device_id = $this->input->get('device_id'); if (empty($password)) { response_msg('1002'); } $user = $this->model->get_user_by_name($name); if (!$user) { response_msg('1003'); } $password = md5($password . $user['salt']); if ($user['user_pass'] != $password) { response_msg('1002'); } if ($user['state'] == 'locked') { response_msg('1006'); } $user['inn_id'] = $this->model->get_user_inn_by_id($user['user_id']); if (!$user['inn_id']) { response_msg('1006'); } $data['token'] = $this->model->create_token($user); $data['role'] = $user['role']; $data['state'] = $user['state']; // $this->user_model->update_login_info($user); response_data($data); }
/** * 忘记密码短信接口 **/ public function forgotPassSMS() { $mobile = input_mobilenum($this->input->post('mobile'), '5001'); $rs = $this->model->get_user_auth_by_mobile($mobile, TRUE); if (!$rs) { response_code('4005'); } $mobile_cache = $this->model->check_mobile_send($mobile); //缓存取数据 if ($mobile_cache && $mobile_cache['sms_sendtime'] < TIME_NOW - 60) { response_code('5008'); } $mobile_identify = make_mobile_identify_code(); $current = array('check_mobile' => $mobile, 'sms_sendtime' => TIME_NOW); $this->set_current_data($current); $mobile_cache = array('mobile_identify' => $mobile_identify, 'sms_sendtime' => TIME_NOW); $this->model->save_mobile_identify($mobile, $mobile_cache); $message = array('type' => 'forgotUser', 'mobile' => $mobile, 'param' => array($mobile_identify, '5')); $rs = $this->sendSMS($message); $rs = json_decode($rs, TRUE); if (isset($rs['respCode'])) { log_message('ERROR', json_encode($rs)); if ($rs['respCode'] == '105122') { response_row(array('code' => '-1', 'msg' => '同一手机每天只能发送8条短信')); } } response_code('1'); }
public function submit() { //下单步骤 //1、验证商品id 验证商品数量 //2、验证用户登录状态 登录则通过商品需求信息验证用户信息 否则进入注册用户阶段 将新注册的用户与相关信息绑定 //3、生成订单阶段 (商品信息 用户id 放入model) //4、返回订单号 $product_id = input_int($this->input->post('pid'), 1, FALSE, FALSE, '2001'); $count = input_int($this->input->post('count'), 1, FALSE, FALSE, '2015'); $product = $this->model->get_product_by_product_id($product_id, TRUE); if (!$product) { response_code('2001'); } if ($product['state'] == 'N' || $product['state'] == 'D' || $product['tuan_end_time'] < TIME_NOW) { response_code('2008'); } if ($product['quantity'] < $count) { response_code('2009'); } $user_id = $this->get_user_id(); $address = array(); $identify = array(); if (!$user_id) { $regName = input_mobilenum($this->input->post('mobile'), '5001'); $regIdentify = input_int($this->input->post('identify'), 1000, 9999, FALSE, '5002'); /* $mobile = $this->get_current_data('check_mobile'); //待修正 $mobile_identify = $this->get_current_data('mobile_identify'); if($mobile != $regName || $mobile_identify != $regIdentify) //手机号 验证码验证 { response_code('5002'); }*/ $mobile = $regName; if ($product['is_express']) { $address = $this->check_user_data('address'); } else { if ($product['category'] == '7') { $identify = $this->check_user_data('identify'); } } //验证完商品之后 开始注册用户 $user_id = $this->model->reg_user($mobile); if (!$user_id) { response_code('5002'); } $session = array('user_id' => $user_id, 'user_name' => $mobile, 'nick_name' => '手机用户'); // $token = $this->create_token($session); // 完成登录 判断是否需要写入 联系表 if ($address) { $address['user_id'] = $user_id; $address['create_time'] = TIME_NOW; $address['mobile'] = $mobile; $address['is_default'] = '1'; $address_id = $this->model->insert($address, 'user_address'); } else { if ($identify) { $identify['user_id'] = $user_id; $identify['create_time'] = TIME_NOW; $identify['is_default'] = '1'; $identify_id = $this->model->insert($identify, 'user_identify'); } } } else { if ($product['is_express']) { $address_id = input_int($this->input->post('address_id'), 1, FALSE, FALSE, '3002'); $address = $this->model->check_user_address($user_id, $address_id); if (!$address) { response_code('3002'); } } else { if ($product['category'] == '7') { $identify_id = input_int($this->input->post('identify_id'), 0, FALSE, FALSE, '3003'); $identify = $this->model->check_user_identify($user_id, $identify_id); if (!$identify) { response_code('3003'); } } } $user = $this->model->get_user_detail($user_id); $mobile = $user['user_mobile']; if (!$mobile) { response_code('5011'); } } //信息验证完毕 开始订单流程 $partner = array(); //用于存储订单附加信息 如收货地址 数量 姓名等 $order['telephone'] = $mobile; if (!empty($address['real_name'])) { $order['contact'] = $address['real_name']; $order['telephone'] = $address['mobile']; $partner = $address; $partner['class'] = 'address'; } else { if (!empty($identify['real_name'])) { $order['contact'] = $identify['real_name']; $partner = $identify; $partner['class'] = 'identify'; } } $order['user_id'] = $user_id; $order['inn_id'] = $product['inn_id']; $order['total'] = $count * $product['price']; $partner['count'] = $count; $partner['id'] = $user_id; //C端所有商品为团购商品 不考虑商户代售 if ($product['is_qieyou']) { $order['inns_profit'] = 0; $order['agent_commission'] = 0; } else { $order['inns_profit'] = $product['purchase_price'] * $count; $order['agent_commission'] = 0; } $order['profit'] = $order['total'] - $order['agent_commission'] - $order['inns_profit']; $rs = $this->model->user_submit_order($order, $product, $partner); if ($rs) { response_json('1', $rs); } response_code('3007'); }
private function check_user_data($type) { if ($type == 'address') { $address = array(); $address['real_name'] = check_empty(trimall(strip_tags($this->input->post('real_name'))), FALSE, '1014'); $address['mobile'] = input_mobilenum($this->input->post('mobile'), '5001'); $address['location_id'] = input_int($this->input->post('local_id'), 100000, 1000000, FALSE, '1015'); $address['address'] = check_empty(trimall(strip_tags($this->input->post('address'))), FALSE, '1016'); $local = check_empty($this->model->get_local_info($address['location_id']), FALSE, '1015'); $address['location'] = $local['sheng']['name'] . $local['shi']['name'] . $local['city']['name']; return $address; } else { if ($type == 'identify') { $identify = array(); $identify['real_name'] = check_empty(trimall(strip_tags($this->input->post('real_name'))), FALSE, '1014'); $identify['idcard'] = input_identity_number($this->input->post('idcard'), '1019'); return $identify; } else { response_code('4001'); } } }
private function check_inn_info() { $innInfo = array(); $innInfo['inn_name'] = check_empty(trimall(strip_tags($this->input->post('inn_name', TRUE))), FALSE, '1010'); $innInfo['dest_id'] = input_int($this->input->post('dest_id'), 1, FALSE, FALSE, '1011'); $innInfo['local_id'] = input_int($this->input->post('local_id'), 1, FALSE, FALSE, '1012'); $profit = check_empty($this->input->post('profit'), FALSE, '1013'); $innInfo['profit'] = sprintf("%.2f", $profit); if ($innInfo['profit'] < 0 || $innInfo['profit'] > 100) { response_code('1013'); } $innInfo['inner_contacts'] = check_empty(trimall(strip_tags($this->input->post('inner_contacts'))), FALSE, '1014'); $innInfo['inner_moblie_number'] = input_mobilenum($this->input->post('inner_moblie_number'), '1015'); //默认为用户账号(手机号) $bdlon = number_format(check_empty($this->input->post('bdlon'), FALSE, '1016'), 7, '.', ""); $bdlat = number_format(check_empty($this->input->post('bdlat'), FALSE, '1016'), 7, '.', ""); $gps = BD09LLtoWGS84($bdlon, $bdlat); $innInfo['lon'] = $gps[0]; $innInfo['lat'] = $gps[1]; $innInfo['bdgps'] = $bdlon . ',' . $bdlat; /* $innInfo['bank_info'] = check_empty(trimall(strip_tags($this->input->post('bank_info'))),FALSE,'1017'); $innInfo['bank_account_no'] = input_num(trimall($this->input->post('bank_account_no')),FALSE,FALSE,FALSE,'1018'); $innInfo['bank_account_no'] = check_luhn($innInfo['bank_account_no'],'1018'); $innInfo['bank_account_name'] = check_empty(trimall(strip_tags($this->input->post('bank_account_name'))),FALSE,'1019'); */ $innInfo['bank_info'] = $this->input->post('bank_info', TRUE); $innInfo['bank_account_no'] = $this->input->post('bank_account_no', TRUE); $innInfo['bank_account_name'] = $this->input->post('bank_account_name', TRUE); $innInfo['inner_telephone'] = check_empty(trimall(strip_tags($this->input->post('inner_telephone'))), ''); $innInfo['inn_address'] = check_empty(trimall(strip_tags($this->input->post('inn_address'))), FALSE, '1020'); return $innInfo; }
private function check_inn_info_value() { $inn_head = $this->input->post('inn_head', TRUE); $features = $this->input->post('inn_features', TRUE); $inner_contacts = $this->input->post('inn_contacts', TRUE); $inner_moblie_number = $this->input->post('inn_contacts_mobile', TRUE); $inner_telephone = $this->input->post('inn_telephone', TRUE); $inn_summary = $this->input->post('inn_summary', TRUE); $inn_address = $this->input->post('inn_address', TRUE); $inn_info = array(); if ($inn_head) { $inn_info['inn_head'] = $inn_head; } if ($features) { $inn_info['features'] = $features; } if ($inner_contacts) { $inn_info['inner_contacts'] = $inner_contacts; } if ($inner_moblie_number) { $inn_info['inner_moblie_number'] = input_mobilenum($inner_moblie_number, '3006'); } if ($inner_telephone) { $inn_info['inner_telephone'] = $inner_telephone; } if ($inn_summary) { $inn_info['inn_summary'] = $inn_summary; } if ($inn_address) { $inn_info['inn_address'] = $inn_address; } return $inn_info; }
public function checkusername() { $user_mobile = input_mobilenum($this->input->post('admins'), '1004'); $user = $this->model->get_user_by_mobile($user_mobile); if (!$user) { $this->_echoJson(false); } else { $this->_echoJson(true); } }
public function submitOrder() { $pid = input_int($this->input->post('pid'), 1, FALSE, FALSE, '2008'); $count = input_int($this->input->post('count'), 1, FALSE, FALSE, '2008'); $product = $this->model->get_product_detail_by_product_id($pid); if (!$product) { response_msg('2009'); } if (!$product['sale_license'] || $product['state'] == 'N' || $product['state'] == 'D' || $product['quantity'] < $count) { response_msg('3009'); } if ($product['tuan_end_time'] < $_SERVER['REQUEST_TIME']) { response_msg('3010'); } $partner['id'] = input_int($this->input->post('pn_id'), 1, FALSE, 0); $partner['name'] = input_empty($this->input->post('pn_name'), '3005'); $partner['mobile'] = input_mobilenum($this->input->post('pn_mobile'), '3006'); if ($product['category'] == '7') { $partner['identity_no'] = input_identity_number($this->input->post('pf_identity_no'), '3013'); } $partner['count'] = $count; $order['user_id'] = $this->token['user_id']; $order['contact'] = $partner['name']; $order['telephone'] = $partner['mobile']; $order['inn_id'] = $product['inn_id']; $order['seller_inn'] = $product['inn_id'] == $this->token['inn_id'] ? 0 : $this->token['inn_id']; $order['total'] = $count * $product['price']; //且游收益计算 :如果是且游的商品 看是否有代售 代售则分配佣金 price-agent * count 不是且游商品看分佣比例 if ($product['is_qieyou']) { $order['inns_profit'] = 0; $order['agent_commission'] = $order['seller_inn'] ? $product['agent'] * $count : 0; } else { if ($product['state'] == 'T') { if ($product['inn_id'] == $this->token['inn_id']) { $order['inns_profit'] = ($product['purchase_price'] + $product['agent']) * $count; $order['agent_commission'] = 0; } else { $order['inns_profit'] = $product['purchase_price'] * $count; $order['agent_commission'] = $product['agent'] * $count; } } else { $order['inns_profit'] = $order['total'] * $product['profit'] / 100; $order['agent_commission'] = 0; } } $order['profit'] = $order['total'] - $order['agent_commission'] - $order['inns_profit']; // 拼音转换 $this->load->library('spell'); $spell = new spell(); $order['spell'] = $spell->getAllPY(iconv('utf-8', 'gb2312', $order['user_name']), ' '); $rs = $this->model->user_submit_order($order, $product, $partner); if ($rs) { $rs = array('code' => '1', 'msg' => $rs); response_data($rs); } response_msg('3007'); }