/** * Pda_orderLoadingAct::act_orderLoading() * 装车扫描的时候对口袋编号进行改变状态,如果是快递的就扫描发货单号 * @author cxy * @return */ public function act_orderLoading() { $userId = $_SESSION['userId']; $packageId = trim($_POST['order_group']); //需要验证是否是口袋编号 //if(strlen($packageId)<7){ // $a = WhWaveAreaInfoModel::get_area_info(1,1,1); // echo $a ;exit; $group_sql = WhWaveOrderPartionShippingReviewModel::get_pocket($packageId); // print_r($group_sql);exit; if (empty($group_sql)) { self::$errCode = '003'; self::$errMsg = '该编号不在发货复核中,请重新输入!'; return false; } $ebay_id_all = WhWaveOrderPartionScanReviewModel::get_shipping_review($packageId); if (empty($ebay_id_all)) { self::$errCode = '003'; self::$errMsg = '该编号不在分区复核中,请重新输入!'; return false; } $data = array('packageId' => $packageId, 'scantime' => time(), 'userId' => $userId, 'isExpress' => 2); $select_loading = WhWaveOrderLoadingModel::select_loading($packageId); if ($select_loading) { self::$errCode = '003'; self::$errMsg = '该' . $packageId . '编号已经进行过装车扫描了!'; return false; } WhBaseModel::begin(); $insert_loading = WhWaveOrderLoadingModel::insert($data); if (empty($insert_loading)) { self::$errCode = '003'; self::$errMsg = '装车扫描失败,请联系负责人!'; WhBaseModel::rollback(); return false; } foreach ($ebay_id_all as $values) { $shipOrderId = $values['shipOrderId']; $result = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($shipOrderId, $status = PKS_DONE); if (!$result) { self::$errCode = '003'; self::$errMsg = '更新' . $shipOrderId . '发货单号失败!'; WhBaseModel::rollback(); return false; } WhPushModel::pushOrderStatus($shipOrderId, 'PKS_DONE', $_SESSION['userId'], time()); //状态推送,需要改为已发货(订单系统提供状态常量) } self::$errCode = '200'; self::$errMsg = '扫描' . $packageId . '口袋编号成功!'; WhBaseModel::commit(); return true; // }else{ // } }
/** * WaveBuildAct::make_wave() * 生成配货单 (单料号和单发货单) * @param int $shipOrderId 发货单ID * @param int $wave_id 发货单ID * @param integer $wave_status wave_id 没有传递时 生成的配货单状态 0可以继续添加 1完结配货单不许再添加 * @param array $order_detail 订单明细 * @param int $wave_type 配货单类型 1=》单个发货单 2-单料号 3-多料号 * @return bool */ public function make_wave($shipOrderId, $wave_id = 0, $wave_status = 0, $order_detail = '', $wave_type = 1) { $shipOrderId = intval(trim($shipOrderId)); $wave_id = intval(trim($wave_id)); $wave_status = intval(trim($wave_status)); //print_r($shipOrderId);exit; if (!$shipOrderId) { self::$errCode = 200; self::$errMsg = '无效发货单ID!'; return FALSE; } if (empty($order_detail)) { $order_detail = WhShippingOrderdetailModel::getShipDetails($shipOrderId); //获取订单明细 if (empty($order_detail)) { //没有订单明细则直接返回 self::$errCode = 201; self::$errMsg = '该发货单没有料号明细!'; return FALSE; } } $order_limit = self::get_order_limit_info($order_detail); //获取当前订单的重量、料号数量、体积信息 $area_info = self::get_area_info($order_detail); //获取订单区域、楼层信息 //print_r($area_info);exit; WhBaseModel::begin(); if (!$wave_id) { //不存在配货单号 $startArea = current($area_info['areas']); //print_r($startArea);exit; $startArea = WhWaveAreaInfoModel::get_area_info('areaName', $startArea); //判断配货单区域类型 $waveZone = self::judge_wave_zone($area_info['storey'], $area_info['areas']); //判断配货单区域类型 if ($waveZone === FALSE) { self::$errCode = 203; self::$errMsg = '获取配货单区域类型失败!'; return FALSE; } $data = array('storey' => implode(',', $area_info['storey']), 'startArea' => $startArea[0]['areaName'], 'totalWeight' => $order_limit['limitWeight'], 'totalVolume' => $order_limit['limitVolume'], 'totalSkus' => $order_limit['limitSkuNums'], 'totalOrders' => 1, 'waveStatus' => $wave_status, 'waveZone' => $waveZone, 'waveType' => $wave_type, 'createTime' => time(), 'printStorey' => $area_info['storey'][0]); if ($wave_type == 2) { //单料号配货单 $data['sku'] = $order_detail[0]['sku']; } //print_r($data);exit; $wave_id = WhWaveInfoModel::insert_wave_info($data); //echo '生成配货单'.$wave_id."<br />"; if ($wave_id === FALSE) { self::$errCode = 100; self::$errMsg = '生成配货单失败!'; WhBaseModel::rollback(); return FALSE; } $wave_number = WhWaveInfoModel::number_encode($wave_id); //生成配货单编号 //print_r($wave_number);exit; /** 更新配货单编号**/ $info = WhWaveInfoModel::update_wave_info(array('number' => $wave_number), array('id' => $wave_id)); if (!$info) { self::$errCode = 108; self::$errMsg = '更新配货单编号失败!'; WhBaseModel::rollback(); return FALSE; } //echo '更新配货单编号'.$wave_number."<br />"; /** end**/ } else { //已存在配货单号 $where = array('id' => $wave_id); $wave_info = WhWaveInfoModel::get_wave_info('*', $where); //获取配货单信息 if (empty($wave_info)) { self::$errCode = 101; self::$errMsg = '没有该配货单信息!'; return FALSE; } $wave_info = $wave_info[0]; if ($wave_info['waveStatus'] != 0) { self::$errCode = 102; self::$errMsg = '该配货单已不能添加订单!'; return FALSE; } $wave_type = $wave_info['waveType']; //配货单类型 单料号 多料号 $order_limit['limitSkuNums'] += $wave_info['totalSkus']; $order_limit['limitWeight'] += $wave_info['totalWeight']; $order_limit['limitVolume'] += $wave_info['totalVolume']; $order_limit['limitOrderNums'] = $wave_info['totalOrders'] + 1; $is_wave = self::judge_single_shiporder($order_limit, $wave_type); //判断加上新订单是否超过单个配货单限制 //var_dump($is_wave);exit; if ($is_wave === TRUE) { //完结配货单 $update = array('waveStatus' => 1); $where = array('id' => $wave_id); $info = WhWaveInfoModel::update_wave_info($update, $where); //超过限制则完结该配货单 return self::make_wave($shipOrderId, 0, $wave_status, $order_detail, $wave_type); //重新分配配货单 } else { /** 更新配货单信息**/ $update = array('totalSkus' => $order_limit['limitSkuNums'], 'totalWeight' => $order_limit['limitWeight'], 'totalVolume' => $order_limit['limitVolume'], 'totalOrders' => $order_limit['limitOrderNums']); $combine_area = self::combine_area_info($wave_info['startArea'], $area_info['areas']); //合并新加入订单的区域信息 //print_r($combine_area);exit; $startArea = WhWaveAreaInfoModel::get_area_info('areaName', current($combine_area)); $combine_storey = self::combine_storey_info($wave_info['storey'], $area_info['storey']); //合并楼层 $waveZone = self::judge_wave_zone($combine_storey, $combine_area); //判断配货单区域类型 $update['storey'] = implode(',', $combine_storey); $update['startArea'] = $startArea[0]['areaName']; $update['waveZone'] = $waveZone; $update['printStorey'] = $combine_storey[0]; $where = array('id' => $wave_id); $info = WhWaveInfoModel::update_wave_info($update, $where); if (!$info) { self::$errCode = 103; self::$errMsg = '更新配货单信息失败!'; WhBaseModel::rollback(); return FALSE; } //echo '更新配货单'.$wave_id."<br />"; /** 更新配货单信息end**/ } } /** 插入收货记录表数据**/ if (empty($area_info['areas'])) { self::$errCode = 111; self::$errMsg = '发货单区域信息为空!'; WhBaseModel::rollback(); return false; } $area_names = self::get_area_names($area_info['areas']); $storey = self::get_storey_list(); //获取楼层列表 //print_r($area_names);exit; $info = WhWaveReceiveRecordModel::insert_receive_data($wave_id, $area_names, $storey); //插入收获记录表区域信息 if ($info === FALSE) { self::$errCode = 104; self::$errMsg = '插入收货记录表失败!'; WhBaseModel::rollback(); return false; } //echo '插入收货记录'.json_encode($area_names)."<br />"; /** end**/ /** 插入配货记录表数据**/ $order_detail = self::merge_order_detail($order_detail); //合并同一生成时间下相同料号,相同仓位的料号信息 //print_r($order_detail);exit; $scan_details = self::process_scan_details($order_detail); //处理订单详情生成相对应配货记录 $info = WhWaveScanRecordModel::inser_scan_data($wave_id, $scan_details); if ($info === FALSE) { self::$errCode = 105; self::$errMsg = '插入配货记录表失败!'; WhBaseModel::rollback(); return false; } //echo '插入配货记录'.json_encode($scan_details)."<br />"; /** end**/ /** 插入配货单、发货单关系表**/ $info = WhWaveShippingRelationModel::insert_relation_data($wave_id, $shipOrderId); if ($info === FALSE) { self::$errCode = 106; self::$errMsg = '插入配货单关系表失败!'; WhBaseModel::rollback(); return false; } //echo '插入配货单关系'.$wave_id.'----'.$shipOrderId."<br />"; /** end**/ /** 更新发货单分配状态**/ $info = WhShippingOrderModel::update(array('is_wave' => 1), array('id' => $shipOrderId)); if ($info === FALSE) { self::$errCode = 107; self::$errMsg = '更新发货单分配状态失败!'; WhBaseModel::rollback(); return false; } //echo '更新发货单分配状态'.$shipOrderId."<br />"; /** end**/ /** 更新多料号临时存放表**/ if ($wave_type == 3) { //多料号发货单 $info = whWaveMultiShipAreaRecordModel::update(array('is_wave' => 1), array('shipOrderId' => $shipOrderId)); if ($info === FALSE) { self::$errCode = 108; self::$errMsg = '更新多料号订单临时存放表状态失败!'; WhBaseModel::rollback(); return false; } //echo '更新多料号订单临时存放表'.$shipOrderId."<br />"; } /** end**/ WhBaseModel::commit(); return TRUE; }
/** * pda_shippingGroupReviewAct::act_outReview() * 扫描口袋编号通过AJAX传递口袋编号来对该编号进行操作 * @author cxy * @return boolean array */ public function act_outReview() { $userId = $_SESSION['userId']; $packageId = intval(trim($_POST['packageid'])); //得到发货单分区列表信息 $get_orderPartion = WhOrderPartionPrintModel::get_OrderPartion($packageId); if (empty($get_orderPartion)) { self::$errCode = '202'; self::$errMsg = '该口袋编号不存在分区列表中'; return false; } if ($get_orderPartion['status'] == 0) { self::$errCode = '202'; self::$errMsg = '该口袋编号还没有进行打包!'; return false; } //得到该口袋编号下的发货单 $all_order = WhOrderPartionRecordsModel::get_OrderPartionRecordsByPackageId($packageId); if ($all_order) { foreach ($all_order as $value) { $result_status = WhShippingOrderModel::get_order_info('orderStatus', array('id' => $value['shipOrderId'])); if ($result_status[0]['orderStatus'] != PKS_WAITING_SHIPPING_CHECKING) { self::$errCode = '202'; self::$errMsg = '该口袋编号下有发货单的状态不是在待发货组复核!'; return false; } } } //发货组复核信息 $get_groupReview = WhWaveOrderPartionShippingReviewModel::get_pocket($packageId); if ($get_groupReview) { self::$errCode = '211'; self::$errMsg = '该口袋编号已经在发货组复核中复核过了'; return true; } //分区复核的信息 $get_orderReview = WhWaveOrderPartionScanReviewModel::get_shippingNews($packageId); // print_r($get_orderReview); // echo $get_orderReview['review_weight'];exit; if ($get_orderPartion['totalWeight'] == $get_orderReview['review_weight'] && $get_orderPartion['totalNum'] == $get_orderReview['review_num']) { $is_error = 0; self::$errCode = '200'; self::$errMsg = '请随机扫描一个订单!'; $data = array('packageId' => $packageId, 'is_error' => $is_error, 'userId' => $userId, 'scantime' => time()); $partion_arr = array(); $review_arr = array(); //分区扫描得到的发货单 $get_orderPartion_detail = WhOrderPartionRecordsModel::get_OrderPartionRecordsByPackageId($packageId); //得到分区复核的发货单列表 $get_review_detail = WhWaveOrderPartionScanReviewModel::get_shipping_review($packageId); foreach ($get_orderPartion_detail as $v) { $partion_arr[$v['shipOrderId']] = $v; } foreach ($get_review_detail as $v) { $review_arr[$v['shipOrderId']] = $v; } $diversity_a = array_diff_key($partion_arr, $review_arr); $diversity_b = array_diff_key($review_arr, $partion_arr); if (!empty($diversity_a) || !empty($diversity_b)) { self::$errCode = '500'; self::$errMsg = '分区的发货单与分区复核的发货单不符合'; $order_str = ''; if ($diversity_a) { foreach ($diversity_a as $k => $val) { $order_str .= $k . ','; } } elseif ($diversity_b) { foreach ($diversity_b as $k => $val) { $order_str .= $k . ','; } } return trim($order_str, ','); } $res = array(); WhBaseModel::begin(); $result = WhWaveOrderPartionShippingReviewModel::insert($data); if ($result) { foreach ($get_review_detail as $ks => $val) { //更新发货操作记录表 $update = WhWaveOrderPartionShippingReviewModel::updateOrderRecords($val['shipOrderId'], $userId); if (!$update) { self::$errCode = '206'; self::$errMsg = '更新操作记录失败,请联系负责人!'; WhBaseModel::rollback(); return false; } //更新发货表状态 $ostatus = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($val['shipOrderId'], $status = PKS_WAITING_LOADING); if (!$ostatus) { self::$errCode = 608; self::$errMsg = "更新发货单状态失败!"; WhBaseModel::rollback(); return false; } WhPushModel::pushOrderStatus($val['shipOrderId'], 'PKS_WAITING_LOADING', $_SESSION['userId'], time()); //状态推送,需要改为装车扫描(订单系统提供状态常量) } self::$errCode = '200'; self::$errMsg = '该口袋编号正确,请复核下该口袋编号下的发货单!'; $get_orderPartion['totalWeight'] = round($get_orderPartion['totalWeight'] / 1000, 3); $get_orderReview['review_weight'] = round($get_orderReview['review_weight'] / 1000, 3); $res['partion_data'] = $get_orderPartion; $res['review_data'] = $get_orderReview; $res['packageid'] = $packageId; } else { self::$errCode = '206'; self::$errMsg = '该发货组复核口袋编号失败,请联系负责人!'; WhBaseModel::rollback(); return false; } WhBaseModel::commit(); return $res; } else { self::$errCode = '201'; self::$errMsg = '分区和分区复核的数据不一致!'; } $res['partion_data'] = $get_orderPartion; $res['review_data'] = $get_orderReview; $res['packageid'] = $packageId; return $res; }
/** * pda_TrackingAct::act_tracking_binding() * 快递绑定跟踪号 * @author cxy * @return */ public function act_tracking_binding() { $userId = $_SESSION['userId']; $ebay_id = trim($_POST['ebay_id']); $tracking = trim($_POST['tracking']); if (empty($userId)) { self::$errCode = '0'; self::$errMsg = '系统登录超时,请先关闭浏览器 然后登录扫描!!'; return false; } if (empty($ebay_id)) { self::$errCode = 0; self::$errMsg = '请填写单号!'; return; } if (empty($tracking)) { self::$errCode = 0; self::$errMsg = '请输入正确的跟踪号!'; return; } //查询扫描的跟踪号是否已经扫描过了的 $result_select = WhOrderTracknumberModel::select_ByTracknumber($tracking); if ($result_select) { self::$errCode = 211; self::$errMsg = '该跟踪号已经绑定' . $result_select['shipOrderId'] . ',请检查!'; return false; } $data = array('tracknumber' => $tracking, 'shipOrderId' => $ebay_id, 'createdTime' => time()); $array = array('shipOrderId' => $ebay_id, 'is_delete' => 0); //根据发货单号获取快递需要的箱子和跟踪号数量 $result_tracking_count = WhWaveTrackingBoxModel::select_by_shipOrderId($ebay_id); //说明该快递单只有一个箱子和一个跟踪号,所以不需要在wh_wave_tracking_box "快递单号的箱子与跟踪号数量表"添加记录 if (empty($result_tracking_count)) { $count_binding = WhOrderTracknumberModel::count($array); //发货单已经绑定跟踪号的数量 if ($count_binding > 0) { self::$errCode = 24; self::$errMsg = '该发货单号已经绑定好跟踪号了,不在需要绑定'; return false; } WhBaseModel::begin(); $result_insert = WhOrderTracknumberModel::insert($data); if (!$result_insert) { WhBaseModel::rollback(); self::$errCode = 20; self::$errMsg = '跟踪号绑定失败,请联系负责人'; return false; } //更新发货表状态 $ostatus = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($ebay_id, $status = PKS_WAITING_LOADING); if (!$ostatus) { WhBaseModel::rollback(); self::$errCode = 20; self::$errMsg = '更新发货单状态失败,请联系负责人'; return false; } WhPushModel::pushOrderStatus($ebay_id, 'PKS_WAITING_LOADING', $_SESSION['userId'], time()); //状态推送,需要改为待装车扫描(订单系统提供状态常量) WhBaseModel::commit(); self::$errCode = 200; self::$errMsg = '绑定成功,请扫描另外一个发货单!'; return true; } else { $result_tracking_count = $result_tracking_count['trackingCount']; //发货单需要绑定跟踪号的数量 $count_binding = WhOrderTracknumberModel::count($array); //发货单已经绑定跟踪号的数量 if ($result_tracking_count > $count_binding) { WhBaseModel::begin(); $result_insert = WhOrderTracknumberModel::insert($data); if (!$result_insert) { WhBaseModel::rollback(); self::$errCode = 21; self::$errMsg = '跟踪号绑定失败,请联系负责人'; return false; } $num = $result_tracking_count - $count_binding - 1; if ($num == 0) { //更新发货表状态 $ostatus = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($ebay_id, $status = PKS_WAITING_LOADING); if (!$ostatus) { WhBaseModel::rollback(); self::$errCode = 20; self::$errMsg = '更新发货单状态失败,请联系负责人'; return false; } WhPushModel::pushOrderStatus($ebay_id, ' ', $_SESSION['userId'], time()); //状态推送,需要改为待装车扫描(订单系统提供状态常量) WhBaseModel::commit(); self::$errMsg = '绑定成功,该发货单不需要绑定跟踪号了'; self::$errCode = 200; return true; } else { WhBaseModel::commit(); self::$errMsg = '绑定成功,该发货单还需要绑定' . $num . '个跟踪号'; self::$errCode = 400; return true; } } else { self::$errCode = 22; self::$errMsg = '绑定失败,绑定的跟踪号已经够' . $result_tracking_count . '个,请扫描另外一个发货单!'; return true; } } }
/** * WaveInfoManageView::makeSingleWave() * 生成单料号及单发货单配货单 * @author Gary * @return void */ public function makeSingleWave($time) { $update = array('createUserId' => $_SESSION['userId'], 'createTime' => time(), 'waveStatus' => 1); $where = array('waveType in' => array(1, 2), 'createTime <=' => $time, 'createUserId' => 0, 'is_delete' => 0); $waveinfo = WhWaveInfoModel::get_wave_info('id', $where); //获取所有符合条件的配货单号 WhBaseModel::begin(); //更新配货单状态 $info = WhWaveInfoModel::update_wave_info($update, $where); if (!$info) { WhBaseModel::rollback(); return $info; } $waveIds = get_filed_array('id', $waveinfo); $waveIds = empty($waveIds) ? array(0) : $waveIds; $shipOrderIds = WhWaveShippingRelationModel::select(array('waveId in' => $waveIds), 'shipOrderId'); //print_r($waveIds);exit; $shipOrderIds = get_filed_array('shipOrderId', $shipOrderIds); $shipOrderIds = empty($shipOrderIds) ? array(0) : $shipOrderIds; $info = WhShippingOrderModel::update(array('orderStatus' => PKS_PROCESS_GET_GOODS), array('id in' => $shipOrderIds)); if (!$info) { WhBaseModel::rollback(); return $info; } $info = WhBaseModel::affected_rows(); WhBaseModel::commit(); return $info; }
/** * MakeRouteIndexAct::act_makePositionIndex() * 生成仓位索引 * @return void */ public function act_makePositionIndex() { $positionInfo = WhPositionDistributionModel::get_position_info_union_area(); if (empty($positionInfo)) { self::$errCode = 204; self::$errMsg = '没有关联的仓位信息!'; return FALSE; } //print_r($positionInfo);exit; $y = range(0, 10); //纵坐标范围 $num = floor(count($y) / 2); //循环次数 $y = -2; $sort = array(); //存放横纵坐标索引值 while ($num > 0) { //生成排序Y坐标索引,键名是Y坐标,值是索引级别,值越大越优先 $y_max = $y < 0 ? 0 : $y + 2; $sort[$y] = $sort[$y_max] = $num; //$sort[$num] = array($y, $y_max); $y += 3; $num--; } $new_arr = array(); foreach ($positionInfo as $position) { $new_arr[$position['areaId']][$sort[$position['y_alixs']]][$position['x_alixs']][$position['z_alixs']][] = $position; } //print_r($new_arr);exit; unset($positionInfo); WhBaseModel::begin(); $where = 'routeType = 4'; $info = WhWaveRouteRelationModel::delete_relation($where); if (!$info) { WhBaseModel::rollback(); self::$errCode = 202; self::$errMsg = '删除旧仓位索引失败!'; return FALSE; } $string = ''; $i = 1; //仓位排序判断 蛇形配货 $route = 1; //仓位索引排序 $data_arr = array(); //插入数据 $routeType = 4; //索引类型为仓位。 foreach ($new_arr as $area) { foreach ($area as $y_sort) { //按照Y轴排序的结果 //print_r($y_sort);exit; foreach ($y_sort as $x_sort) { //按照X轴排序的结果 $i % 2 === 0 ? rsort($x_sort) : sort($x_sort); //print_r($x_sort);exit; foreach ($x_sort as $z_sort) { //按照Z轴排序的结果 sort($z_sort); //print_r($z_sort);exit(); foreach ($z_sort as $position) { $data_arr[] = array('name' => $position['pName'], 'routeId' => $position['id'], 'route' => $route, 'routeType' => $routeType); if ($route % 100 == 0) { //每3000条插入一次数据\ //var_dump($data_arr);exit; $info = WhWaveRouteRelationModel::insert_data($data_arr); if (!$info) { WhBaseModel::rollback(); self::$errCode = 203; self::$errMsg = '插入新仓位索引失败!'; return FALSE; } $data_arr = array(); } $route++; } } } } $i++; } //print_r($data_arr);exit; unset($new_arr); if (!empty($data_arr)) { $info = WhWaveRouteRelationModel::insert_data($data_arr); if (!$info) { WhBaseModel::rollback(); self::$errCode = 203; self::$errMsg = '插入新仓位索引失败!'; return FALSE; } } WhBaseModel::commit(); self::$errCode = 200; self::$errMsg = '更新仓位索引成功!'; return TRUE; }
/** * 订单系统通过接口更改仓库系统订单废弃 */ public static function orderDiscard($oidStr, $storeId) { self::initDB(); if (empty($oidStr) || !is_numeric($storeId)) { self::$errCode = "401"; self::$errMsg = "参数有误"; return false; } $orders = trim($oidStr, ','); $sql = "select shipOrderId from wh_shipping_order_relation where originOrderId in ({$orders}) and storeId={$storeId} and is_delete = 0"; $query = self::$dbConn->query($sql); $shipOrderIds = self::$dbConn->fetch_array_all($query); $shipOrderArr = array(); if ($shipOrderIds) { foreach ($shipOrderIds as $shipOrderId) { $shipOrderArr[] = $shipOrderId['shipOrderId']; } $shipOrders = implode(',', $shipOrderArr); $orderStatus = PKS_DONE; $sql = "select orderStatus from wh_shipping_order where id in ({$shipOrders}) and orderStatus = {$orderStatus}"; $result = self::$dbConn->query($sql); $result = self::$dbConn->fetch_array_all($result); if ($result) { self::$errCode = "404"; self::$errMsg = "仓库系统对应的发货单已经发货!"; return false; } WhBaseModel::begin(); $sql = "update wh_shipping_order set orderStatus=900 where id in({$shipOrders})"; $query = self::$dbConn->query($sql); if ($query) { $sql1 = "update wh_shipping_order_relation set is_delete= 1 where shipOrderId in({$shipOrders})"; $query1 = self::$dbConn->query($sql1); if (!$query1) { WhBaseModel::rollback(); self::$errCode = "404"; self::$errMsg = "仓库系统订单废弃失败!"; return false; } WhBaseModel::commit(); return true; } else { self::$errCode = "403"; self::$errMsg = "仓库系统订单废弃失败!"; return false; } } else { self::$errCode = "402"; self::$errMsg = "找不到仓库系统对应的发货单!"; return false; } }
/** * 1001014对这个发货单号进行测试 * abnormalInvoiceAct::act_abnormalInvoice() * 拆分异常发货单 * @author chenxianyu * @return array */ public function act_abnormalInvoice() { $userId = $_SESSION['userId']; $status = trim($_POST['status']); $orderids = isset($_POST['orderids']) ? $_POST['orderids'] : ''; if (empty($orderids)) { self::$errCode = 0; self::$errMsg = '请选择发货单号!'; return false; } //得到发货单号为一维数组 $order_arr = explode(',', $orderids); $status_isSplit = ''; //发货单已经是拆分过了的 $one_sku = ''; //单个SKU和单个组合料号的发货单 $err_str = ''; //发货单错误信息的提示 $cuccess_str = ''; //发货单成功信息的提示 $data = array(); //添加到拆分记录的数组 $data_api = array(); //通过接口传递到订单系统的数组 $j = 0; //标识这个发货单拆分的时候之前是在分拣标识异常的状态还是在复核的时候标识为异常的状态 foreach ($order_arr as $val) { $order = WhShippingOrderdetailModel::getShipDetailsById($val); if (!$order) { self::$errCode = 0; self::$errMsg .= "{$val}此发货单不存在!"; continue; } if ($order[0]['orderStatus'] != PKS_UNUSUAL_SHIPPING_INVOICE) { continue; } if ($order[0]['isSplit'] == 2) { self::$errMsg .= "{$val}发货单是已经拆分过了,不能拆分!"; $status_isSplit .= $val . ':发货单是已经拆分过了,不能拆分'; continue; } //得到发货单号对应订单系统的订单号 $result = WhShippingOrderModel::select_shipping_order_relation($val); $originOrderId = $result['originOrderId']; $arr_combine = array(); //单个SKU if (count($order) == 1) { self::$errCode = 0; self::$errMsg .= "{$val}发货单是单个SKU的,不能拆分!"; $one_sku .= $val . ':发货单是单个SKU的,不能拆分'; continue; } $i = 0; //标识该发货单有不是组合料号的SKU foreach ($order as $values) { //如果有组合料号,先获取真实的SKU if (!empty($values['combineSku'])) { $arr_combine[$values['combineSku']][] = $values; } else { $i++; //标识该发货单有不是组合料号的SKU $shipOrderId = $val; $sku = $values['sku']; //获取配货单分拣复核记录信息 $result = OrderReviewModel::getReviewList('amount,sku', "where isScan = 1 and is_delete = 0 and shipOrderId = '{$shipOrderId}' and sku ='{$sku}'"); if (!empty($result)) { $j = 1; //表示是在复核的时候标识为异常的状态 $sku_count_all = 0; //已经分拣的总数量 foreach ($result as $Pick) { $sku_count_all += $Pick['amount']; //已经分拣的数量 } if ($sku_count_all < $values['amount']) { $isShortage = 1; } else { $isShortage = 2; } $skuAmount = $values['amount']; //应配货数量 $amount = $sku_count_all; //已配货数量 } else { //如果没有分拣复核的信息,那么就查找分拣记录 $pick_record = WhWavePickRecordModel::get_pickByIdSku($shipOrderId, $sku); if ($pick_record) { if ($pick_record[0]['skuAmount'] > $pick_record[0]['amount']) { $isShortage = 1; } else { $isShortage = 2; } $skuAmount = $pick_record[0]['skuAmount']; //应配货数量 $amount = $pick_record[0]['amount']; //已配货数量 //如果分拣和分拣复核都没有数据的就跳过 } else { if (strpos($err_str, $val) === false) { self::$errMsg .= $val . '分拣和分拣复核都没有数据,'; $err_str .= $val . ':分拣和分拣复核都没有数据'; } } } //传递到订单系统的 $data_api[$originOrderId][$isShortage][$values['sku']] = $values['amount']; //添加到拆分记录表的 $data[$shipOrderId][] = array('oldshipOrderId' => $shipOrderId, 'sku' => $sku, 'createdTime' => time(), 'skuAmount' => $skuAmount, 'amount' => $amount, 'userId' => $userId, 'isShortage' => $isShortage); } } if (count($arr_combine) == 1 && $i == 0) { $one_sku .= $val . ','; continue; } //对组合起来的组合料号数组进行拆分 if (!empty($arr_combine)) { foreach ($arr_combine as $keys => $v) { $combineSku = $keys; //组合料号 $arr_data = array(); $shortage = false; foreach ($v as $list) { $shipOrderId = $list['shipOrderId']; $sku = $list['sku']; $amount_datail = $list['amount']; //获取配货单分拣复核记录信息 $re_combine = OrderReviewModel::getReviewList('amount,sku', "where isScan = 1 and is_delete = 0 and shipOrderId = '{$shipOrderId}' and sku ='{$sku}'"); if (!empty($re_combine)) { $j = 1; //表示是在复核的时候标识为异常的状态 $sku_count = 0; foreach ($re_combine as $Pick) { $sku_count += $Pick['amount']; } //当复核数量小于需要配货数量的时候 if ($sku_count < $amount_datail) { $shortage = true; } } else { //如果没有分拣复核的信息,那么就查找分拣记录 $pick_record = WhWavePickRecordModel::get_pickByIdSku($shipOrderId, $sku); if ($pick_record) { if ($pick_record[0]['skuAmount'] > $pick_record[0]['amount']) { $shortage = true; } $amount_datail = $pick_record[0]['skuAmount']; $sku_count = $pick_record[0]['amount']; } else { //如果分拣和分拣复核都没有数据的就跳过 if (strpos($err_str, $val) === false) { self::$errMsg .= $val . '分拣和分拣复核都没有数据,'; $err_str .= $val . ':分拣和分拣复核都没有数据'; } } } $arr_data[] = array('oldshipOrderId' => $shipOrderId, 'sku' => $sku, 'createdTime' => time(), 'skuAmount' => $amount_datail, 'amount' => $sku_count, 'userId' => $userId, 'combineSku' => $combineSku); } if ($shortage) { $isShortage = 1; } else { $isShortage = 2; } foreach ($arr_data as $data_value) { //传递到订单系统的 $data_api[$originOrderId][$isShortage][$data_value['sku']] = $data_value['skuAmount']; //添加到拆分记录表的 $data[$shipOrderId][] = array('oldshipOrderId' => $data_value['oldshipOrderId'], 'sku' => $data_value['sku'], 'createdTime' => time(), 'skuAmount' => $data_value['skuAmount'], 'amount' => $data_value['amount'], 'userId' => $data_value['userId'], 'combineSku' => $data_value['combineSku'], 'isShortage' => $isShortage); } } } //以上是拆分发货单到拆分记录表的操作 //把需要拆分的数组传递到订单系统 WhBaseModel::begin(); $ipa_res = CommonModel::get_shipDetail($data_api); /* $ipa_res = array( "status"=>true, "data"=> array( $originOrderId=>array( '1'=>array( 'omOrderId'=>14478451, 'actualTotal'=>7.43, 'usefulChannelId'=>66, 'calcOrderShipping'=>2.39, 'calOrderWeight'=>0.192, ), '2'=>array( 'omOrderId'=>15029562, 'actualTotal'=>22.29, 'usefulChannelId'=>66, 'calcOrderShipping'=>9.88, 'calOrderWeight'=>0.653 ), ), ), ); */ // var_dump($ipa_res); // print_r($data_api); // print_r($data); //exit(); //调用订单拆分接口成功 if ($ipa_res['status']) { foreach ($data[$val] as $insert_list) { //查询发货单拆分记录 $select_Invoice = WhWaveInvoiceSplitRecordModel::getInvoiceSplitBySku($insert_list['oldshipOrderId'], $insert_list['sku']); if ($select_Invoice) { continue; } else { //把拆分记录插入拆分记录数据表 $result_insert = WhWaveInvoiceSplitRecordModel::insert($insert_list); if (!$result_insert) { WhBaseModel::rollback(); } } //如果需配货数量与已配货数量不同,则把发货明细列表更新为逻辑删除 if ($insert_list['isShortage'] == 1) { $update_result = WhShippingOrderdetailModel::updateShipDetailByShipOrderId($insert_list['oldshipOrderId'], $insert_list['sku']); if (!$update_result) { WhBaseModel::rollback(); } } } //拆分有返回值 if ($ipa_res['data'][$originOrderId]) { foreach ($ipa_res['data'][$originOrderId] as $k => $list) { //把原来的发货单与订单的关系更新为旧的发货单与新的有货的订单为对应关系 if ($k == 2) { //2是代表有货的拆分 1是无货 $omOrderId = $list['omOrderId']; $update_relation = WhShippingOrderRelationModel::update_shipping_by_orderId("shipOrderId = '{$val}'", "originOrderId = '{$omOrderId}'"); if (!$update_relation) { WhBaseModel::rollback(); } if ($j == 1) { $orderStatus = PKS_WWEIGHING; } else { $orderStatus = PKS_WIQC; } //拆分成功后,旧的发货单就更新发货单列表的状态为待称重,估计重量,金额,估算运费 $calcShipping = $list['calcOrderShipping']; $calcWeight = $list['calOrderWeight']; $total = $list['actualTotal']; $update_shipping_order = WhShippingOrderModel::update_shipping_order_by_id("id = '{$shipOrderId}' and is_delete = 0", "orderStatus = {$orderStatus},isSplit =2,calcShipping = '{$calcShipping}',calcWeight = '{$calcWeight}',total = '{$total}'"); if (!$update_shipping_order) { WhBaseModel::rollback(); } } } $cuccess_str .= '发货单为' . $val . ','; } else { //拆分失败 if (strpos($err_str, $val) === false) { self::$errMsg .= $val . '拆分发货单失败,'; $err_str .= $val . ':拆分发货单失败,订单系统不允许该发货单拆分'; } WhBaseModel::rollback(); } } else { //调用接口失败 if (strpos($err_str, $val) === false) { self::$errMsg .= $val . '调用订单系统的接口失败,'; $err_str .= $val . ':调用订单系统的接口失败'; } WhBaseModel::rollback(); } WhBaseModel::commit(); } if (empty($cuccess_str)) { self::$errCode = 20; self::$errMsg .= '拆分失败,点击的异常发货单是单个料号或者是单个组合料号'; $res['one_sku'] = $one_sku; $res['status_isSplit'] = $status_isSplit; $res['err'] = $err_str; return $res; } self::$errCode = 200; self::$errMsg .= '拆分已经完成,请注意拆分失败的发货单'; $res['err'] = $err_str; $res['cuccess'] = $cuccess_str; $res['one_sku'] = $one_sku; $res['status_isSplit'] = $status_isSplit; return $res; }
/** * pda_ExpressWeighingAct::act_trackingCount() * @author cxy *快递箱子和跟踪号数量添加到数据库 * @return */ public function act_trackingCount() { $userId = $_SESSION['userId']; $ebay_id = trim($_POST['ebay_id']); $count_box = trim(intval($_POST['count_box'])); $tracking_count = trim(intval($_POST['tracking'])); $weighing = trim($_POST['weighing']); $weighing = $weighing * 1000; if (empty($userId)) { self::$errCode = '0'; self::$errMsg = '系统登录超时,请先关闭浏览器 然后登录扫描!!'; return false; } if (empty($ebay_id)) { self::$errCode = 0; self::$errMsg = '请填写单号!'; return; } if ($count_box <= 1) { self::$errCode = 0; self::$errMsg = '请输入正确的箱子数量,最小是2!'; return false; } if ($tracking_count < 1) { self::$errCode = 0; self::$errMsg = '请输入正确的跟踪号数量,最小是1!'; return false; } if ($weighing <= 0) { self::$errCode = 0; self::$errMsg = '请输入正确的重量!'; return; } $where = "where id={$ebay_id}"; $order = orderPartionModel::selectOrder($where); if ($order[0]['transportId'] == 48) { //顺丰快递的跟踪号值能是一个 $tracking_count = 1; } else { if ($tracking_count != $count_box) { self::$errCode = 0; self::$errMsg = '跟踪号数量与箱子数量不相等!'; return; } } //逻辑删除以前称重的记录 $update = WhWaveTrackingBoxModel::update(array('is_delete' => 1), array('shipOrderId' => $ebay_id)); $data = array('boxCount' => $count_box, 'trackingCount' => $tracking_count, 'shipOrderId' => $ebay_id, 'weighTime' => time()); $result = WhWaveTrackingBoxModel::insert($data); if ($result) { WhBaseModel::begin(); $status = PKS_PRINT_SHIPPING_INVOICE; $result = WhShippingOrderModel::update_shipping_order_by_id("id = '{$ebay_id}' and is_delete = 0", "orderStatus = '{$status}',orderWeight = '{$weighing}'"); if (!$result) { WhBaseModel::rollback(); self::$errCode = 0; self::$errMsg = '称重添加失败,请联系负责人'; return false; } $msg = orderWeighingModel::insertRecord($ebay_id, $userId); if (!$msg) { self::$errCode = 511; self::$errMsg = "插入称重记录失败!"; WhBaseModel::rollback(); return false; } $msg_update = orderWeighingModel::updateRecord($ebay_id, $weighing, $userId); if (!$msg_update) { self::$errCode = 512; self::$errMsg = "更新操作记录表失败!"; WhBaseModel::rollback(); return false; } WhPushModel::pushOrderStatus($ebay_id, 'PKS_PRINT_SHIPPING_INVOICE', $_SESSION['userId'], time()); //状态推送,需要改为待打印面单(订单系统提供状态常量) WhBaseModel::commit(); self::$errCode = 200; self::$errMsg = '操作成功,请称重下一个发货单号'; return true; } else { self::$errCode = 211; self::$errMsg = '操作失败,请联系IT部门'; return false; } }
public function view_formDataImport() { // $tir_obj = new TrackInfoRecordModel(); $ebay_id = $_POST['order'][1]; $tracking = $_POST['express'][1]; if (empty($ebay_id) && empty($tracking)) { $data = array("data" => array('发货单和跟踪号不能是空!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); } $where = "where id={$ebay_id}"; $order = orderPartionModel::selectOrder($where); if (!$order) { $data = array("data" => array('发货单不存在!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } if ($order[0]['orderStatus'] != PKS_PRINT_SHIPPING_INVOICE) { $data = array("data" => array($ebay_id . '此发货单状态不是在待打印面单状态!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } $array = array('shipOrderId' => $ebay_id, 'is_delete' => 0); //根据发货单号获取快递需要的箱子和跟踪号数量 $result_tracking_count = WhWaveTrackingBoxModel::select_by_shipOrderId($ebay_id); $count_binding = WhOrderTracknumberModel::count($array); //发货单已经绑定跟踪号的数量 if (empty($result_tracking_count)) { if ($count_binding > 0) { $data = array("data" => array($ebay_id . "该发货单已经绑定好跟踪号了!"), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } } else { $result_tracking_count = $result_tracking_count['trackingCount']; //发货单需要绑定跟踪号的数量 if ($result_tracking_count <= $count_binding) { $data = array("data" => array($ebay_id . "该发货单已经绑定好跟踪号了!"), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } } //查询扫描的跟踪号是否已经扫描过了的 $result_select = WhOrderTracknumberModel::select_ByTracknumber($tracking); if ($result_select) { $data = array("data" => array('该跟踪号已经绑定' . $result_select['shipOrderId'] . ',请检查!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } $data_insert = array('tracknumber' => $tracking, 'shipOrderId' => $ebay_id, 'createdTime' => time()); $array_count = array('shipOrderId' => $ebay_id, 'is_delete' => 0); //根据发货单号获取快递需要的箱子和跟踪号数量 $result_tracking_count = WhWaveTrackingBoxModel::select_by_shipOrderId($ebay_id); //说明该快递单只有一个箱子和一个跟踪号,所以不需要在wh_wave_tracking_box "快递单号的箱子与跟踪号数量表"添加记录 if (empty($result_tracking_count)) { $count_binding = WhOrderTracknumberModel::count($array_count); //发货单已经绑定跟踪号的数量 if ($count_binding > 0) { $data = array("data" => array('该发货单号已经绑定好跟踪号了,不在需要和这个跟踪号绑定!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } WhBaseModel::begin(); $result_insert = WhOrderTracknumberModel::insert($data_insert); if (!$result_insert) { WhBaseModel::rollback(); $data = array("data" => array('跟踪号绑定失败,请联系负责人!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } //更新发货表状态 $ostatus = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($ebay_id, $status = PKS_WAITING_LOADING); if (!$ostatus) { WhBaseModel::rollback(); $data = array("data" => array('更新发货单状态失败,请联系负责人!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } WhPushModel::pushOrderStatus($ebay_id, 'PKS_WAITING_LOADING', $_SESSION['userId'], time()); //状态推送,需要改为待装车扫描(订单系统提供状态常量) WhBaseModel::commit(); $data = array("data" => array('绑定成功,请扫描另外一个发货单!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goOkMsgPage($data); } else { $result_tracking_count = $result_tracking_count['trackingCount']; //发货单需要绑定跟踪号的数量 $count_binding = WhOrderTracknumberModel::count($array_count); //发货单已经绑定跟踪号的数量 if ($result_tracking_count > $count_binding) { WhBaseModel::begin(); $result_insert = WhOrderTracknumberModel::insert($data_insert); if (!$result_insert) { WhBaseModel::rollback(); $data = array("data" => array('跟踪号绑定失败,请联系负责人!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } $num = $result_tracking_count - $count_binding - 1; if ($num == 0) { //更新发货表状态 $ostatus = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($ebay_id, $status = PKS_WAITING_LOADING); if (!$ostatus) { WhBaseModel::rollback(); $data = array("data" => array('更新发货单状态失败,请联系负责人!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } WhPushModel::pushOrderStatus($ebay_id, ' ', $_SESSION['userId'], time()); //状态推送,需要改为待装车扫描(订单系统提供状态常量) WhBaseModel::commit(); $data = array("data" => array('绑定成功,该发货单不需要绑定跟踪号了!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); } else { WhBaseModel::commit(); $data = array("data" => array('绑定成功,该发货单还需要绑定' . $num . '个跟踪号!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goOkMsgPage($data); } } else { $data = array("data" => array('绑定失败,绑定的跟踪号已经够' . $result_tracking_count . '个,请扫描另外一个发货单!'), 'link' => 'index.php?mod=expressRecheck&act=trackNumberInput'); goErrMsgPage($data); exit; } } $navlist = array(array('url' => '', 'title' => '出库'), array('url' => 'index.php?mod=expressRecheck&act=ExpressList', 'title' => '快递待复核'), array('url' => '', 'title' => '快递待复核数据导入 ')); $this->smarty->assign('navlist', $navlist); $toptitle = '待复核'; // 顶部链接 $this->smarty->assign('toptitle', $toptitle); $toplevel = 2; // 顶层菜单 $this->smarty->assign('toplevel', $toplevel); $secondlevel = '28'; // 当前的二级菜单 $this->smarty->assign('secondlevel', $secondlevel); $this->smarty->assign('secnev', 3); // 二级导航 $this->smarty->assign('list', TrackInfoRecordModel::$data); $this->smarty->display('tracknumimport.htm'); }
/** * pda_partitionCheckingAct::act_scanOrderReview() * 在PDA扫描分区编号后对订单号进行分区复核 * @author cxy * @return boolean */ public function act_scanOrderReview() { $userId = $_SESSION['userId']; $ebay_id = trim($_POST['ebay_id']); $ebay_id = substr($ebay_id, -22); $partion = trim($_POST['partion']); $package_id = intval(trim($_POST['package_id'])); if (empty($userId)) { self::$errCode = '0'; self::$errMsg = '系统登录超时,请先关闭浏览器 然后登录扫描!!'; return false; } //先核对订单 //兼容 EUB或者 包裹 扫描的是 trackno 而非ebayid 拿LN229773466CN追踪号对应1012970发货单号测试 $p_real_ebayid = '#^\\d+$#'; $p_trackno_eub = '#^(LK|RA|RI|RL|RB|RM|RC|RD|RR|RF|LN|LM|AG)\\d+(CN|HK|DE200)$#'; $p_trackno_ups = '#^(BLVS|1ZR)\\d+$#'; $p_ups = '/^(1ZA)/'; $is_eub_package_type = false; if (preg_match($p_real_ebayid, $ebay_id)) { } else { if (preg_match($p_trackno_eub, $ebay_id)) { $is_eub_package_type = true; } else { if (preg_match($p_trackno_ups, $ebay_id)) { $is_eub_package_type = true; } else { if (preg_match($p_ups, $ebay_id)) { $is_eub_package_type = true; } else { self::$errCode = '001'; self::$errMsg = '订单号[' . $ebay_id . ']格式有误'; return false; } } } } if (strlen($ebay_id) > 20) { $is_eub_package_type = true; } if ($is_eub_package_type == true) { //$is_eub_package_type是真的时候$ebay_id是跟踪号 $info = orderWeighingModel::selectOrderId($ebay_id); if (!$info) { self::$errCode = 501; self::$errMsg = "此跟踪号不存在!"; return false; } //得到发货单号 $shipOrderId = $info[0]['shipOrderId']; } else { $shipOrderId = $ebay_id; } //得到发货单明细 $order_records = WhOrderPartionRecordsModel::get_OrderPartionRecords($shipOrderId); if (empty($order_records)) { self::$errCode = 0; self::$errMsg = "此跟踪号/发货单号还没有进行分区!"; return false; } if ($order_records['packageId'] != $package_id) { self::$errCode = 0; self::$errMsg = "此跟踪号/发货单号应该在{$order_records['packageId']}口袋编号中!"; return false; } if ($order_records['partion'] != $partion) { self::$errCode = 0; self::$errMsg = "此跟踪号/发货单号没有在{$partion}分区中!"; return false; } $where = "where id={$shipOrderId}"; $order = orderPartionModel::selectOrder($where); if (!$order) { self::$errCode = 0; self::$errMsg = "此发货单不存在!"; return false; } if ($order[0]['orderStatus'] != PKS_DISTRICT_CHECKING) { self::$errCode = 0; self::$errMsg = "此发货单状态不是在待分区复核!"; return false; } $review_list = WhWaveOrderPartionScanReviewModel::get_reviewById($shipOrderId); if (!empty($review_list)) { self::$errCode = 0; self::$errMsg = "此发货单已经分区复核过了!"; return false; } else { WhBaseModel::begin(); $data = array('shipOrderId' => $shipOrderId, 'partion' => $partion, 'userId' => $userId, 'scantime' => time(), 'packageId' => $package_id); $result = WhWaveOrderPartionScanReviewModel::insert($data); if ($result) { $update = WhWaveOrderPartionScanReviewModel::updateOrderRecords($shipOrderId, $userId); if (!$update) { self::$errCode = '206'; self::$errMsg = '更新操作记录失败,请联系负责人!'; WhBaseModel::rollback(); return false; } //更新发货表状态 $ostatus = WhWaveOrderPartionScanReviewModel::updateShippingOrderStatus($shipOrderId, $status = PKS_PRINT_SHIPPING_INVOICE); if (!ostatus) { self::$errCode = 608; self::$errMsg = "更新发货单状态失败!"; WhBaseModel::rollback(); return false; } WhPushModel::pushOrderStatus($shipOrderId, 'PKS_PRINT_SHIPPING_INVOICE', $_SESSION['userId'], time()); //状态推送,需要改为待打印面单(订单系统提供状态常量) } else { self::$errCode = '206'; self::$errMsg = '该订单分区复核失败,请联系负责人!'; WhBaseModel::rollback(); return false; } self::$errCode = '200'; self::$errMsg = '该订单分区正确,请复核下一订单!'; WhBaseModel::commit(); return true; } }
public function recordDataFromExecl_all() { // echo $_FILES['excelsheet']['tmp_name'];exit; $parseresult = $this->parsexls($_FILES['excelsheet']['tmp_name']); if (empty($parseresult)) { return FALSE; } $date = trim($_POST['date']); $time = strtotime($date); $time2 = $time + 60 * 60 * 24; $sql = "select * from wh_order_tracknumber where createdTime>=" . "'{$time}' and createdTime <" . "'{$time2}'"; $res = $this->dbconn->query($sql); $resrows = array(); while ($row = mysql_fetch_assoc($res)) { $resrows[$row['tracknumber']] = $row; } foreach ($resrows as $key => $val) { if (array_key_exists($key, $parseresult)) { unset($parseresult[$key]); } } $imar = $parseresult; if (count($parseresult) == 0) { self::$errCode = 0; self::$errMsg = ''; self::$data = $imar; return true; } // echo '<pre>'; // print_r($parseresult);exit; $sqlstr = 'insert into wh_order_tracknumber (`shipOrderId`,`tracknumber`,`createdTime`) values '; $sqlar = array(); // $time = time(); foreach ($parseresult as $val) { $val[1] = mysql_real_escape_string($val[1]); $val[2] = mysql_real_escape_string($val[2]); $sqlar[] = "('{$val['1']}', '{$val['2']}', '{$time}')"; } $sqlstr .= implode(',', $sqlar); // echo $sqlstr;exit; WhBaseModel::begin(); $result = $this->dbconn->query($sqlstr); $insertnum = mysql_affected_rows(); if (!$result) { // 导入失败 WhBaseModel::rollback(); return FALSE; } else { $is_array = array(); //发货单号是否已经存在 // echo '<pre>'; // print_r($parseresult); foreach ($parseresult as $list) { if (in_array($list[1], $is_array)) { continue; } $shipOrderId = $list[1]; // $upstatus_sql = 'update wh_shipping_order set orderStatus='.PKS_WAITING_LOADING.' where id='.$list['shipOrderId']; $result_update = WhShippingOrderModel::update_shipping_order_by_id("id = '{$shipOrderId}'", "orderStatus=" . PKS_WAITING_LOADING); if (empty($result_update)) { WhBaseModel::rollback(); return FALSE; } WhPushModel::pushOrderStatus($shipOrderId, 'PKS_WAITING_LOADING', $_SESSION['userId'], time()); //状态推送 } } WhBaseModel::commit(); self::$data = $imar; return true; }