🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 订单的验收 **位置:** Common\Lib\FlowLib.class.php **参数:** * @param $data array 订单信息(如:订单类型,订单ID,订单状态) * @return array 订单验收提示信息 **调用:** * $flow = new FlowLib(); * $order_arr = $flow->check($data); **完整代码:** ~~~ /** * 门店最终的验货 * @param $data array 订单信息 * @return int 订单改变状态 * whz 2018-01-30 * */ public function check($data) { M()->startTrans(); //1、根据订单ID查询所有装箱单扫描了的商品信息 $goods_list = M('wms_flow as r') ->field('o.id,o.no_id,o.status,x.status as box_status') ->join('coscia_wms_box as x on r.id = x.order_id','left') ->join('coscia_wms_no as o on r.id = o.order_id') ->where(array('r.id'=>$data['id'], 'o.status'=>array('in',array(1,2)), 'o.is_delete'=>0)) ->select(); //2、判断发货商品是否都已经验收 foreach ($goods_list as $key => $value){ //当前收货单只要有一个商品没有扫描验收,就不能进行验收 if ($value['status'] != 2) { return array('success'=>false, 'code'=>201, 'msg'=>'商品还没有扫描完,验收失败!'); } //只要有一个装箱单没有确认收完就不能进行验收(提示有装箱单没有验收确认) if ($value['box_status'] != 2) { return array('success'=>false, 'code'=>202, 'msg'=>'还有装箱单收完没有确定,验收失败!'); } } //3、验收成功之后记录验收人和时间 $edit_data = array( 'in_uid' => $_SESSION['userInfo']['id'], 'in_time' => time(), 'status' => 7 ); $edit = M('wms_flow') ->where(array('id' => $data['id'])) ->save($edit_data); //判断记录更新是否成功 if ($edit === false) { M()->rollback(); return array('success'=>false, 'code'=>203, 'msg'=>'记录验收人和验收时间失败!'); } //4、记录验收日志 $add_log['description'] = '订单验收成功!'; $add_log['order_id'] = $data['id']; $add_log['type'] = $data['type']; $addlog = $this->addLog($add_log); if (!$addlog) { M()->rollback(); return array('success'=>false, 'code'=>203, 'msg'=>'日志记录添加失败!'); } M()->commit(); return array('success'=>true, 'code'=>200, 'msg'=>'验收成功!'); } ~~~