public function fetch_order_by_type_from_completed($value, $type, $tag) { $status_id = fetch_status_id('order_status', 'wait_for_feedback'); $this->db->from('order_list_completed'); if ($tag == 'qt') { $this->db->where('order_status >=', "{$status_id}"); } $this->db->like($type, $value); $query = $this->db->get(); return $query->result(); }
public function waiting_for_sale_goods_list() { $this->enable_search('product_basic'); $this->enable_sort('product_basic'); $sale_statusid = fetch_status_id('sale_status', 'in_stock'); $where = "((lowest_profit = 0 AND sale_status = {$sale_statusid}) OR sale_status=0)"; $waiting_products = $this->waiting_for_perfect_model->waiting_for_perfect($where); $data = array('waiting_products' => $waiting_products); $this->template->write_view('content', 'sale/waiting_for_perfect_goods', $data); $this->template->render(); }
public function print_or_deliver_ship_confirm_day() { $cky_shipping_codes = $this->CI->shipping_code_model->cky_fetch_all_shipping_codes(); $status_id = fetch_status_id('order_status', 'wait_for_shipping_confirmation'); $ship_confirm_day = date("Y-m-d", time()); $this->db->like('print_label_date', $ship_confirm_day); $this->db->where_not_in('is_register', $cky_shipping_codes); $this->db->where('order_status', $status_id); $this->db->from('order_list'); return $this->db->count_all_results(); }
public function waiting_for_stock_goods_list() { $this->enable_search('product_basic'); $this->enable_sort('product_basic'); $sale_statusid = fetch_status_id('sale_status', 'in_stock'); $where = "(((stock_code = 0 OR shelf_code = 0 OR packing_material = 0) AND sale_status = {$sale_statusid}) OR sale_status=0)"; $waiting_products = $this->waiting_for_perfect_model->waiting_for_perfect($where); $data = array('waiting_products' => $waiting_products, 'action' => 'pi'); $this->template->write_view('content', 'sale/waiting_for_perfect_goods', $data); $this->template->render(); }
public function get_all_ebay_order_ids_for_profit($emails) { $status = fetch_status_id('order_status', 'wait_for_assignment'); $this->db->select('id'); $this->db->where_in('to_email', $emails); $this->db->where('trade_fee', 0); $this->db->where('order_status !=', $status); $this->db->limit(3000); $this->db->order_by('input_date', 'DESC'); $query = $this->db->get('order_list'); $result = $query->result(); return $result; }
public function waiting_for_perfect_purchase_goods_list() { $this->enable_search('product_basic'); $this->enable_sort('product_basic'); $user_id = get_current_user_id(); $sale_statusid = fetch_status_id('sale_status', 'in_stock'); $priority = $this->user_model->fetch_user_priority_by_system_code('purchase'); if ($priority == 1) { $where = "((market_model = 0 OR box_height = 0 OR box_length = 0 OR box_width = 0 OR box_contain_number = 0 OR box_total_weight = 0) AND sale_status = {$sale_statusid} AND purchaser_id = {$user_id})"; } else { $where = "((market_model = 0 OR box_height = 0 OR box_length = 0 OR box_width = 0 OR box_contain_number = 0 OR box_total_weight = 0) AND sale_status = {$sale_statusid})"; } $waiting_products = $this->waiting_for_perfect_model->waiting_for_perfect($where); $data = array('waiting_products' => $waiting_products); $this->template->write_view('content', 'sale/waiting_for_perfect_goods', $data); $this->template->render(); }
private function _process_add_order($data) { $order_id = $data->id; $track_code = $this->epacket_model->get_ems_track_number($order_id); if ($track_code) { //return $this->_process_print_label($track_code, $transaction_id, $order_id); $user_name = lang('program'); $wait_for_feedback_status = fetch_status_id('order_status', 'wait_for_feedback'); $remark = $this->order_model->get_sys_remark($order_id); $remark .= sprintf(lang('confirm_shipped_remark'), date('Y-m-d H:i:s'), $user_name); $data1 = array('track_number' => $track_code, 'ship_confirm_date' => date('Y-m-d H:i:s'), 'order_status' => $wait_for_feedback_status, 'sys_remark' => $remark . ' epacket: order status id is ' . $wait_for_feedback_status); $this->order_model->update_order_information($order_id, $data1); $this->epacket_model->save_specification_track_number($track_code, $data->id); $this->get_epacket_specification_print_lable_url($track_code); if ($this->_check_label_exists($track_code)) { $this->print_sku_list($track_code, $order_id); /*标签文件下载成功后才生成清单*/ } return; } //$product_mode = FALSE; $this->CI =& get_instance(); $this->CI->load->config('config_epacket_specification'); $ems_token = $this->CI->config->item('ems_token'); $ems_url = $this->CI->config->item('ems_url'); $ems_label_url = $this->CI->config->item('ems_label_url'); $version = $this->CI->config->item('version'); $order_info = array(); $receiver_info = array(); $items = array(); $skus = explode(',', trim($data->sku_str, ',')); $item_ids = explode(',', trim($data->item_id_str, ',')); $item_titles = explode(ITEM_TITLE_SEP, trim($data->item_title_str, ',')); $qties = explode(',', trim($data->qty_str, ',')); $i = 0; $volweight = 0; $item_count = count($skus); /*$price = ( ! empty($data->gross)) ? ($data->gross / 2) : ($data->net / 2); $price = $price / $item_count;*/ $price = 5; $weight = $data->ship_weight / 1000 / $item_count; if (empty($weight)) { $weight = 0.05; } echo "weight:" . $weight . "\n"; foreach ($skus as $sku) { $item = array(); $item_title = $item_titles[$i]; $qty = $qties[$i]; if ($this->order_model->check_exists('product_makeup_sku', array('makeup_sku' => $sku))) { $makeup_sku = $this->product_makeup_sku_model->fetch_makeup_sku_by_sku($sku); $sku_arr = explode(',', $makeup_sku->sku); $qty_arr = explode(',', $makeup_sku->qty); foreach ($sku_arr as $key => $value) { $count_sku = (int) $qty * $qty_arr[$key]; $product = $this->epacket_model->get_product_info_for_epacket($value); $item['cnname'] = $product->name_cn; $item['enname'] = "Accessories "; $item['count'] = $count_sku; $item['weight'] = (int) $weight; $item['delcarevalue'] = price($price); $items[] = $item; $volweight += $weight; } } else { $product = $this->epacket_model->get_product_info_for_epacket($sku); $item['cnname'] = $product->name_cn; $item['enname'] = "Accessories "; $item['count'] = $qty; $item['weight'] = (int) $weight; $item['delcarevalue'] = price($price); $items[] = $item; $volweight += $weight; } $i++; } $datetime = date('Y-m-d\\TH:i:s\\Z'); $end_time = date('Y-m-d\\TH:i:s\\Z', mktime(substr($datetime, 11, 2), substr($datetime, 14, 2), substr($datetime, 17, 2), substr($datetime, 5, 2), substr($datetime, 8, 2) + 4, substr($datetime, 0, 4))); $ems_token_array = explode('_', trim($ems_token)); $order_info['orderid'] = str_pad($data->id, 4, '0', STR_PAD_LEFT); $order_info['customercode'] = $ems_token_array[0]; $order_info['volweight'] = (int) $volweight; $order_info['startdate'] = $datetime; $order_info['enddate'] = $end_time; $street = ''; $street = empty($street) ? $data->address_line_1 : $street . ', ' . $data->address_line_1; if (!empty($data->address_line_2)) { $street = $street . ',' . $data->address_line_2; } $receiver_info['receiver_name'] = htmlspecialchars($data->name); $receiver_info['receiver_postcode'] = $data->zip_code ? trim($data->zip_code) : ' '; $receiver_info['receiver_phone'] = $data->contact_phone_number ? $data->contact_phone_number : ' '; $receiver_info['receiver_mobile'] = $data->contact_phone_number ? $data->contact_phone_number : ' '; $receiver_info['receiver_country'] = get_country_code($data->country); $receiver_info['receiver_province'] = $data->state_province ? $data->state_province : ' '; $receiver_info['receiver_city'] = $data->town_city; $receiver_info['receiver_county'] = ''; $receiver_info['receiver_street'] = $street; $xml = epacket_specification_order($order_info, $this->sender_info, $receiver_info, $this->collect_info, $items); $order_gateway_url = $ems_url . "order/"; var_dump($order_gateway_url); echo "\n"; var_dump($xml); echo "\n"; //echo "<pre>";var_dump($xml);echo "</pre>";die("***********************"); //var_dump(utf8_encode($xml)); //die($order_gateway_url); /* 开始提交xml了 */ //$xml=utf8_encode($xml); $ch = curl_init(); $header[] = "Content-type: text/xml"; //定义content-type为xml $header[] = "version: " . $version; $header[] = "authenticate: " . $ems_token; curl_setopt($ch, CURLOPT_URL, $order_gateway_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); $response = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); } curl_close($ch); var_dump($response); $arr = parseNamespaceXml($response); //echo "<br>**********************<br>"; //print_r($arr); $user_name = lang('program'); $track_code = isset($arr['mailnum']) ? $arr['mailnum'] : ''; $wait_for_feedback_status = fetch_status_id('order_status', 'wait_for_feedback'); $remark = $this->order_model->get_sys_remark($order_id); $remark .= sprintf(lang('confirm_shipped_remark'), date('Y-m-d H:i:s'), $user_name); $data1 = array('track_number' => $track_code, 'ship_confirm_date' => date('Y-m-d H:i:s'), 'order_status' => $wait_for_feedback_status, 'sys_remark' => $remark . ' epacket: order status id is ' . $wait_for_feedback_status); $this->order_model->update_order_information($order_id, $data1); $this->epacket_model->save_specification_track_number($track_code, $data->id); $this->get_epacket_specification_print_lable_url($track_code); if ($this->_check_label_exists($track_code)) { $this->print_sku_list($track_code, $order_id); /*标签文件下载成功后才生成清单*/ } }
public function by_sku() { $this->set_2column('sidebar_statistics_order'); $input_user = NULL; if (!$this->input->is_post()) { $begin_time = date("Y-m-d H:i:s", strtotime('-1 month')); $end_time = date("Y-m-d H:i:s"); } else { $begin_time = $this->input->post('begin_time'); $end_time = $this->input->post('end_time'); $input_user = $this->input->post('input_user'); } $input_users = $this->order_model->fetch_input_user(); $status_id = fetch_status_id('order_status', 'received_partial_refunded'); $skus_obj = $this->solr_statistics_model->fetch_total_count_of_sku('skus', $begin_time, $end_time, $input_user); $skus = $skus_obj['facet']; $return_skus_obj = $this->solr_statistics_model->fetch_return_count_of_sku('skus', $status_id, $begin_time, $end_time, $input_user); $return_skus = $return_skus_obj['facet']; $data = array('input_users' => $input_users, 'current_user' => $input_user, 'begin_time' => $begin_time, 'end_time' => $end_time, 'return_skus' => $return_skus, 'skus' => $skus); $this->template->write_view('content', 'order/receive_partial_refunded/by_sku', $data); $this->template->add_js('static/js/sorttable.js'); $this->template->render(); }
$confirm .= '<br/><br/>' . anchor('#', lang('close_order'), array('onclick' => "return close_order(this, '{$close_url}', {$order->id}, {$last_order});")); $confirm .= '<br/><br/><a href=' . $split_url . ' target=_blank>' . lang('split_order') . '</a>'; $confirm .= '</span>'; $row[] = $confirm; $data[] = $row; } echo block_header(lang('confirm_order')); $options = array(); if (isset($confirm_type) && $confirm_type == 'wait_for_finance_confirmation') { $values = array('wait_for_finance_confirmation', 'finance_holded'); } else { $values = array('wait_for_confirmation', 'holded'); } $type = 'order_status'; foreach ($values as $value) { $key = fetch_status_id($type, $value); $options[$key] = lang($value); } $filters = array(NULL, array('type' => 'input', 'field' => 'id', 'method' => '='), array('type' => 'input', 'field' => 'item_no|buyer_id|from_email|name|country|zip_code'), array('type' => 'input', 'field' => 'item_id_str|invoice_number|sku_str'), array('type' => 'input', 'field' => 'track_number|transaction_id', 'method' => '='), array('type' => 'dropdown', 'field' => 'order_status', 'options' => $options, 'method' => '=')); $config = array('filters' => $filters); echo form_open(); echo $this->block->generate_pagination('order'); echo $this->block->generate_reset_search($config); echo $this->block->generate_table($head, $data, $filters, 'order'); echo form_close(); echo $this->block->generate_check_all(); $batch_confirm_url = site_url('order/regular_order/make_batch_confirmed'); $batch_confirm_order = lang('batch_confirm_order'); if (isset($confirm_type) && $confirm_type == 'wait_for_finance_confirmation') { // $confirm_url = site_url('finance/finance_order/make_batch_confirmed'); $batch_confirm_url = site_url('finance/finance_order/make_batch_confirmed');
public function verify_order_before_print_label($order_id) { if (strpos($_SERVER['SCRIPT_FILENAME'], 'auto_verify_order_after_change.php') === FALSE) { exit; } if (empty($order_id)) { return; } $order = $this->order_model->get_order($order_id); $wait_for_purchase_status = fetch_status_id('order_status', 'wait_for_purchase'); $wait_for_finance_status = fetch_status_id('order_status', 'wait_for_finance_confirmation'); $sys_remark = $order->sys_remark . sprintf(lang('purchase_to_finance_confirmation_note_due_to_profit_rate'), get_current_time(), lang('system')); $skus = explode(',', $order->sku_str); $qties = explode(',', $order->qty_str); $product_price = 0; $shipping_weight = 0; $i = 0; foreach ($skus as $sku) { $qty = $qties[$i]; $i++; $product = $this->product_model->fetch_product_by_sku($sku); $product_price += $product->price * $qty; $shipping_weight += $product->total_weight * $qty; } $order_data = array('item_id_str' => $order->item_id_str, 'gross' => $order->gross, 'net' => $order->net, 'currency' => $order->currency, 'transaction_ids' => $order->transaction_id, 'shipping_code' => $order->is_register, 'price' => $product_price, 'shipping_weight' => $shipping_weight, 'country' => $order->country); $result = $this->_calculate_profit_rate($order_data); if (isset($result['profit_rate'])) { $data = array(); $profit = $result['profit']; $profit_rate = $result['profit_rate']; if ($profit < -1 or $profit_rate < -0.1 or $profit_rate > 0.3) { if ($order->order_status == $wait_for_purchase_status) { $data = array('order_status' => $wait_for_finance_status, 'sys_remark' => $sys_remark); } } $data['profit_rate'] = $result['profit_rate']; $data['shipping_cost'] = $result['shipping_cost']; $data['product_cost_all'] = $result['product_cost']; $data['trade_fee'] = $result['trade_fee']; $data['listing_fee'] = $result['listing_fee']; /* Not activate it currently. * $order_role = $this->_get_order_role($order->sku_str, $order->to_email); $data['stock_user_id'] = $order_role['stock_user_id']; $data['purchaser_id_str'] = $order_role['purchaser_id_str']; $data['developer_id'] = $order_role['developer_id']; $data['saler_id'] = $order_role['saler_id']; */ $this->order_model->update_order_information($order_id, $data); } }
public function by_ship_confirm_user() { $this->set_2column('sidebar_count_statistics'); $input_user = NULL; if (!$this->input->is_post()) { $begin_time = date("Y-m-d H:i:s", strtotime('-1 month')); $end_time = date("Y-m-d H:i:s"); } else { $begin_time = $this->input->post('begin_time'); $end_time = $this->input->post('end_time'); $input_user = $this->input->post('input_user'); } $begin_time = to_utc_format($begin_time); $end_time = to_utc_format($end_time); $input_users = $this->order_model->fetch_input_user(); $ship_users = $this->order_model->fetch_ship_confirm_user(); foreach ($ship_users as $users) { if (empty($users->ship_confirm_user)) { continue; } $ship_user_arr[] = $users->ship_confirm_user; } $status_id = fetch_status_id('order_status', 'closed'); $currencies = array('RMB', 'USD', 'AUD', 'GBP', 'EUR'); foreach ($currencies as $currency) { $total_infos = $this->solr_statistics_model->fetch_total_info_by_ship_confirm_user($currency, $begin_time, $end_time, $input_user, $status_id); $total_datas = empty($total_infos->facets->ship_confirm_user) ? NULL : $total_infos->facets->ship_confirm_user; $total_all_count = empty($total_infos->count) ? 0 : $total_infos->count; $total_all_cost[$currency] = empty($total_infos->sum) ? 0 : $total_infos->sum; foreach ($ship_user_arr as $ship_user) { if (!empty($total_datas->{$ship_user}->count)) { $tmp_count = $total_datas->{$ship_user}->count; } else { $tmp_count = 0; } if (isset($total_count[$ship_user])) { $total_count[$ship_user] += $tmp_count; } else { $total_count[$ship_user] = $tmp_count; } if (empty($total_datas->{$ship_user}->sum)) { $total_cost[$ship_user][$currency] = 0; } else { $total_cost[$ship_user][$currency] = price($total_datas->{$ship_user}->sum); } if (isset($total_to_rmb[$ship_user])) { $total_to_rmb[$ship_user] += $total_cost[$ship_user][$currency] * $this->cur_rates[$currency]; } else { $total_to_rmb[$ship_user] = $total_cost[$ship_user][$currency]; } } } $data = array('input_users' => $input_users, 'current_user' => $input_user, 'begin_time' => $begin_time, 'end_time' => $end_time, 'total_count' => $total_count, 'total_cost' => $total_cost, 'currencies' => $currencies, 'ship_users' => $ship_user_arr, 'rates' => $this->cur_rates); $this->template->write_view('content', 'order/statistics_graph/by_ship_confirm_user', $data); $this->template->add_js('static/js/sorttable.js'); $this->template->render(); }
function do_upload() { $config['upload_path'] = '/tmp/'; $config['allowed_types'] = '*'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('shipping/deliver_management/import_track_number', $error); } else { $data = array('upload_data' => $this->upload->data()); $file_path = $data['upload_data']['full_path']; $before_file_arr = $this->excel->csv_to_array($file_path); $sueecss_counts = 0; $failure_counts = 0; $blank_counts = 0; $number = 1; $output_data = array(); $i = 0; foreach ($before_file_arr as $row) { $i++; //$output_data["$number"] = sprintf(lang('start_number_note'), $number); $data = array(); if ($i == 1) { continue; } if (count($row) < 1) { //$output_data[] = $number.lang('no_data'); $blank_counts++; $number++; continue; } else { $ship_user = $this->get_current_login_name(); $data = array(); $order_id = $row[0]; $order = $this->order_model->get_order($order_id); $order_status = fetch_status_id('order_status', 'wait_for_shipping_confirmation'); $close_status = fetch_status_id('order_status', 'closed'); if ($order->order_status != $order_status || $order->order_status == $close_status || $order->is_register == 'H' || $order->is_register == 'EUB') { $failure_counts++; $number++; continue; } $remark = $order->sys_remark; $remark .= sprintf(lang('confirm_shipped_remark'), date('Y-m-d H:i:s'), $ship_user); $data = array('descript' => $ship_user . 'import shipped!', 'ship_confirm_user' => $ship_user, 'order_status' => $this->order_statuses['wait_for_feedback'], 'ship_confirm_date' => date('Y-m-d H:i:s'), 'sys_remark' => $remark, 'ship_weight' => 0.05); if ($row[1] != '') { $data['track_number'] = $row[1]; } if ($row[2] != '') { $data['ship_weight'] = $row[2]; } $this->ebay_order_model->save_wait_complete_sale($order_id); $this->product_model->update_product_stock_count_by_order_id($order_id); $this->order_model->update_order_information($order_id, $data); $number++; } } /*end foreach*/ } /*end if*/ $output_data["total"] = sprintf(lang('total_count_result'), $number - 1, $sueecss_counts, $failure_counts, $blank_counts); $data_page = array('data' => $output_data); $this->template->write_view('content', 'shipping/deliver_management/success', $data_page); $this->template->render(); }
public function fetch_order_sale_record_count_by_days($last_day, $days) { $closed_id = fetch_status_id('order_status', 'closed'); $where = <<<WHERE order_status != {$closed_id} AND input_date < '{$last_day}' AND input_date >= DATE_SUB('{$last_day}' , INTERVAL {$days} DAY) WHERE; $results = $this->get_result('order_list', 'sku_str,qty_str', $where); $qty = 0; $return_array = array(); foreach ($results as $result) { $skus = explode(',', $result->sku_str); $qtys = explode(',', $result->qty_str); foreach ($skus as $key => $order_sku) { if (isset($return_array[trim($order_sku)])) { $return_array[trim($order_sku)] += $qtys[$key]; } else { $return_array[trim($order_sku)] = $qtys[$key]; } } } return $return_array; }
if (product_can_write('fill_material_heavy')) { $data[] = array(lang('fill_material_heavy') . ' (g)', form_input($config)); } else { if (product_can_read('fill_material_heavy')) { if (empty($product->fill_material_heavy)) { $config['disabled'] = true; } else { $config['readonly'] = true; } $data[] = array(lang('fill_material_heavy') . ' (g)', form_input($config)); } } /** * Product ebay field . */ $in_stock = fetch_status_id('sale_status', 'in_stock'); $options = fetch_statuses('sale_status'); foreach ($options as $key => $value) { $options[$key] = lang($value); } if (product_can_write('sale_status')) { $data[] = array(lang('sale_status'), form_dropdown('sale_status', $options, empty($product->sale_status) ? $in_stock : $product->sale_status)); } else { if (product_can_read('sale_status')) { $data[] = array(lang('sale_status'), !empty($product->sale_status) ? $options[$product->sale_status] : ''); } } $options = fetch_statuses('ban_levels'); $forbidden_level_html = ''; $forbidden_level_arr = array(); foreach (get_forbidden_level_obj($product->id) as $value) {
public function save_split_order() { if ($this->input->is_post()) { $old_item_title_str = $this->input->post('old_item_title_str'); $old_item_id_str = $this->input->post('old_item_id_str'); $old_gross = $this->input->post('old_gross'); $old_net = $this->input->post('old_net'); $old_shipping_cost = $this->input->post('old_shipping_cost'); $old_shipping_way = $this->input->post('old_shipping_way'); $old_sku_arr = $this->input->post('old_sku'); $old_qty_arr = $this->input->post('old_qty'); $old_price_arr = $this->input->post('old_price'); $item_title_str = $this->input->post('item_title_str'); $item_id_str = $this->input->post('item_id_str'); $gross = $this->input->post('gross'); $net = $this->input->post('net'); $shipping_cost = $this->input->post('shipping_cost'); $shipping_way = $this->input->post('shipping_way'); $sku_arr = $this->input->post('sku'); $qty_arr = $this->input->post('qty'); $price_arr = $this->input->post('price'); $old_order_id = $this->input->post('order_id'); } $old_sku_str = ''; $old_qty_str = ''; $old_price_str = ''; $sku_str = ''; $qty_str = ''; $price_str = ''; foreach ($old_sku_arr as $old_sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $old_sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $old_sku_str = $old_sku_str . $old_sku . ','; } } foreach ($old_qty_arr as $old_qty) { if (!is_positive($old_qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $old_qty_str = $old_qty_str . $old_qty . ','; } } foreach ($old_price_arr as $old_price) { $old_price_str = $old_price_str . $old_price . ','; } foreach ($sku_arr as $sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $sku_str = $sku_str . $sku . ','; } } foreach ($qty_arr as $qty) { if (!is_positive($qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $qty_str = $qty_str . $qty . ','; } } foreach ($price_arr as $price) { $price_str = $price_str . $price . ','; } $old_sku_str = substr($old_sku_str, 0, strlen($old_sku_str) - 1); $old_qty_str = substr($old_qty_str, 0, strlen($old_qty_str) - 1); $old_price_str = substr($old_price_str, 0, strlen($old_price_str) - 1); $sku_str = substr($sku_str, 0, strlen($sku_str) - 1); $qty_str = substr($qty_str, 0, strlen($qty_str) - 1); $price_str = substr($price_str, 0, strlen($price_str) - 1); $input_user = $this->get_current_login_name(); $input_date = get_current_time(); $register = $shipping_way; $item_id_arr = explode(',', $item_id_str); $order_status = fetch_status_id('order_status', 'wait_for_confirmation'); $data = $this->order_model->get_order_with_id($old_order_id); $transaction_id = $data->transaction_id; $ebay_id = $data->ebay_id; if ($ebay_id == '') { //$ebay_id= $this->ebay_model->get_ebay_id_by_item_id($item_id_arr[0]); } $item_no = $this->order_model->create_item_no($input_user, date('ymd'), $item_id_arr[0] . 'C', $transaction_id, $register); $item_id = $data->item_id_str; $old_item_no = $data->item_no; $old_sys_remark = $data->sys_remark; /*替换新订单的参数*/ $data->id = ''; $data->item_no = $item_no; $data->sku_str = $sku_str; $data->qty_str = $qty_str; $data->item_price_str = $price_str; $data->item_id_str = $item_id_str; $data->item_title_str = $item_title_str; $data->gross = $gross; $data->net = $net; $data->shipping_cost = $shipping_cost; $data->sys_remark = sprintf(lang('split_order_remark'), get_current_time(), $input_user, $transaction_id, $item_id) . ',' . lang('order_number') . ':' . $old_item_no; $data->is_register = $shipping_way; $data->transaction_id = $transaction_id . '-' . date('is'); $data->is_splited = 1; $data->track_number = ''; //print_r($data); $old_data = array('item_title_str' => $old_item_title_str, 'item_id_str' => $old_item_id_str, 'gross' => $old_gross, 'net' => $old_net, 'shipping_cost' => $old_shipping_cost, 'item_title_str' => $old_price_str, 'is_register' => $old_shipping_way, 'sku_str' => $old_sku_str, 'qty_str' => $old_qty_str, 'sys_remark' => $old_sys_remark . ';' . sprintf(lang('split_by_label_remark'), get_current_time(), $input_user)); //print_r($old_data); try { $new_order_id = $this->order_model->add_split_order($data); $this->order_model->update_order_information($old_order_id, $old_data); echo $this->create_json(1, lang('order_saved')); } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } }
public function auto_get_epacket_track_number() { $wait_for_feedback_id = fetch_status_id('order_status', 'wait_for_feedback'); $sql = <<<SQL SELECT * from order_list WHERE track_number='' AND is_register='H' AND order_status={$wait_for_feedback_id} SQL; $query = $this->db->query($sql); $orders = $query->result(); foreach ($orders as $order) { echo $order->id . "\n"; $this->script->fetch_epacket_track_number(array('order_id' => $order->id)); } }
public function auto_update_order_status() { if (strpos($_SERVER['SCRIPT_FILENAME'], 'auto_abroad_update_order_status.php') === FALSE) { exit; } define('SHIPPED_STATUS', 7); $status = 0; $outstocks = $this->abroad_stock_model->fetch_cky_outstock_by_status($status); $update_status_flag = TRUE; $wait_for_feedback_status = fetch_status_id('order_status', 'wait_for_feedback'); $user_name = 'chukou1'; foreach ($outstocks as $outstock) { $order_sign = $outstock->order_sign; $data = array('order_no' => $order_sign); $result = $this->cky_order->outstore_product_list($data); var_dump($result); if ($result && $result['status']) { $result = $result['result']; foreach ($result as $order_id => $value) { if ($value['state'] == SHIPPED_STATUS) { $shipping_status = $this->order_model->check_order_shipped_or_not($order_id); // not shipped ? if (!$shipping_status) { // update shipping status $datetime = get_current_time(); $order = $this->order_model->get_order($order_id); if (empty($order)) { continue; } $remark = $order->sys_remark; $remark .= sprintf(lang('confirm_shipped_remark'), $datetime, $user_name); $data = array('track_number' => $value['track_number'], 'ship_confirm_user' => $user_name, 'ship_confirm_date' => $datetime, 'order_status' => $wait_for_feedback_status, 'sys_remark' => $remark); echo "updating order {$order_id},\n"; var_dump($data); $this->order_model->update_order_information($order_id, $data); // notify customer by email in backend. $this->events->trigger('shipping_confirmation_after', array('order_id' => $order_id)); } } else { $update_status_flag = FALSE; } } } else { $update_status_flag = FALSE; var_dump($result); } if ($update_status_flag) { $data = array('status' => 1); $this->abroad_stock_model->update_outstock($order_sign, $data); } } }
/** * 仓库部 待审核(退款/重发)订单。 * @return String */ public function stock_return_order_wait_auditing() { $CI =& get_instance(); if (!isset($CI->order_model)) { $CI->load->model('order_model'); } $status = array($this->order_model->fetch_status_id('order_status', 'not_received_partial_refunded'), $this->order_model->fetch_status_id('order_status', 'not_received_full_refunded'), $this->order_model->fetch_status_id('order_status', 'not_received_approved_resending'), $this->order_model->fetch_status_id('order_status', 'received_partial_refunded'), $this->order_model->fetch_status_id('order_status', 'received_full_refunded'), $this->order_model->fetch_status_id('order_status', 'received_resended'), $this->order_model->fetch_status_id('order_status', 'not_shipped_agree_to_refund')); $refund_verify_status = array(fetch_status_id('refund_verify_status', 'waiting_for_verification')); $stock_return_order_wait_auditing_counts = $CI->order_model->get_return_order_by_status_count($status, $refund_verify_status); $txt_html = sprintf($this->format, lang('stock_return_order_wait_auditing'), site_url('order/return_order_auditing/management'), $stock_return_order_wait_auditing_counts); return $txt_html; }
var status_partial_not = '<?php echo fetch_status_id('order_status', 'not_received_apply_for_partial_refund'); ?> '; var status_partial_yes = '<?php echo fetch_status_id('order_status', 'received_apply_for_partial_refund'); ?> '; var status_resending_not = '<?php echo fetch_status_id('order_status', 'not_received_apply_for_resending'); ?> '; var status_resending_yes = '<?php echo fetch_status_id('order_status', 'received_apply_for_resending'); ?> '; if(obj.value == status_full_not || obj.value == status_full_yes) { // $('label_cost').hide(); // $('return_cost').hide(); $('label_is_return').hide(); $('is_return').type = 'hidden'; $('label_clue').hide(); $('label_cost').style.display = ''; $('return_cost').style.display = '';
public function management() { $this->enable_search('retrun_order_management'); $this->enable_sort('retrun_order_management'); $status = array($this->order_model->fetch_status_id('order_status', 'not_received_partial_refunded'), $this->order_model->fetch_status_id('order_status', 'not_received_full_refunded'), $this->order_model->fetch_status_id('order_status', 'not_received_approved_resending'), $this->order_model->fetch_status_id('order_status', 'received_partial_refunded'), $this->order_model->fetch_status_id('order_status', 'received_full_refunded'), $this->order_model->fetch_status_id('order_status', 'received_resended'), $this->order_model->fetch_status_id('order_status', 'not_shipped_agree_to_refund')); $refund_verify_status = array(fetch_status_id('refund_verify_status', 'waiting_for_verification'), fetch_status_id('refund_verify_status', 'operation_verified')); $orders = $this->order_model->get_return_order_by_status($status, $refund_verify_status, 'shipping'); $bad_comment_types = $this->order_model->fetch_all_bad_comment_type(); $refund_status = array('' => lang('all')); $waiting_for_verification_id = $this->order_model->fetch_status_id('refund_verify_status', 'waiting_for_verification'); $operation_verified_id = $this->order_model->fetch_status_id('refund_verify_status', 'operation_verified'); $refund_status["{$waiting_for_verification_id}"] = lang('waiting_for_verification'); $refund_status["{$operation_verified_id}"] = lang('operation_verified'); $data = array('orders' => $orders, 'bad_comment_types' => $bad_comment_types, 'tag' => 'shipping', 'refund_status' => $refund_status); $this->template->write_view('content', 'order/auditing_order/return_order_management', $data); $this->template->add_js('static/js/ajax/order.js'); $this->template->render(); }
public function fetch_on_way_count_purchase_list_by_sku($sku) { $review_state_id = fetch_status_id('review_state', 'completed'); $this->db->select('pos.*, po.item_no, po.id as po_id'); $this->db->from('purchase_order_sku as pos'); $this->db->join('purchase_order as po', 'pos.purchase_order_id = po.id'); $this->db->where('pos.sku', $sku); $this->db->where('po.review_state !=', $review_state_id); $query = $this->db->get(); return $query->result(); }
public function statistics_my_order_count($begin_time, $end_time, $input_user, $statistics_type = 0) { $closed_id = fetch_status_id('order_status', 'closed'); $sql = <<<SQL select * from order_list where input_date>='{$begin_time}' and input_date<='{$end_time}' SQL; if ($input_user) { $sql .= <<<SQL and input_user='******' SQL; } if ($statistics_type == 1) { $sql .= <<<SQL and order_status!='{$closed_id}' SQL; } if ($statistics_type == 2) { $sql .= <<<SQL and order_status='{$closed_id}' SQL; } $sql .= <<<SQL and auction_site_type='mallerp' SQL; //echo $sql; $query = $this->db->query($sql); return $query->result(); }
public function modification_order_status() { $item_no = $this->input->post('item_no'); $order_status = $this->input->post('order_status'); if (empty($item_no)) { echo $this->create_json(0, lang('item_no_is_null')); return; } $order = $this->order_model->get_order_with_item_no($item_no); if (!$order) { $order = $this->order_model->get_order_with_item_no_from_completed($item_no); } if (empty($order)) { echo $this->create_json(0, lang('order_not_exists')); return; } else { $status = $order->order_status; } $not_shipped = fetch_status_id('order_status', 'not_shipped_agree_to_refund'); $ok_arr = array(fetch_status_id('order_status', 'not_received_partial_refunded'), fetch_status_id('order_status', 'not_received_full_refunded'), fetch_status_id('order_status', 'not_received_approved_resending'), fetch_status_id('order_status', 'received_partial_refunded'), fetch_status_id('order_status', 'received_full_refunded'), fetch_status_id('order_status', 'received_approved_resending')); if (empty($status)) { $lang_string = 'NULL'; } else { $status_string = fetch_status_name('order_status', $order->order_status); $lang_string = lang($status_string); } $sys_remark = $order->sys_remark; $sys_remark .= sprintf(lang('modification_by_sys_remark'), get_current_time(), get_current_user_name(), $lang_string, lang('wait_for_feedback')); $data = array('order_status' => fetch_status_id('order_status', 'wait_for_feedback'), 'sys_remark' => $sys_remark); try { if (in_array($status, $ok_arr) || empty($status)) { $this->order_model->update_order_information_by_item_no($item_no, $data); $this->order_model->update_order_information_by_item_no_from_completed($item_no, $data); echo $this->create_json(1, lang('ok')); } else { if ($status == $not_shipped) { $this->order_model->update_order_information_by_item_no($item_no, $data); $this->order_model->update_order_information_by_item_no_from_completed($item_no, $data); echo $this->create_json(1, lang('ok')); } else { echo $this->create_json(0, lang('no_update_this_status_order')); } } } catch (Exception $ex) { echo lang('error_msg'); $this->ajax_failed(); } }
public function can_merge_order($transaction_details, $input_user, $ebay_id, $shipping_code = FALSE) { /*取消合并订单功能---同一个ebayid的才可以合并*/ $transaction_id = $transaction_details['TRANSACTIONID']; $wait_for_shipping_label_status = fetch_status_id('order_status', 'wait_for_shipping_label'); $closed_status = fetch_status_id('order_status', 'closed'); $not_handled_status = fetch_status_id('order_status', 'not_handled'); $wait_for_assignment_status = fetch_status_id('order_status', 'wait_for_assignment'); $epacket_shipping_code = 'H'; $ship_to_street2 = isset($transaction_details["SHIPTOSTREET2"]) ? $transaction_details["SHIPTOSTREET2"] : ''; $this->db->select('order_list.id as o_id'); $this->db->from('order_list'); $this->db->where(array('order_status <=' => $wait_for_shipping_label_status, 'order_status !=' => $closed_status, 'order_status !=' => $not_handled_status, 'order_status !=' => $wait_for_assignment_status, 'name' => $transaction_details["SHIPTONAME"], 'country' => $transaction_details["SHIPTOCOUNTRYNAME"], 'town_city' => $transaction_details["SHIPTOCITY"], 'address_line_1' => $transaction_details["SHIPTOSTREET"], 'address_line_2' => $ship_to_street2, 'is_register !=' => $epacket_shipping_code, 'transaction_id !=' => $transaction_id, 'ebay_id' => $ebay_id)); $query = $this->db->get(); $row = $query->row(); $nowtime_hour = date('H'); //$array_mallerp_time=array('01','02','03','04','05','06','07','08','19','20','21','22','23');//合并订单的时间 return isset($row) && isset($row->o_id) ? $row->o_id : FALSE; }
public function batch_update_purchase_order_status($tag) { $order_count = $this->input->post('order_count'); $user_id = get_current_user_id(); for ($i = 0; $i < $order_count; $i++) { $order_id = $this->input->post('purchase_order_id_' . $i); $completed_id = fetch_status_id('review_state', 'completed'); $pending_skus_obj_arr = $this->purchase_order_model->fetch_skus($order_id); try { if ($tag === 'batch_review') { $data = array('payment_state' => '1'); $this->purchase_order_model->review_reject_order($order_id, $data); // $this->finance_pending(); } else { $data = array('review_state' => $completed_id); $this->purchase_finance_model->update_purchase_order_by_id($order_id, $data); } foreach ($pending_skus_obj_arr as $pending_sku_obj) { $count = on_way_count($pending_sku_obj->s_sku); $data_product = array('on_way_count' => $count); $this->product_model->update_product_by_sku($pending_sku_obj->s_sku, $data_product); } } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } } echo $this->create_json(1, lang('stock_check_or_count_successfully')); }
public function statistic() { $group_id = '120'; if (!$this->input->is_post()) { $begin_time = date("Y-m-d H:i:s", strtotime('-1 month')); $end_time = date("Y-m-d H:i:s"); } else { $begin_time = $this->input->post('begin_time'); $end_time = $this->input->post('end_time'); $group_id = $this->input->post('group'); } $sku_prices = $this->catalog_statistic_model->fetch_sku_price(); $prices = array(); foreach ($sku_prices as $sku_price) { $prices[$sku_price->sku] = $sku_price->price; } $status_id_1 = fetch_status_id('order_status', 'wait_for_feedback'); $status_id_2 = fetch_status_id('order_status', 'received'); $status_ids = array($status_id_1, $status_id_2); $groups_a[] = lang('select'); $groups_b = $this->user_model->fetch_all_groups_by_system_code('order'); $groups = $groups_a + $groups_b; $group_users = array(); $group_users = $this->user_model->fetch_all_users_by_group_id($group_id); $saler_ids = array_flip($group_users); $saler_skus = $this->catalog_statistic_model->fetch_dep_saler_sku($saler_ids); foreach ($saler_skus as $saler_sku) { $sku_salers[$saler_sku->sku] = $saler_sku->saler_id; } $datas = $this->catalog_statistic_model->fetch_order_infos($begin_time, $end_time, $status_ids); $amount = array(); $order_counts = array(); foreach ($datas as $data) { $skus = $data->skus; $qties = $data->qties; $currency = $data->currency; $gross = $data->gross; $net = $data->net; $count = count($skus); $tmp_saler_arr = array(); if ($count <= 1) { if (!isset($sku_salers[$skus[0]])) { continue; } $tmp_saler_id = $sku_salers[$skus[0]]; if ($gross != 0) { if (!isset($amount[$tmp_saler_id])) { $amount[$tmp_saler_id] = $gross * $this->cur_rates[$currency]; } else { $amount[$tmp_saler_id] += $gross * $this->cur_rates[$currency]; } } else { if (!isset($amount[$tmp_saler_id])) { $amount[$tmp_saler_id] = $net * $this->cur_rates[$currency]; } else { $amount[$tmp_saler_id] += $net * $this->cur_rates[$currency]; } } if (!isset($order_counts[$tmp_saler_id])) { $order_counts[$tmp_saler_id] = 0; } $order_counts[$tmp_saler_id]++; } else { $total_price = 0; for ($i = 0; $i < $count; $i++) { if (!isset($prices[$skus[$i]])) { $sku_price = 0; } else { $sku_price = $prices[$skus[$i]]; } $total_price += $sku_price * $qties[$i]; } for ($j = 0; $j < $count; $j++) { if (!isset($sku_salers[$skus[$j]])) { continue; } else { $tmp_saler_id = $sku_salers[$skus[$j]]; } $rates = array(); if ($total_price == 0) { $rates = 0; } else { $rates = $prices[$skus[$j]] * $qties[$j] / $total_price; } if ($gross != 0) { if (!isset($amount[$tmp_saler_id])) { $amount[$tmp_saler_id] = $gross * $rates * $this->cur_rates[$currency]; } else { $amount[$tmp_saler_id] += $gross * $rates * $this->cur_rates[$currency]; } } else { if (!isset($amount[$tmp_saler_id])) { $amount[$tmp_saler_id] = $net * $rates * $this->cur_rates[$currency]; } else { $amount[$tmp_saler_id] += $net * $rates * $this->cur_rates[$currency]; } } if (!isset($order_counts[$tmp_saler_id])) { $order_counts[$tmp_saler_id] = 0; } if (!in_array($tmp_saler_id, $tmp_saler_arr)) { $order_counts[$tmp_saler_id]++; } $tmp_saler_arr[] = $tmp_saler_id; } } } #eof--$datas $data = array('begin_time' => $begin_time, 'end_time' => $end_time, 'groups' => $groups, 'cur_group' => $group_id, 'group_users' => $group_users, 'saler_ids' => $saler_ids, 'amount' => $amount, 'order_counts' => $order_counts); $this->template->write_view('content', 'sale/taobao/sale_statistic', $data); $this->template->render(); }
public function statistic() { $start_second = mktime(); $group_id = ''; if (!$this->input->is_post()) { $begin_time = date("Y-m-d H:i:s", strtotime('-1 month')); $end_time = date("Y-m-d H:i:s"); } else { $begin_time = $this->input->post('begin_time'); $end_time = $this->input->post('end_time'); $group_id = $this->input->post('group'); } $sku_prices = $this->catalog_statistic_model->fetch_sku_price(); $prices = array(); foreach ($sku_prices as $sku_price) { $prices[$sku_price->sku] = $sku_price->price; } $status_id_1 = fetch_status_id('order_status', 'wait_for_feedback'); $status_id_2 = fetch_status_id('order_status', 'received'); $status_ids = array($status_id_1, $status_id_2); $groups = $this->user_model->fetch_all_groups_by_system_code('order'); $group_users = array(); $group_users = $this->user_model->fetch_all_users_by_group_id($group_id); $saler_ids = array_flip($group_users); if (empty($saler_ids)) { $saler_ids = array('71', '121', '100', '188', '189'); } $saler_skus = $this->catalog_statistic_model->fetch_dep_saler_sku($saler_ids); $prices = array(); $salers = array(); foreach ($saler_skus as $saler_sku) { $salers[$saler_sku->saler_id][$saler_sku->sku] = $saler_sku->sku; } $datas_arr = $this->catalog_statistic_model->fetch_order_infos($begin_time, $end_time, $status_ids); //$datas = isset($datas_arr[0])? $datas_arr[0] :NULL; $num = $datas_arr[1]; echo $num . "<br>"; //echo "<pre>"; //print_r($datas); $limit = 4000; $loop = ceil($num / $limit); echo $loop; $amount_arr = array(); $order_counts = array(); for ($i = 0; $i < $loop; $i++) { if ($i > 0) { $datas_arr = array(); $datas_arr = $this->catalog_statistic_model->fetch_order_infos($begin_time, $end_time, $status_ids, $limit); $limit += 4000; } $datas = isset($datas_arr[0]) ? $datas_arr[0] : NULL; //echo $i; foreach ($saler_ids as $saler_name => $saler_id) { $amount = 0; $order_count = 0; if (!isset($salers[$saler_id])) { continue; } if (empty($datas)) { break; } foreach ($datas as $key => $data) { $count = count($data->skus); if ($count <= 1) { foreach ($data->skus as $value) { $sku = $value; } if (in_array($sku, $salers[$saler_id])) { if ($data->gross != 0) { $amount += $data->gross * $this->cur_rates[$data->currency]; } else { $amount += $data->net * $this->cur_rates[$data->currency]; } $order_count++; unset($datas[$key]); } else { continue; } } else { $total_price = 0; for ($j = 0; $j < $count; $j++) { if (!isset($prices[$data->skus[$j]])) { $sku_price = 0; } else { $sku_price = $prices[$data->skus[$j]]; } $total_price += $sku_price * $data->qties[$j]; } foreach ($data->skus as $key2 => $sku) { $rates = array(); if ($total_price == 0) { $rates[$sku] = 0; } else { $rates[$sku] = $prices[$sku] / $total_price; } $k = 0; if (in_array($sku, $salers[$saler_id])) { $k++; if ($data->gross != 0) { $amount += $data->gross * $this->cur_rates[$data->currency] * $rates[$sku]; } else { $amount += $data->net * $this->cur_rates[$data->currency] * $rates[$sku]; } if ($k <= 1) { $order_count++; } unset($datas[$key]->skus[$key2]); unset($datas[$key]->qties[$key2]); sort($data->skus); sort($data->qties); } else { continue; } } } } #--eof foreach $data if (isset($amount_arr[$saler_id])) { $amount_arr[$saler_id] += price($amount); } else { $amount_arr[$saler_id] = price($amount); } //$amount_arr[$saler_id] += price($amount); if (isset($order_counts[$saler_id])) { $order_counts[$saler_id] += $order_count; } else { $order_counts[$saler_id] = $order_count; } //$order_counts[$saler_id] += $order_count; } #--eof foreach $saler_id echo "abc@"; //break; } #eof--for print_r($saler_ids); echo "<hr>"; print_r($order_counts); echo "<hr>"; print_r($amount_arr); $end_second = mktime(); $cost_second = $end_second - $start_second; echo "<br>用时:" . $cost_second . "秒"; $data = array('begin_time' => $begin_time, 'end_time' => $end_time, 'groups' => $groups, 'cur_group' => $group_id, 'group_users' => $group_users, 'saler_ids' => $saler_ids, 'amount_arr' => $amount_arr, 'order_counts' => $order_counts); $this->template->write_view('content', 'sale/taobao/sale_statistic', $data); $this->template->render(); }
public function get_all_orders_for_epacket() { $wait_for_feedback = fetch_status_id('order_status', 'wait_for_feedback'); $wait_for_assignment = fetch_status_id('order_status', 'wait_for_assignment'); $this->db->select('id, transaction_id, item_id_str, to_email, buyer_id, name'); $this->db->where('is_register', 'H'); $this->db->where('ship_confirm_date', ''); $this->db->where('order_status >', $wait_for_assignment); $this->db->where('order_status <', $wait_for_feedback); $this->db->where('to_email !=', ''); $this->db->where('buyer_id !=', ''); $this->db->where('name !=', ''); $this->db->order_by('input_date', 'DESC'); $query = $this->db->get('order_list'); $result = $query->result(); return $result; }
public function fetch_all_on_way_count_products() { $out_of_stock_status = fetch_status_id('sale_status', 'out_of_stock'); $this->db->select('id, sku, price, purchaser_id'); $this->db->from('product_basic'); $this->db->where('on_way_count > ', 0); $this->db->order_by('sale_status', 'DESC'); $query = $this->db->get(); return $query->result(); }