Outerrors.php 22 KB

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