Outerrors.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Outerrors extends Start_Controller{
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_outerrors','outerrors');
  8. $this->load->_model("Model_logic_order","logic_order");
  9. $this->load->_model("Model_check",'check');
  10. $this->load->_model("Model_express","express");
  11. $this->load->_model("Model_warehouse","warehouse");
  12. $this->load->_model('Model_whlabel','whlabel');
  13. $this->load->_model("Model_logic_express","logic_express");
  14. $this->load->_model("Model_ck",'ck');
  15. $this->load->_model("Model_shop","shop");
  16. $this->load->_model('Model_specialstock','specialstock');
  17. $this->load->_model('Model_fullorder','fullorder');
  18. $this->load->_model('Model_fullordersmt','fullordersmt');
  19. $this->load->_model('Model_fullordertt','fullordertt');
  20. $this->load->_model('Model_fullorderamz','fullorderamz');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_dhlhz','dhlhz');
  23. $this->load->_model('Model_typeclass','typeclass');
  24. $this->load->_model("Model_logic_ding",'logic_ding');
  25. }
  26. //定义方法的调用规则 获取URI第二段值
  27. public function _remap($arg,$arg_array)
  28. {
  29. if($arg == 'scan')//出库页
  30. {
  31. $this->_scan();
  32. }
  33. else if($arg == 'operate')//出库列表页
  34. {
  35. $this->_operate();
  36. }
  37. else if($arg == 'excel'){
  38. $this->_excel();
  39. }
  40. else
  41. {
  42. $this->_index();
  43. }
  44. }
  45. private function _index()
  46. {
  47. if($this->input->method() === 'post'){
  48. $page = $this->input->post('page',true);
  49. $perpage = $this->input->post('perpage',true);
  50. $number = $this->input->post('number',true);
  51. $timetk = $this->input->post('timetk',true);
  52. $timetj = $this->input->post('timetj',true);
  53. $order_status = $this->input->post('order_status',true);
  54. $timetk = strtotime($timetk);
  55. $timetj = strtotime($timetj);
  56. $where = "";
  57. if($number){
  58. $where .= " number = '$number' ";
  59. }
  60. if(empty($where)){
  61. $where = " scan_time > '$timetk' and scan_time < '$timetj' ";
  62. }else{
  63. $where .= " and scan_time > '$timetk' and scan_time < '$timetj' ";
  64. }
  65. if($order_status >= 0){
  66. $where .= " and order_status = '$order_status' ";
  67. }
  68. //数据排序
  69. $order_str = "order_status asc, id desc";
  70. if(empty($page))
  71. {
  72. $start = 0;
  73. $perpage = 1;
  74. }
  75. else
  76. {
  77. $start = ($page - 1)*$perpage;
  78. }
  79. $list = $this->outerrors->find_all($where,"*",$order_str,$start,$perpage);
  80. $info_list = [];
  81. foreach($list as $k => $v){
  82. $str = "";
  83. $str .= "<p ><b style='font-size:18px !important' data-id='".$v['id']."' data-type='1' data-operate='".$v['dy_operate']."' onclick='dycz(this)'>店员备注</b></p>";
  84. if(!empty($v['dy_status']) ){
  85. $str .= "<p><b style='font-size:18px !important;background-color: #FFC125;color: #000;' data-id='".$v['id']."' data-type='2' data-operate='".$v['ck_operate']."' onclick='dycz(this)'>仓库备注</b></p>";
  86. }
  87. $info_list[] = [
  88. 'id' => $v['id'],
  89. 'scan_time' => date('Y-m-d H:i:s',$v['scan_time']),
  90. 'number' => $v['number'],
  91. 'waybill' => $v['waybill'],
  92. 'order_status'=>empty($v['order_status'])?'未出库':date("Y-m-d H:i:s",$v['library_time'])."出库",
  93. 'dy_status'=>empty($v['dy_status'])?'':$v['dy_operate'],
  94. 'ck_status' => empty($v['ck_status'])?'':$v['ck_operate'],
  95. 'remark'=>empty($v['remark'])?'':$v['remark'],
  96. 'opreate'=>$str
  97. ];
  98. }
  99. $total = $this->outerrors->find_count($where);
  100. $pagenum = ceil($total/$perpage);
  101. $over = $total-($start+$perpage);
  102. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  103. echo json_encode($rows);exit;
  104. }
  105. $this->_Template('outerrors',$this->data);
  106. }
  107. private function _operate(){
  108. if($this->input->method() === 'post'){
  109. $id = $this->input->post('id',true);
  110. $type = $this->input->post('operate_type',true);
  111. $remark = $this->input->post('operate_remark',true);
  112. if($type == 1){
  113. $arr = [
  114. 'dy_status'=>1,
  115. 'dy_operate'=>$remark,
  116. 'dy_time'=>time(),
  117. ];
  118. }else if($type == 2){
  119. $arr = [
  120. 'ck_status'=>1,
  121. 'ck_operate'=>$remark,
  122. 'ck_time'=>time(),
  123. ];
  124. }else{
  125. echo json_encode(['code'=>-1,'msg'=>'执行类型异常']);exit;
  126. }
  127. if($this->outerrors->save($arr,$id)){
  128. echo json_encode(['code'=>1,'msg'=>'操作成功']);exit;
  129. }else{
  130. echo json_encode(['code'=>-1,'msg'=>'操作失败']);exit;
  131. }
  132. }
  133. echo json_encode(['code'=>-1,'msg'=>'参数异常']);exit;
  134. }
  135. //excel 下载
  136. private function _excel(){
  137. if($this->input->method() === 'get'){
  138. $excel = $this->input->get('excel',true);
  139. if($excel == 2){
  140. $number = $this->input->get('number',true);
  141. $timetk = $this->input->get('timetk',true);
  142. $timetj = $this->input->get('timetj',true);
  143. $timetk = strtotime($timetk);
  144. $timetj = strtotime($timetj);
  145. $where = "";
  146. if($number){
  147. $where .= " number = '$number' ";
  148. }
  149. if(empty($where)){
  150. $where = " scan_time > '$timetk' and scan_time < '$timetj' ";
  151. }else{
  152. $where .= " and scan_time > '$timetk' and scan_time < '$timetj' ";
  153. }
  154. $list = $this->outerrors->find_all($where,"*");
  155. $info_list = [];
  156. foreach($list as $k => $v){
  157. $info_list[] = [
  158. 'id' => $v['id'],
  159. 'number' => $v['number'],
  160. 'dy_operate'=>$v['dy_operate'],
  161. 'ck_operate' => $v['ck_operate'],
  162. 'remark'=>empty($v['remark'])?'':$v['remark'],
  163. 'scan_time' => date('Y-m-d H:i:s',$v['scan_time']),
  164. 'dy_time'=>empty($v['dy_time'])?'':date('Y-m-d H:i:s',$v['dy_time']),
  165. 'ck_time'=>empty($v['ck_time'])?'':date('Y-m-d H:i:s',$v['ck_time']),
  166. ];
  167. }
  168. $filename = date("Y-m-d")."扫不出库记录.xls";
  169. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  170. <head>
  171. <!--[if gte mso 9]><xml>
  172. <x:ExcelWorkbook>
  173. <x:ExcelWorksheets>
  174. <x:ExcelWorksheet>
  175. <x:Name>EXCEL</x:Name>
  176. <x:WorksheetOptions>
  177. <x:Print>
  178. <x:ValidPrinterInfo />
  179. </x:Print>
  180. </x:WorksheetOptions>
  181. </x:ExcelWorksheet>
  182. </x:ExcelWorksheets>
  183. </x:ExcelWorkbook>
  184. </xml>
  185. <![endif]-->
  186. </head><body>";
  187. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  188. $str .= "<tr><td>订单编码</td><td>店员操作</td><td>仓库操作</td><td>不能出库原因</td><td>扫描时间</td><td>店员操作时间</td><td>仓库操作时间</td></tr>";
  189. foreach ($info_list as $key=>$value)
  190. {
  191. $str .= "<tr>";
  192. $str .= "<td>". $value['number']. "</td>";
  193. $str .= "<td>". $value['dy_operate']. "</td>";
  194. $str .= "<td>". $value['ck_operate']. "</td>";
  195. $str .= "<td>". $value['remark']. "</td>";
  196. $str .= "<td>". $value['scan_time']. "</td>";
  197. $str .= "<td>". $value['dy_time']. "</td>";
  198. $str .= "<td>". $value['ck_time']. "</td>";
  199. $str .= "</tr>";
  200. }
  201. $str .= "</table></body></html>";
  202. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  203. header( "Content-type: application/octet-stream" );
  204. header( "Content-Disposition: attachment; filename=".$filename );
  205. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  206. header( "Pragma: no-cache" );
  207. header( "Expires: 0" );
  208. exit($str);
  209. }
  210. }
  211. }
  212. //扫描未出库的单子
  213. private function _scan(){
  214. if($this->input->method() === 'post'){
  215. $waybill = $this->input->post('waybill',true);
  216. $weight = $this->input->post('weight',true);
  217. if(empty($waybill)){
  218. echo json_encode(['code'=>-1,'msg'=>'快递单号不能为空']);exit;
  219. }
  220. if(empty($weight)){
  221. echo json_encode(['code'=>-1,'msg'=>'重量不能为空']);exit;
  222. }
  223. $waybill = trim($waybill);
  224. $weight = trim($weight);
  225. if(substr($waybill,0,3) == '788' && substr($waybill,-4,4) == '0430')//Fedex联邦
  226. {
  227. $waybill = substr($waybill,0,12);
  228. }
  229. if(strlen($waybill) == '34')//联邦杭州超长运单截取
  230. {
  231. $str = substr($waybill, 0,3);
  232. if($str == "420"){
  233. $waybill = substr($waybill,12);
  234. }else{
  235. $waybill = substr($waybill,22,12);
  236. }
  237. }
  238. if(!$waybill)
  239. {
  240. echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
  241. }
  242. if(strlen($waybill) == 30)
  243. {
  244. $waybill = substr($waybill, 8);
  245. }
  246. $this->logic_ding->sendToDing("扫描未出库单子的数据".json_encode([
  247. 'waybill' => $waybill,
  248. 'weight' => $weight,
  249. ],JSON_UNESCAPED_UNICODE));
  250. $info = $this->logic_order->getInfo("waybill = '$waybill'");
  251. $outtype = 1;
  252. if(empty($info)){
  253. $outtype = 2;
  254. $info = $this->logic_order->getInfo("number = '$waybill'");
  255. }
  256. if(empty($info)){
  257. $info = $this->logic_order->getInfo("oldwaybill like '%/".$waybill."%'");
  258. if(!empty($info)){
  259. $arr = [
  260. 'number'=>$info['number'],
  261. 'waybill'=>$waybill,//扫描单号
  262. 'plat'=>$info['lv_platform'],
  263. 'shop'=>$info['shop'],
  264. 'remark'=>"无此数据",
  265. 'scan_time'=>time(),
  266. ];
  267. if($this->outerrors->insert($arr)){
  268. echo json_encode(['code'=>1,'msg'=>'扫描成功']);exit;
  269. }else{
  270. echo json_encode(['code'=>-1,'msg'=>'操作失败']);exit;
  271. }
  272. }
  273. }
  274. if(empty($info)){
  275. echo json_encode(['code'=>-1,'msg'=>'未发现和 '.$waybill.' 关联的订单信息']);exit;
  276. }
  277. $r_info = $this->outerrors->find("waybill = '$waybill'");
  278. if(!empty($r_info)){
  279. echo json_encode(['code'=>-1,'msg'=>''.$waybill.' 的相关信息已录入,记录单号为:'.$r_info['number']]);exit;
  280. }
  281. $r = $this->_outerrorinfo($info,$weight,$outtype);
  282. if($r['success']){
  283. echo json_encode(['code'=>-1,'msg'=>$r['msg']]);exit;
  284. }
  285. $arr = [
  286. 'number'=>$info['number'],
  287. 'waybill'=>$waybill,//扫描单号
  288. 'plat'=>$info['lv_platform'],
  289. 'shop'=>$info['shop'],
  290. 'remark'=>$r['msg'],
  291. 'scan_time'=>time(),
  292. ];
  293. if($this->outerrors->insert($arr)){
  294. echo json_encode(['code'=>1,'msg'=>'扫描成功']);exit;
  295. }else{
  296. echo json_encode(['code'=>-1,'msg'=>'操作失败']);exit;
  297. }
  298. }
  299. $this->_Template('outerrors_scan',$this->data);
  300. }
  301. //出库错误的原因返回
  302. private function _outerrorinfo($info,$weight,$outtype){
  303. $time = time();
  304. if(!isset($weight))//测试没问题后可以删
  305. {
  306. $weight = '';
  307. }
  308. $y = $info;
  309. $fullorder_name = $y['lv_platform'];
  310. if($y['mergeid'] == '1')
  311. {
  312. $y = $this->$fullorder_name->read($y['merge']);
  313. }
  314. // 66 云途(欧洲) 67 云途(欧洲)-带保险 如果是欧洲云途 需要检擦出库时间是否超过15天
  315. if(in_array($y['express'],[66,67,82])){
  316. if((time() - $y['printtime']) >= (14*24*3600)){
  317. return array('msg'=>'运单超时!请联系梦体处理!','success'=>false);
  318. //echo json_encode(array('msg'=>'运单超时!请联系梦体处理!','success'=>false));exit;
  319. }
  320. }
  321. // 78 dpd英国 和 79dpd欧盟
  322. if(in_array($y['express'],[78,79,84])){
  323. $r = $this->check->checkOverdue($y['name'],$y['number'],$y['address']);
  324. if(!$r){
  325. return array('msg'=>'同一个客户3天内发货超过2包,不可出库!请联系店员做申报信息修改!'.$y['name']."-".$y['number']."-".$r*1,'success'=>false);
  326. //echo json_encode(array('msg'=>'同一个客户3天内发货超过2包,不可出库!请联系店员做申报信息修改!'.$y['name']."-".$y['number']."-".$r*1,'success'=>false));exit;
  327. }
  328. }
  329. $express = $this->express->read($y['express']);
  330. if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
  331. {
  332. $y['librarynot'] = '客户已取消!';
  333. }
  334. if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
  335. {
  336. return array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false);
  337. //echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
  338. }
  339. if($y['library'] > 1)
  340. {
  341. return array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作出库','success'=>false);
  342. // echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  343. }
  344. if($express['out'] != 3)
  345. {
  346. if($express['out'] != $outtype)
  347. {
  348. $smlx = ($express['out']=='1')?'运单':'发货单';
  349. return array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false);
  350. //echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
  351. }
  352. }
  353. if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
  354. {
  355. $r = $this->logic_express->ydCheckById($y['waybill'],$y['express']);
  356. if(!$r){
  357. return array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'],'success'=>false);
  358. //echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'],'success'=>false));exit;
  359. }
  360. }
  361. if(stripos($weight,',') !== false){
  362. $tmp_arr = explode(",",$weight);
  363. $weight = end($tmp_arr);
  364. $numweight = (float)$weight;
  365. $weight = $numweight."kg";
  366. }
  367. $numweight = str_replace('kg','',$weight);
  368. //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
  369. //还有翔文仓库的 不执行
  370. //源代码是
  371. //所有快递必须称重
  372. //所有快递必须称重 翔文除外
  373. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
  374. if(!in_array($y['express'],[2,8,39,43,44,45,47,48,49,55,61,63,64,65,74,81,83,85])){
  375. if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  376. {
  377. return array('msg'=>'此单需要称重!','success'=>false);
  378. //echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  379. }
  380. $yzweight = explode('.',$numweight);
  381. if($yzweight[0] == '')
  382. {
  383. return array('msg'=>'重量错误,请重新称重!','success'=>false);
  384. //echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  385. }
  386. if(empty($numweight)){
  387. return array('msg'=>'此单需要称重2!','success'=>false);
  388. //echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
  389. }
  390. }
  391. $express_info = $this->express->read($y['express']);
  392. if(empty($express_info)){
  393. return array('msg'=>'快递信息异常,请联系技术!','success'=>false);
  394. }
  395. $weight_limit = $express_info['weight_limit']*1;
  396. if($weight_limit > 0 && $y['type'] != 5){
  397. $yzweight = explode('.',$numweight);
  398. if($yzweight[0] == '')
  399. {
  400. return array('msg'=>'重量错误,请重新称重!','success'=>false);
  401. }
  402. if($numweight < ($y['jweight']/1000)){
  403. return array('msg'=>'重量小于净重,请重新称重!','success'=>false);
  404. }
  405. //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
  406. if(in_array($y['express'],[3,24,42])){
  407. //规定实际重量不允许超过 净重为1kg
  408. if($numweight -($y['jweight']/1000) > 1 )
  409. {
  410. return array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false);
  411. }
  412. }
  413. if($weight_limit < $numweight){
  414. return array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false);
  415. }
  416. }
  417. if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
  418. {
  419. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  420. }
  421. if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
  422. {
  423. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  424. return array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false);
  425. }
  426. if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
  427. {
  428. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  429. }
  430. $this->db->trans_begin();
  431. $warehouse = $this->warehouse->read($y['type']);
  432. $bdck = $warehouse['bdck'];
  433. if($warehouse['zd'] == '1')
  434. {
  435. if($warehouse['bdck'] == '')
  436. {
  437. $this->db->trans_rollback();
  438. return array('msg'=>'仓库设置错误!','success'=>false);
  439. }
  440. $wh = $this->_fout_db($y,$warehouse,$bdck);
  441. if($wh['fh'] == 2)
  442. {
  443. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  444. if($kcyz['t'] == '0')
  445. {
  446. if($kcyz['fpdata'] != '')
  447. {
  448. $x['whlabel'] = $kcyz['whlabel'];
  449. $x['fpdata'] = $kcyz['fpdata'];
  450. $y['whlabel'] = $x['whlabel'];
  451. $this->$fullorder_name->save($x,$y['id']);
  452. }
  453. }
  454. $wh = $this->_fout_db($y,$warehouse,$bdck);
  455. if($wh['fh'] == 2)
  456. {
  457. $this->db->trans_rollback();
  458. return array('msg'=>'库存占用量与实际出库量不符!','success'=>false);
  459. }
  460. }
  461. foreach ($wh['sj'] as $v)
  462. {
  463. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  464. }
  465. }
  466. $shop = $this->shop->read($y['shop']);
  467. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  468. {
  469. $type = $this->typeclass->read($shop['type']);
  470. $y['shoptype'] = $type['title'];
  471. $y['weight'] = $weight;
  472. $d = $this->dhl->get_data_9610($y);
  473. if($d != 1)
  474. {
  475. $this->db->trans_rollback();
  476. return array('msg'=>'9610失败,'.$d,'success'=>false);
  477. }
  478. }
  479. if($fullorder_name == 'fullordersmt')
  480. {
  481. $stt = ($y['waybill']!='')?209:$y['state'];
  482. $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  483. }
  484. else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
  485. {
  486. $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  487. }
  488. else
  489. {
  490. $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  491. }
  492. if($outtype == 2 && $y['printnumber'] > 1)
  493. {
  494. $p = json_encode($post);
  495. $this->db->trans_rollback();
  496. return array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false);
  497. }
  498. $this->db->trans_rollback();
  499. return array('msg'=>'此单允许出库 !!!','success'=>true);
  500. //$this->$fullorder_name->save($post,$y['id']);
  501. }
  502. private function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  503. {
  504. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  505. $cpsl = 0;
  506. $pp = explode('|',trim($y['whlabel'],'|'));
  507. foreach ($pp as $va)
  508. {
  509. $num = explode('-',$va);
  510. if(isset($num[2]))
  511. {
  512. if(stripos($num[2],$warehouse['hz']) !== false)
  513. {
  514. $cpsl += $num[1];
  515. }
  516. }
  517. }
  518. if(count($wh) == $cpsl)
  519. {
  520. return array('fh'=>1,'sj'=>$wh);
  521. }
  522. else
  523. {
  524. return array('fh'=>2);
  525. }
  526. }
  527. }