public function view_waveinit() { $waveId = WhWaveInfoModel::number_decode($_POST['waveId']); //判断每个区域是否已配货完结 $list = WhWaveReceiveRecordModel::select("waveId='{$waveId}'"); if (!$list) { $result = array('status' => 'A00', 'msg' => '配货单收货记录不存在'); echo json_encode($result); exit; } else { $areas = array(); foreach ($list as $val) { if ($val['scanStatus'] < 2) { $areas[] = $val['area']; } } if ($areas) { $result = array('status' => 'A00', 'msg' => '部分区域未完成收货,暂不能执行分拣<br/>' . implode(', ', $areas)); echo json_encode($result); exit; } } //分配筒号(亮灯) $orderlist = WhWaveShippingRelationModel::select("waveId='{$waveId}' AND is_delete=0 order by shipOrderId asc"); $light = 1; $shipOrderPickData = array(); foreach ($orderlist as $val) { $data = array('pickLight' => $light, 'pickTime' => time(), 'pickUserId' => $_SESSION['userId']); WhWaveShippingRelationModel::update($data, $val['id']); //生成发货单投放记录表 $shipOrderPickData[] = array('waveId' => $waveId, 'shipOrderId' => $val['shipOrderId'], 'pickStatus' => 0, 'pickTime' => 0, 'pickUserId' => 0, 'is_delete' => 0); $light++; } //查看是否有此波次的发货单投放记录 $shipOrderPick = WhWaveShippingPickRecordModel::find(' waveId=' . $waveId); if (!$shipOrderPick) { WhWaveShippingPickRecordModel::insert($shipOrderPickData, true); } //生成分拣记录表 $pick = WhWavePickRecordModel::find("waveId='{$waveId}'"); if (!$pick) { $list = WhShippingOrderdetailModel::getShippingOrderSkuList($waveId); foreach ($list as $val) { $data = array('waveId' => $val['waveId'], 'shipOrderId' => $val['shipOrderId'], 'sku' => $val['sku'], 'skuAmount' => $val['amount'], 'amount' => 0, 'pickStatus' => 0, 'pickUserId' => 0, 'pickTime' => 0, 'deleteUserId' => '0', 'deleteTime' => '0', 'is_delete' => '0'); $picklist[] = $data; } WhWavePickRecordModel::insert($picklist, true); } //扫描配货单的时候,查看配货单是否已经配货完成 $shipOrderPicks = WhWaveShippingPickRecordModel::select(' waveId=' . $waveId . ' AND pickStatus = 0', '*'); $hasShippingPick = false; $message = '配货单筒号分配正常,可以执行分拣(当前流程是SKU分拣)'; if (count($shipOrderPicks) > 0) { $hasShippingPick = true; $message = '配货单筒号分配正常,可以执行分拣(当前流程是发货单投放)'; } $result = array('status' => 'A99', 'hasShippingPick' => $hasShippingPick, 'msg' => $message); echo json_encode($result); }
//发票信息 $detail = WhShippingOrderdetailModel::getShipDetails($orderid); $tPrice = 0; if ($detail) { foreach ($detail as $values) { $prices += $detail['itemPrice'] * $detail['amount']; } } $tPrice = $tPrice != 0 ? round(floatval($tPrice), 4) : 0; // $sql = "SELECT SUM(ebay_itemprice*ebay_amount) as tPrice FROM ebay_orderdetail WHERE ebay_ordersn = '{$ordersn}'"; //$query = $dbcon->execute($sql); // $result = $dbcon->fetch_one($query); // $tPrice = isset($result['tPrice']) ? round(floatval($result['tPrice']),4) : 0; $nPrice = rand(140, 190); $pFlag = $tPrice > 200 ? true : false; $result = WhShippingOrderdetailModel::select_datail_category($orderid); // $sql = "SELECT b.goods_category,a.sku,a.ebay_itemtitle,a.ebay_amount,a.ebay_itemprice FROM ebay_orderdetail as a // LEFT JOIN ebay_goods AS b ON a.sku = b.goods_sn // WHERE a.ebay_ordersn = '{$ordersn}'"; //$query = $dbcon->execute($sql); // $result = $dbcon->getResultArray($query); $lineitem = ""; foreach ($result as $val) { $category = $val['goodsCategory']; if (substr($category, 0, 2) == '1-') { $enname = str_replace(array("'", "´", "&", "&"), array("'", "'", " ", " "), '(cotton:95%,spandex:5%)' . $val['itemTitle']); } else { $enname = str_replace(array("'", "´", "&", "&"), array("'", "'", " ", " "), $val['itemTitle']); } $count = $val['amount']; $price = $val['itemPrice'];
public function act_manualSortingCheck() { $userId = $_SESSION['userId']; $waveId = isset($_POST['waveId']) ? $_POST['waveId'] : ""; $where = "number='{$waveId}'"; $waveInfo = WhWaveInfoModel::get_wave_info("*", $where); if (!$waveInfo) { self::$errCode = 502; self::$errMsg = "此配货单号不存在!"; return false; } if ($waveInfo[0]['waveStatus'] != WAVE_FINISH_GET_GOODS) { self::$errCode = 514; self::$errMsg = "此配货单不在【配货完成】状态,不能进行分拣操作!"; return false; } if ($waveInfo[0]['waveType'] == 3) { self::$errCode = 518; self::$errMsg = "此配货单属于多SKU生成的配货单,不能进行人工分拣!"; return false; } //一个发货单对应多个配货单的时候,发货单是唯一的, if ($waveInfo[0]['waveType'] == 1) { $waveId = $waveInfo[0]['id']; $result = WhWaveShippingRelationModel::select_not_scanning($waveId); $shipOrderId = $result[0]['shipOrderId']; if ($result[0]['pickUserId'] != 0) { self::$errCode = 520; self::$errMsg = "此配货单已经分拣过了!"; return false; } WhShippingOrderModel::begin(); $update = WhWaveShippingRelationModel::update(array('pickUserId' => $userId, 'pickTime' => time()), array('is_delete' => 0, 'waveId' => $waveId)); if (!$update) { self::$errCode = 519; self::$errMsg = "扫描该配货单失败,请联系负责人!"; WhShippingOrderModel::rollback(); return false; // $result = WhWaveShippingRelationModel::getShippingOrderIdsByWaveId($waveId); //$shipOrderId = $result[0]['shipOrderId']; //查询还没有扫描的配货单 } $select_not_scanning = WhWaveShippingRelationModel::select_not_scanning_by_id($shipOrderId); $not_scanning_waveId = ''; //还没有分拣的配货单 if ($select_not_scanning) { foreach ($select_not_scanning as $val) { $not_scanning_waveId .= $val['waveId'] . ','; } self::$errMsg = "扫描该配货单'{$waveId}'成功,对应发货单'{$shipOrderId}'的配货单'{$not_scanning_waveId}'还没有分拣!"; } else { self::$errMsg = "扫描该配货单'{$waveId}'成功,对应的发货单'{$shipOrderId}'已经分拣完成,请处理完成之后拿去复核!"; //获取一个发货单对应多个配货单的每个配货单号 $result = OmAvailableModel::getTNameList("wh_wave_shipping_relation", "waveId", "where shipOrderId='{$shipOrderId}' and is_delete=0 "); $wave_all = ''; foreach ($result as $values) { $wave_all .= $values['waveId'] . ','; } $wave_all = trim($wave_all, ','); //得到该发货单下所有配货单的信息 $scan_record = OmAvailableModel::getTNameList("wh_wave_scan_record", "waveId,sku,skuAmount,amount", "where waveId in ('{$wave_all}') and scanStatus = 1 and is_delete=0 "); $picklist_all = array(); foreach ($scan_record as $record) { $data = array('waveId' => $record['waveId'], 'shipOrderId' => $shipOrderId, 'sku' => $record['sku'], 'skuAmount' => $record['skuAmount'], 'amount' => $record['amount'], 'pickStatus' => 1, 'pickUserId' => intval($_SESSION['userId']), 'pickTime' => time(), 'deleteUserId' => '0', 'deleteTime' => '0', 'is_delete' => '0'); $picklist_all[] = $data; } if (!WhWavePickRecordModel::insert($picklist_all, true)) { WhShippingOrderModel::rollback(); self::$errCode = 517; self::$errMsg = "该配货单插入分拣记录失败!"; return false; } $where = "id = '{$shipOrderId}' AND orderStatus='" . PKS_WAITING_SORTING . "'"; if (!WhShippingOrderModel::update_shipping_order($where, "orderStatus='" . PKS_WIQC . "'")) { WhShippingOrderModel::rollback(); self::$errCode = 516; self::$errMsg = "此配货单所属发货单{$shipOrderId}更新状态失败!"; return false; } } WhPushModel::pushOrderStatus($shipOrderId, 'PKS_WIQC', $_SESSION['userId'], time()); //状态推送,需要改为待复核单(订单系统提供状态常量) WhShippingOrderModel::commit(); self::$errCode = 200; return true; } /* if(empty($waveInfo[0]['sku'])){ self::$errCode = 515; self::$errMsg = "此配货单不属于单SKU生成的配货单,不能进行人工分拣!"; return false; } */ $waveId = $waveInfo[0]['id']; //echo $waveId; $shippOrders = WhWaveShippingRelationModel::getShippingOrderIdsByWaveId($waveId); //var_dump($shippOrders); WhShippingOrderModel::begin(); foreach ($shippOrders as $shippOrder) { $shipOrderId = $shippOrder['shipOrderId']; $where = "id = '{$shipOrderId}' AND orderStatus='" . PKS_WAITING_SORTING . "'"; if (!WhShippingOrderModel::update_shipping_order($where, "orderStatus='" . PKS_WIQC . "'")) { WhShippingOrderModel::rollback(); self::$errCode = 516; self::$errMsg = "此配货单所属发货单{$shipOrderId}更新状态失败!"; return false; } } $pick = WhWavePickRecordModel::find("waveId='{$waveId}'"); if (!$pick) { $picklist = array(); $list = WhShippingOrderdetailModel::getShippingOrderSkuList($waveId); foreach ($list as $val) { $data = array('waveId' => $val['waveId'], 'shipOrderId' => $val['shipOrderId'], 'sku' => $val['sku'], 'skuAmount' => $val['amount'], 'amount' => 0, 'pickStatus' => 1, 'pickUserId' => intval($_SESSION['userId']), 'pickTime' => time(), 'deleteUserId' => '0', 'deleteTime' => '0', 'is_delete' => '0'); $picklist[] = $data; } if (!WhWavePickRecordModel::insert($picklist, true)) { WhShippingOrderModel::rollback(); self::$errCode = 517; self::$errMsg = "该配货单插入分拣记录失败!"; return false; } else { foreach ($picklist as $lists) { WhPushModel::pushOrderStatus($lists['shipOrderId'], 'PKS_WIQC', $_SESSION['userId'], time()); //状态推送,需要改为待复核单(订单系统提供状态常量) } } } WhShippingOrderModel::commit(); self::$errCode = 200; self::$errMsg = "该配货单分拣成功,请处理完成之后拿去复核!"; return true; }
/** * OrderPrintAct::get_all_sku_info() * 获取发货单详细料号信息 * @param int $shipOrderId * @return void */ public function get_all_sku_info($shipOrderId) { $shipOrderId = intval($shipOrderId); $detail = array(); $totalqty = 0; if ($shipOrderId) { $order_detail = WhShippingOrderdetailModel::getShipDetailUnionPcGoods($shipOrderId); foreach ($order_detail as $val) { $totalqty += $val['amount']; $has_packingstatus = $val['isPacking'] == '1' ? 'Y ' : 'N '; $detail[$val['sku']] = array('sku' => $val['sku'], 'info' => $has_packingstatus . '[' . $val['pName'] . '] ' . $val['sku'] . '*' . $val['amount'], 'spu' => $val['spu'], 'itemTitle' => $val['itemTitle'], 'itemPrice' => $val['itemPrice'], 'amount' => $val['amount'], 'pName' => $val['pName'], 'pmId' => $val['pmId'], 'category' => $val['goodsCategory'], 'goodsWeight' => $val['goodsWeight'], 'packStatus' => $has_packingstatus); } $detail = array_filter($detail); } $detail['totalqty'] = $totalqty; return $detail; }
/** * WaveBuildAct::split_signle_shipOrder() * 单个发货单拆分成多个配货单 * @param int $shipOrderId 订单ID * @param array $order_detail 订单明细 * @return void */ public function split_signle_shipOrder($shipOrderId, $order_detail = '') { $shipOrderId = intval($shipOrderId); if (empty($order_detail)) { $order_detail = WhShippingOrderdetailModel::getShipDetails($shipOrderId); } $new_order_detail = array(); foreach ($order_detail as $val) { if ($val['amount'] > 1) { for ($i = 1; $i <= $val['amount']; $i++) { $new_order_detail[] = array('sku' => $val['sku'], 'amount' => 1, 'positionId' => $val['positionId'], 'pName' => $val['pName']); } } else { $new_order_detail[] = $val; } } $per_wave = array(); //每个波次料号临时存放表 foreach ($new_order_detail as $val) { $per_wave[] = $val; $limit_info = self::get_order_limit_info($per_wave); //获取波次临时存放表的总重量、体积、料号数量信息。 $is_wave = self::judge_split_wave($limit_info); //判断是否符合波次拆分规则 if ($is_wave == TRUE) { array_pop($per_wave); //将最后一个加入的料号剔除 $wave_detail = $per_wave; $per_wave = array(); if (empty($wave_detail)) { $wave_detail[] = $val; } else { $per_wave[] = $val; } self::make_wave($shipOrderId, 0, 1, $wave_detail, 1); } } if (!empty($per_wave)) { self::make_wave($shipOrderId, 0, 1, $per_wave, 1); } }
/** * 生成配货单明细 */ private function createWaveScanRecord($waveId) { //检查是否已生成配货单明细 $wave = WhWaveScanRecordModel::find("waveId='{$waveId}'"); if (!$wave) { $skulist = WhShippingOrderdetailModel::getShippingOrderSkuList($waveId); $list = array(); foreach ($skulist as $val) { if ($list[$val['sku']]) { $list[$val['sku']]['skuAmount'] = $list[$val['sku']]['skuAmount'] + $val['amount']; } else { $data = array('waveId' => $val['waveId'], 'sku' => $val['sku'], 'skuAmount' => $val['amount'], 'pName' => $val['pName'], 'storey' => $val['storey'], 'area' => $val['areaName']); $list[$val['sku']] = $data; } } WhWaveScanRecordModel::begin(); $result = WhWaveScanRecordModel::insert($list, true); if ($result) { WhWaveScanRecordModel::commit(); } else { WhWaveScanRecordModel::rollback(); } } }
$ebay_userid = $order['platformUsername']; //买家ID $ebay_username = $order['username']; $ebay_account = CommonModel::getAccountNameById($order['accountId']); //店铺账号 $ebay_state = $order['state']; $ebay_city = $order['city']; $ebay_street = $order['street']; $ebay_address = $ebay_state . $ebay_city . $ebay_street; //买家地址 $ebay_phone = $order['landline']; $ebay_phone1 = $order['phone']; //$ebay_ordersn = $order['ebay_ordersn']; //order表联系orderdetail表的foreginkey $tel1 = !$order['landline'] ? "" : str_replace('-', '', $order['landline']); $tel = $tel1 ? $tel1 : ($order['phone'] ? $order['phone'] : ""); $detail = WhShippingOrderdetailModel::getShipDetails($shipOrderId); //获取发货单明细 $totalAmount = 0; //总件数 $goodsInfo = ""; //订单中的商品sku及对应数量的组合信息,用"/"隔开 foreach ($detail as $val) { $totalAmount += $val['amount']; $sku = $val['sku']; $cs = strstr($val['itemTitle'] == '##' ? "" : $val['itemTitle'], '#'); //截取itemtile字段,得到color and size $goodsInfo = $goodsInfo . $sku . ' ' . $cs . $val['amount'] . '件/ '; } $count = count($detail); ?> <div id="main">
public function getTaoBaoOrderInfo($orderInfo) { $orderInfo = $orderInfo; // $sod_obj = new ShipingOrderDetailModel(); foreach ($orderInfo as &$info) { $totalAmount = 0; //总件数 $goodsInfo = ""; //订单中的商品sku及对应数量的组合信息,用"/"隔开 $orderDetail = WhShippingOrderdetailModel::getShipDetails($info['id']); foreach ($orderDetail as $detail) { $totalAmount += $detail['amount']; $cs = strstr($detail['itemTitle'] == '##' ? "" : $detail['itemTitle'], '#'); //截取itemtile字段,得到color and size $goodsInfo = $goodsInfo . $detail['sku'] . ' ' . $cs . $detail['amount'] . '件/ '; } $address = $info['state'] . $info['city'] . $info['street']; //买家地址 $info['goodsInfo'] = $totalAmount . '件 /' . $goodsInfo; $info['address'] = $address; } return $orderInfo; }
/** * 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; }