/** * 通过分区ID和用户ID获取订单分区记录 * @param $partitionId * @param $userId * @return array() * @author cmf */ public function getPartionRecords($partitionId = 0, $userId = 0) { if (!$partitionId || !$userId) { return array(); } $result = WhOrderPartionRecordsModel::find("partitionId='" . $partitionId . "' AND packageId=0 AND scanUserId='" . $userId . "' group by packageId", "count(shipOrderId) as totalnum,sum(weight) as totalweight"); return $result; }
/** * 分区操作 * @author czq */ public function act_checkPartion() { if (!$_SESSION['userId']) { $result = array('status' => 0, 'msg' => '请先登录系统'); echo json_encode($result); exit; } $shipOrderId = trim($_REQUEST['shipOrderId']); $shipOrder = WhShippingOrderModel::find($shipOrderId); if (empty($shipOrder)) { $result = array('status' => 'A00', 'msg' => '发货单信息不存在'); echo json_encode($result); exit; } if ($shipOrder['orderStatus'] != PKS_WDISTRICT) { $result = array('status' => 'A00', 'msg' => '发货单非待分区状态,不能分区'); echo json_encode($result); exit; } if (empty($shipOrder['channelId'])) { $result = array('status' => 'A00', 'msg' => '发货单在申请运输方式中,请稍后分区'); echo json_encode($result); exit; } $partition = WhTransportPartitionModel::getPartition($shipOrder['channelId'], $shipOrder['countryName']); if ($partition) { $vo = WhOrderPartionRecordsModel::find("shipOrderId='" . $shipOrderId . "'"); if (!$vo) { $data = array('shipOrderId' => $shipOrderId, 'packageId' => 0, 'partitionId' => $partition['id'], 'weight' => $shipOrder['orderWeight'], 'partion' => $partition['title'], 'scanUserId' => $_SESSION['userId'], 'scanTime' => time(), 'modifyTime' => 0, 'note' => '', 'is_delete' => 0, 'storeId' => 0); WhOrderPartionRecordsModel::insert($data); $result = array('status' => $partition['code'], 'partition' => $partition['partition'], 'msg' => $partition['title']); } else { if ($vo['packageId']) { $result = array('status' => 'A00', 'partition' => $partition['partition'], 'msg' => '已打包,不能再分区'); } else { $result = array('status' => $partition['code'], 'partition' => $partition['partition'], 'msg' => '包裹已分拣,分区为: ' . $partition['title']); } } } else { $result = array('status' => 'A00', 'partition' => '', 'msg' => '当前国家未分区,请联系销售人员'); } echo json_encode($result); exit; }