我遇到的问题是,当发送数据失败而不是转到主页并再次发送数据时,请在函数内调用相同的函数。我将在下面发布我的代码:
CODE:
function send_order($order,$wcustid,$customer_address_id) { // function to call
$this->load->model("order_product_m");
$msg='';
$order_ref = $order[0]->order_no;
$payment_method='payment';
$currency='currency';
$currency_rate='1.00';
//get shippingn method
$shipping=$this->order_m->getShippingMethod($order[0]->shipping_id);
$ship_method = 'Delivered';
$ship_amount = $shipping[0]->amount;
$addOrderHeaderToWarehouse = $this->BLWP_CreateOrderHeader($wcustid, $customer_address_id, $order_ref, $ship_method,$ship_amount,$payment_method, $currency, $currency_rate);
$status_ord_header = explode("=", $addOrderHeaderToWarehouse[1]);
if(strpos($addOrderHeaderToWarehouse[1], 'OK')== true) {
$ord = explode("=", $addOrderHeaderToWarehouse[3]);
$warehouseOredrId=$ord[1];
$w_ordid=(int)$warehouseOredrId;
$this->order_m->addWwarehouseorder($order[0]->id,$warehouseOredrId); //update order with warehouse id
//update table orders with warehouse order id
//SAVE WAREHOUSE ORDER ID FOR CRM ORDERS
$order_products=$this->order_m->getOrderProducts($order[0]->id);
$orderlineitem=0;
foreach($order_products as $order_product) {
//get warehouse order id from local db
$w_ord_id=$this->order_m->getwarehouseOrderId($order_product->order_id);
$prod=$this->product_m->getProductCode($order_product->product_id);
$product_code = $prod[0]->product_code;
$addorderproduct = $this->BLWP_CreateOrderLine($w_ord_id[0]->warehouse_order_id, $product_code, $order_product->quantity, $order_product->sales_price,'');
if(strpos($addorderproduct[1], 'OK')== true) {
$ordline = explode("=", $addorderproduct[3]);
$w_order_line_id=$ordline[1];
//add order line id for each product in the table order product
$this->order_product_m->update_order_line_id($order_product->order_id,$order_product->product_id,$w_order_line_id);
$orderlineitem=1;
}
else $msg="Order line item not created";
}
//Process order================================
if($orderlineitem==1) {
$process_ord_response = $this->BLWP_ProcessOrder($w_ordid);
$process_order = explode("=", $process_ord_response[3]);
$w_ord_status= $process_order[1];
$this->order_m->addWarehouseorderStatus($order[0]->id,$w_ord_status); //update order with warehouse id/
}
else $msg.="<br>Order not processed";
//============================================
$msg.=" Order sent to warehouse";
}
else
$msg="Order could not be sent to warehouse";
//want to create the retry button here.
return $msg;
}
我想在send_order
$msg= Order could not be sent to warehouse
函数
答案 0 :(得分:0)
如果要调用成员函数,请使用$ this
logging.getLogger("clientIn").error(b"bacd")
Traceback (most recent call last):
File "/usr/lib/python3.4/logging/__init__.py", line 980, in emit
stream.write(msg)
TypeError: 'str' does not support the buffer interface
Call stack:
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/multiprocessing/spawn.py", line 106, in spawn_main
exitcode = _main(fd)
File "/usr/lib/python3.4/multiprocessing/spawn.py", line 119, in _main
return self._bootstrap()
File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/home/serj/work/proxy_mult/proxy/connection_worker_process.py", line 70, in __call__
self._do_work(ipc_socket)
File "/home/serj/work/proxy_mult/proxy/connection_worker_process.py", line 76, in _do_work
logging.getLogger("clientIn").error("bacd")
Message: 'bacd'