'/index.php/Retail/AllocationTube/export', 'adopt' => '/index.php/Retail/AllocationTube/adopt', 'OrderInfo' => '/index.php/Retail/AllocationTube/details', 'WarehouseInfo' => '/index.php/Retail/AllocationTube/allocation' ); $authArr = checkFunction($arr); $this->assign('authArr', $authArr); $user = session("merchant_userinfo"); $merchant_id = $user['id']; $store = D('Store')->getSelect(array('merchantid' => $merchant_id, 'state' => 0)); $this->assign('store', json_encode($store)); $this->display(); } /*门店调拨管理列表 *@param $merchant_id 商户id *@param $store_id 门店id *@param $examine_status 商户审核 0未审核 1审核通过 2审核失败 *@param $where['type'] 0其他出库 1退货出库 2盘亏出库 3调拨出库 * @param $where['status'] 0未出库 1出库成功' */ public function allOrderList() { $user = session("merchant_userinfo"); $merchant_id = $user['id']; $data = I("post."); $page = $data['page']; $limit = $data['limit']; $order_number = $data['order_number']; $add_time = $data['add_time']; $store_id = $data['store_id']; $examine_status = $data['examine_status']; if (!empty($order_number)) { $where['order_number'] = $order_number; } if (!empty($add_time)) { $start_time = strtotime($add_time[0]); $end_time = strtotime($add_time[1]); $where['add_time'] = array('between', array($start_time, $end_time)); } if (!empty($store_id)) { $where['store_id'] = $store_id; } if ($examine_status != '') { switch ($examine_status) { case 0: case 1: case 2: $where['examine_status'] = $examine_status; break; case 3: $where['examine_status'] = 1; $where['warehousing_status'] = 0; break; case 4: $where['examine_status'] = 1; $where['warehousing_status'] = 1; break; } } $where['merchant_id'] = $merchant_id; $where['type'] = 3; $where['status'] = 1; $orderList = D('SStockOutOrder')->getSelect($where, $page, $limit); if ($orderList) { $count = D('SStockOutOrder')->getCount($where); foreach ($orderList as $key => &$val) { $val['index'] = $key + 1; $val['store_name'] = D('Store')->getStoreName(array('id' => $val['store_id'])); $val['transfer_name'] = D('Store')->getStoreName(array('id' => $val['transfer_to_store_id'])); $val['money_total'] = round($val['money_total'], 2); $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); $val['warehouse_time'] = date('Y-m-d H:i:s', $val['warehouse_time']); switch ($val['examine_status']) { case 0: $val['examine_name'] = '未审核'; break; case 1: if (!$val['warehousing_status']) { $val['examine_name'] = '审核通过未入库'; } else { $val['examine_name'] = '审核通过已入库'; $val['real_money_total'] = round($val['real_money_total'], 2); } break; case 2: $val['examine_name'] = '审核拒绝'; break; } } } $res['status'] = 1; $res['msg'] = ''; $res['data'] = $orderList; $res['count'] = $count ? $count : 0; $this->ajaxReturn($res); } /*门店出库详情 * */ public function details() { $arr = array( 'exportOperation' => '/index.php/Retail/AllocationTube/detailsExport', ); $authArr = checkFunction($arr); $this->assign('authArr', $authArr); $id = I('get.id'); $where['id'] = $id; $info = D('SStockOutOrder')->getFind($where); $info['add_time'] = date('Y-m-d H:i:s', $info['add_time']); $info['remarks'] = str_replace("\n", "", $info['remarks']); $warehouse = D('SSaleWarehouse')->getFindField(array('id' => $info['warehouse_id']), "name"); $this->assign('id', $id); $this->assign('info', $info); $this->assign('warehouse', $warehouse); $this->display(); } /*入库详情 * @param $where['stock_out_id'] 出库单id * @param $where['type'] 入库类型 0其他入库 1采购入库 2补货入库 3盘盈入库 4商户调拨入库 5门店调拨入库 */ public function allocation() { $arr = array( 'exportOperation' => '/index.php/Retail/AllocationTube/allocationExport', ); $authArr = checkFunction($arr); $this->assign('authArr', $authArr); $id = I("get.id"); $where['stock_out_id'] = $id; $where['type'] = 5; $info = D('SWarehousingRecord')->getFind($where); $info['add_time'] = date('Y-m-d H:i:s', $info['add_time']); $info['remarks'] = str_replace("\n", "", $info['remarks']); $warehouse = D('SSaleWarehouse')->getFindField(array('id' => $info['warehouse_id']), "name"); $this->assign('id', $info['id']); $this->assign('info', $info); $this->assign('warehouse', $warehouse); $this->display(); } /*审核操作 * @param $type 门店调拨出库商户审核 0未审核 1审核通过 2审核失败 */ public function adopt() { $data = I('post.'); $result = A("Api/Inventory")->MerExamine($data); if($result['status'] == 1){ //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $platform_type = 3;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 if($data['type'] == 1){ $desc = '门店调拨管理-通过';//操作行为描述 }else if($data['type'] == 2){ $desc = '门店调拨管理-拒绝';//操作行为描述 } action_log($source,$platform_type,$request_data,$desc); } $this->ajaxReturn($result); } //导出 public function export() { $user = session("merchant_userinfo"); $merchant_id = $user['id']; $data = I("get."); $order_number = $data['order_number']; $add_time = $data['add_time']; $store_id = $data['store_id']; $examine_status = $data['examine_status']; if (!empty($order_number)) { $where['order_number'] = $order_number; } if (!empty($add_time)) { if(!is_array($add_time)){ $add_time = explode(',', $add_time); } $start_time = strtotime($add_time[0]); $end_time = strtotime($add_time[1]); $where['add_time'] = array('between', array($start_time, $end_time)); } if (!empty($store_id)) { $where['store_id'] = $store_id; } if ($examine_status != '') { $where['examine_status'] = $examine_status; } $where['merchant_id'] = $merchant_id; $where['type'] = 3; $where['status'] = 1; $orderList = D('SStockOutOrder')->getSelect($where); if ($orderList) { foreach ($orderList as $key => &$val) { $val['index'] = $key + 1; $val['store_name'] = D('Store')->getStoreName(array('id' => $val['store_id'])); $val['transfer_name'] = D('Store')->getStoreName(array('id' => $val['transfer_to_store_id'])); $val['money_total'] = strval(round($val['money_total'], 2)); $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); $val['warehouse_time'] = date('Y-m-d H:i:s', $val['warehouse_time']); switch ($val['examine_status']) { case 0: $val['examine_name'] = '未审核'; break; case 1: if (!$val['warehousing_status']) { $val['examine_name'] = '未入库'; } else { $val['examine_name'] = '已入库'; $val['real_money_total'] = round($val['real_money_total'], 2); } break; case 2: $val['examine_name'] = '审核失败'; break; } } } $fileds_name = "门店调拨单导出"; $arr = array( array('index', '序号'), array('add_time', '调拨时间'), array('warehouse_time', '入库时间'), array('order_number', '调拨单号'), array('store_name', '调拨门店'), array('transfer_name', '货至'), array('goods_species', '应收合计(种)'), array('money_total', '应收金额'), array('real_goods_species', '实收合计(种)'), array('real_money_total', '实收金额'), array('remarks', '备注'), array('examine_name', '货至状态'), ); $str = $fileds_name . ',导出日期:' . date('Y-m-d H:i:s', time()); getExcel($fileds_name, $arr, $orderList, $str); } //调拨详情导出 public function detailsExport() { $id = I('get.id'); $where['id'] = $id; $info = D('SStockOutOrder')->getFind($where); $info['add_time'] = date('Y-m-d H:i:s', $info['add_time']); $warehouse = D('SSaleWarehouse')->getFindField(array('id' => $info['warehouse_id']), "name"); $map['stock_out_id'] = $id; $detailsList = D('SStockOutGoods')->getSelect($map); if ($detailsList) { foreach ($detailsList as $key => &$val) { $val['index'] = $key + 1; $val['stock_num'] = strval(round($val['stock_num'], 3)); $val['stock_price'] = strval(round($val['stock_price'], 2)); $val['subtotal'] = strval(round($val['subtotal'], 2)); $val['sku_num'] = strval(round($val['sku_num'], 3)); if ($val['attribute_state'] == 2) { $val['goods_code'] = $val['sku_code']; $val['goods_number'] = $val['sku_goods_number']; } } } $fileds_name = "调拨详情导出"; $arr = array( array('index', '序号'), array('goods_name', '商品名称'), array('sku_name', '规格'), array('goods_number', '货号'), array('goods_code', '条码'), array('company', '单位'), array('sku_num', '规格基数'), array('stock_num', '数量'), array('stock_price', '调拨价'), array('subtotal', '合计'), array('remarks', '备注'), ); $str = array(); $str[0] = $fileds_name . ',导出日期:' . date('Y-m-d H:i:s', time()); $str[1] = '出库单号:' . $info['order_number'] . " 出库仓库:" . $warehouse . " 创建时间:" . $info['add_time']; $str[2] = '合计:' . $info['goods_species'] . " 金额:" . strval($info['money_total']); $str[3] = "备注:" . $info['remarks']; detailGetExcel($fileds_name, $arr, $detailsList, $str); } //入库详情导出 public function allocationExport() { $id = I("get.id"); $where['id'] = $id; $where['type'] = 5; $info = D('SWarehousingRecord')->getFind($where); $info['add_time'] = date('Y-m-d H:i:s', $info['add_time']); $warehouse = D('SSaleWarehouse')->getFindField(array('id' => $info['warehouse_id']), "name"); $map['warehouse_record_id'] = $id; $detailsList = D('SWarehousingGoods')->getSelect($map); if ($detailsList) { foreach ($detailsList as $key => &$val) { $val['index'] = $key + 1; $val['warehouse_num'] = strval(round($val['warehouse_num'], 3)); $val['warehouse_price'] = strval(round($val['warehouse_price'], 2)); $val['subtotal'] = strval(round($val['subtotal'], 2)); $val['sku_num'] = strval(round($val['sku_num'], 3)); if ($val['attribute_state'] == 2) { $val['goods_code'] = $val['sku_code']; $val['goods_number'] = $val['sku_goods_number']; } } } $fileds_name = "入库详情导出"; $arr = array( array('index', '序号'), array('goods_name', '商品名称'), array('sku_name', '规格'), array('goods_number', '货号'), array('goods_code', '条码'), array('company', '单位'), array('sku_num', '规格基数'), array('warehouse_num', '数量'), array('warehouse_price', '入库价'), array('subtotal', '合计'), array('remarks', '备注'), ); $str = array(); $str[0] = $fileds_name . ',导出日期:' . date('Y-m-d H:i:s', time()); $str[1] = '入库单号:' . $info['order_number'] . " 入库仓库:" . $warehouse . " 创建时间:" . $info['add_time']; $str[2] = '合计:' . $info['goods_species'] . " 金额:" . strval($info['money_total']); $str[3] = "备注:" . $info['remarks']; detailGetExcel($fileds_name, $arr, $detailsList, $str); } }