Exemple #1
0
 private function check_user_data($class)
 {
     if ($class == 'address') {
         $address = array();
         $address['real_name'] = check_empty(trimall(strip_tags($this->input->post('real_name'))), FALSE, '1014');
         $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');
         $this->load->model('home_model');
         $local = check_empty($this->home_model->get_local_info($address['location_id']), FALSE, '1015');
         $address['location'] = $local['sheng']['name'] . $local['shi']['name'] . $local['city']['name'];
         return $address;
     } else {
         if ($class == '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');
         }
     }
 }
Exemple #2
0
 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');
 }