/** * 保存订单 * * @param xml string $request * @return xml string */ private function orderSave($request) { try { $item = $request["body"]; if ($item) { $model = new OrderModel(); $item["client"] = $item["clientName"]; $item["qty"] = intval($item["qty"]); $item["weight"] = doubleval($item["weight"]); $item["cubage"] = floatval($item["cubage"]); $item["insuranceValue"] = doubleval($item["insuranceValue"]); $item["getMoney"] = doubleval($item["getMoney"]); $item["receipt"] = intval($item["receipt"]); //有id的更新,否则新增 if ($item["id"]) { $item["id"] = intval($item["id"]); $result = $model->save($item); } else { unset($item["id"]); $result = $model->add($item); } if ($result === false) { return $this->createResult($request["head"]["type"], -1, 'save/add bill error'); } if ($item["id"]) { $id = $item["id"]; } else { $id = $result; } return $this->createResult($request["head"]["type"], 1, 'succeed', 1, "<item>{$id}</item>"); } else { return $this->createResult($request["head"]["type"], -3, 'not a valid action in order save'); } } catch (Exception $e) { return $this->createResult($request["head"]["type"], -1, 'error in order save'); } }
/** * 保存订单 * */ private function saveOrder($data) { try { $headmodel = new OrderModel(); //作废标记处理 if ($data['FILEFUNCTION'] === 'CANCEL') { $sql = "update web_order set status = -1 where orderNo = '" . $data['ECNO'] . "';"; $headmodel->execute($sql); $headmodel->commit(); return true; } //查找已经存在的记录 $find = $headmodel->where("orderNo = '" . $data['ECNO'] . "'")->find(); if ($find['id']) { unset($find['dno']); unset($find['synup']); unset($find['billNo']); unset($find['OrderInfoId']); unset($find['status']); $head = $find; } //订单头文件 $head["departure"] = ''; $head["destination"] = ''; $head["orderNo"] = $data['ECNO']; $head["client"] = '国药控股广州有限公司'; $head["clientName"] = $data['CONSIGNOR'] != 'null' ? $data['CONSIGNOR'] : ''; $head["clientPhone"] = $data['CONPHONE'] != 'null' ? $data['CONPHONE'] : ''; $head["clientAddress"] = $data['CONADDRESS'] != 'null' ? $data['CONADDRESS'] : ''; $head["consignee"] = $data['CUSTOMERNNAME'] != 'null' ? $data['CUSTOMERNNAME'] : ''; $head["consigneeName"] = $data['CUSCONTACT'] != 'null' ? $data['CUSCONTACT'] : ''; $head["consigneePhone"] = $data['CUSNPHONENO'] != 'null' ? $data['CUSNPHONENO'] : ''; $head["consigneeAddress"] = $data['CUSTADDRESS'] != 'null' ? $data['CUSTADDRESS'] : ''; $head["deliverType"] = $data['TMSLOADINGMETHOD'] != 'null' ? $data['TMSLOADINGMETHOD'] : ''; $head["goods"] = '药品'; //$data['GOODSTYPE']!='null'?$data['GOODSTYPE']:''; $head["package"] = ''; $head["qty"] = intval($data['TOTALQUANTITY']); $head["weight"] = 0; $head["addition"] = intval($data['INVOICENUMBER']); $head["notice"] = $data['REQUIREMENT'] != 'null' ? $data['REQUIREMENT'] : ''; $head["transtype"] = $this->authname == 'NGWL01' ? '空运' : '汽运'; //$orderhead->Transporttype; $head["declareValue"] = 0; $head["sendFax"] = 0; $head["requirementDate"] = $data['DELIVETIME']; $head["requirementTime"] = $data['DELIVETIME']; $head["userName"] = $data['CREATER'] != 'null' ? $data['CREATER'] : ''; $head["userId"] = '000032'; $head["company"] = '000032'; $head["billDate"] = $data['CREATETIME']; date_default_timezone_set("Asia/Shanghai"); //额外信息 $head["clientMobile"] = ''; $head["consigneeMobile"] = ''; $head["getMoney"] = 0; $head["cubage"] = 0; $head["package"] = '纸箱'; $head["payType"] = "月结"; $head["insuranceValue"] = 0; $head["signBackType"] = ''; //save head if ($head['id']) { $rs = $headmodel->save($head); } else { $rs = $headmodel->where("not exist")->add($head); } if ($rs === false) { $this->addLog("save head error"); return false; } //save detail $detail['orderNo'] = $data["ECNO"]; $detail['businessNo'] = $data["LEGNO"]; $detail['OUTORDERID'] = $data["OUTORDERID"]; $detail['LOTNO'] = $data["LOTNO"]; $detail['GOODSTYPE'] = $data["GOODSTYPE"]; $detail['TRASNCONDITION'] = $data['TRASNCONDITION']; $detail['PRODUCTTYPE'] = $data["PRODUCTTYPE"]; $detail['QUANTITY'] = intval($data["QUANTITY"]); $detail['QUANTITYUNIT'] = intval($data["QUANTITYUNIT"]); $detail['QUNITNAME'] = $data["QUNITNAME"]; $detail['PACKWEIGHT'] = intval($data["PACKWEIGHT"]); $detail['CARTONQUANITTY'] = intval($data["CARTONQUANITTY"]); $detail['PLACESUPPLYDTLID'] = $data["PLACESUPPLYDTLID"]; $detail['OWNERGOODSID'] = $data["OWNERGOODSID"]; $detailmodel = new OrderdetailModel(); $find = $detailmodel->where("orderNo = '" . $data['ECNO'] . "' and businessNo='" . $data['LEGNO'] . "'")->find(); if (!$find) { $detailmodel->add($detail); } else { if (DEBUG) { $this->debug('duplicate', "found detail" . $detail['orderNo'] . " " . $data['LEGNO']); } } } catch (Exception $e) { $this->addLog("save order Exception error" . $e->getMessage()); return false; } $this->orderno = $data['ECNO']; return true; }