ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### 装箱单封箱保存唯一码信息 **位置:** Common\Lib\FlowLib.class.php **参数:** * @param $data array 装箱单信息(如:订单类型,订单ID,装箱单编号) * @return array 装箱返回的提示信息 **调用:** * $flow = new FlowLib(); * $order_arr = $flow->boxClose($data); **完整代码:** ~~~ /** * 扫描商品封箱 * @param $data array 封箱的商品信息 * @return array 返回查询的商品信息 * whz 2018-01-30 * */ public function boxClose($data) { $url = U('view',array('id' => $data['id'])); //1、没有扫描商品不能封箱 if(count($data['nos']) == 0 || $data['nos'][0] == ''){ return array('success'=>false, 'code'=>201, 'msg'=>'没有扫描商品,请扫描商品后再封箱'); } //2、查询订单信息 $type = M('wms_flow') ->where(array('id' => $data['id'])) ->find(); if (count($type) == 0) { return array('success'=>false, 'code'=>202, 'msg'=>'订单信息查询失败!'); } //3、确认封箱生成装箱单 $box_data = array( 'box_no' => $data['box_no'], 'num' => count($data['nos']), 'type' => $data['type'], 'order_id' => $data['id'], 'uid' => $_SESSION['userInfo']['id'], 'create_time' => time(), 'status' => 0 //装箱单状态:0、已封箱 ); M()->startTrans(); //往装箱单表添加新封箱的装箱单 $box_id = M("wms_box")->add($box_data); if (!$box_id){ M()->rollback(); return array('success'=>false, 'code'=>202,'msg'=>'封箱生成装箱单失败,请重新扫描!'); } //4、把扫的商品唯一码添加到流通唯一码表里面 foreach ($data['nos'] as $key => $value){ //查询唯一码信息 $no_arrs = M('goods_no') ->where(array('is_delete'=>0, 'no'=>$value)) ->find(); if (count($no_arrs) == 0) { M()->rollback(); return array('success'=>false, 'code'=>202, 'msg'=>'唯一码信息查询失败!'); } //唯一码SKU的ID查询 if ($type['type'] == 1) { $goods_id = M('wms_sku') ->where(array('order_id'=>$data['id'],'sku_id'=>$no_arrs['sku_id'])) ->find(); $goodsid = $goods_id['id']; if (count($goods_id) == 0) { M()->rollback(); return array('success'=>false, 'code'=>202, 'msg'=>'SKU信息查询失败!'); } }else{ $goodsid = 0; } $no_data = array( 'no_id' => $no_arrs['id'], 'no' => $value, 'goods_id' => $goodsid, 'box_id' => $box_id, 'status' => 1, //商品状态:1、已扫描 'uid' => $_SESSION['userInfo']['id'], 'create_time' => time(), 'is_delete' => 0, 'type' => $data['type'], 'order_id' => $data['id'] ); //添加扫描的商品插入流通唯一码表 $edit_no = M('wms_no') ->add($no_data); if (!$edit_no) { M()->rollback(); return array('success'=>false, 'code'=>203, 'msg'=>'扫描的商品入箱出错,请重新扫描!'); } //5、改变唯一码物流状态 $edit_status = $this->deliveryStatus($data['type']); $edit_delivert = M('goods_no') ->where(array('is_delete'=>0, 'no'=>$value)) ->save(array('delivery_status'=>$edit_status[0])); if ($edit_delivert === false) { M()->rollback(); return array('success'=>false, 'code'=>203, 'msg'=>'扫描的唯一码物流状态改变出错,请重新扫描!'); } } if ($type['type'] == 2) { //改变订单状态 $order_status = M('wms_flow') ->where(array('id'=>$data['id'])) ->save(array('status'=>1)); if ($order_status === false) { M()->rollback(); return array('success'=>false, 'code'=>203, 'msg'=>'订单状态改变失败!'); } } //6、生成日志记录 $add_log['description'] = '装箱单:' . $data['box_no'] . ' 生成成功!'; $add_log['order_id'] = $data['id']; $add_log['type']= $data['type']; $log_add = $this->addLog($add_log); if (!$log_add) { M()->rollback(); return array('success'=>false, 'code'=>204, 'msg'=>'日志信息记录失败!'); } M()->commit(); return array('success'=>true, 'code'=>200, 'msg'=>'装箱单:'. $data['box_no'] . ' 生成成功!', 'url'=>$url); } ~~~