config['status_manage']; $method = Dever::db('shop/sell_order')->config['method']; $pay_method = Dever::db('shop/sell_order')->config['pay_method']; $pay_type = Dever::db('shop/sell_order')->config['pay_type']; $info_type = Dever::db($table)->config['config_type']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['shop_id']); $goods = Dever::db('shop/sell_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/sell_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $paydate = isset($v['paydate']) && $v['paydate'] ? date('Y-m-d H:i', $v['paydate']) : '-'; $operdate = $v['cdate'] ? date('Y-m-d H:i',$v['cdate']) : '-'; // $operdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; $total_cash = Dever::load("shop/lib/manage.getTotalCash", $v['id']); $v['refund_cash'] = $v['refund_cash'] ? $v['refund_cash'] : 0; $user = Dever::load("shop/lib/manage.user", $v['id']); #礼品卡 $card_name= ''; $code = Dever::db('card/code')->find(array('id'=>$v['card_code_id'])); if(isset($code) && $code && $code['card_id']){ $card = Dever::db('card/info')->find(array('id'=>$code['card_id'])); if(isset($card) && $card && $card['name']){ $card_name = $card['name']; } } if (!$v['card_code_cash']) { $v['card_code_cash'] = 0; } if (!$v['coupon_cash']) { $v['coupon_cash'] = 0; } if (!$v['refund_cash']) { $v['refund_cash'] = 0; } foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] >= 7) { $v['price'] = 0; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $v['refund_cash'] = $v1['price']*$v1['num']; $refund_status = '已退款'; } else { $num = '0'; $v['refund_cash'] = '0'; $refund_status = '未退款'; } if ($k1 == 0) { $goods_price = $v['price']; $d_total_cash = round($total_cash, 2); $d_price = round($v['price'], 2); $d_refund_cash = round($v['refund_cash'], 2); $d_card_code_cash = round($v['card_code_cash'], 2); $d_wallet_cash = round($v['wallet_cash'], 2); $d_coupon_cash = round($v['coupon_cash'], 2); $d_discount_cash = round($v['discount_cash'], 2); } else { $goods_price = 0; $d_total_cash = 0; $d_price = 0; $d_refund_cash = 0; $d_card_code_cash = 0; $d_wallet_cash = 0; $d_coupon_cash = 0; $d_discount_cash = 0; } $d = array ( $info['sid'], $info['name'], $info_type[$info['type']], $v['order_num'], $user, $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['price'], 2), round($v1['num'], 2), round($v1['price']*$v1['num'], 2), $method[$v['method']], $pay_method[$v['pay_method']], $cdate, $paydate, $operdate, $d_total_cash, $d_price, $d_refund_cash, $d_card_code_cash, $d_wallet_cash, $d_coupon_cash, $d_discount_cash, $pay_type[$v['pay_type']], $status[$v['status']], $card_name, ); $body[] = $d; if ($goods_info['price_type'] > 2 && isset($goods_info['goods']) && is_array($goods_info['goods'])) { foreach ($goods_info['goods'] as $v2) { if ($v2['code']) { //$v2['code'] = '-' . $v2['code']; } $p = $v2['price']; if (is_numeric($v2['num']) && is_numeric($v2['price'])) { $p = $v2['price']*$v2['num']; } $d = array ( $info['sid'], $info['name'], $info_type[$info['type']], $v['order_num'], $user, $v2['code'] . "\t", $v2['name'] . '('.$goods_info['name'].')', $sku, round($v2['price'], 2), round($v2['num'], 2), $p, $method[$v['method']], $pay_method[$v['pay_method']], $cdate, $paydate, $operdate, '', '', '', '', '', '', '', $pay_type[$v['pay_type']], $status[$v['status']], $card_name, ); $body[] = $d; } } } } return Dever::excelExport($body, $header, $file); } # 平台零售订单 public function p_sell_order($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('订单号', '收件人', '收件人手机', '收件人地址', '商品编码', '商品名称', '规格型号', '商品单价', '购买数量', '商品合计金额', '商品支付金额', '下单时间', '付款时间', '发货时间', '收货时间' , '订单总数量', '订单总金额', '订单实付金额', '礼品卡金额', '钱包金额', '优惠券金额', '代理优惠金额', '订单状态', '退款状态', '退款金额','礼品卡名称'); $table = 'shop/info'; $body = array(); $status = Dever::db('shop/sell_order')->config['status_manage']; $info_type = Dever::db($table)->config['config_type']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['shop_id']); if ($v['store_id']) { $store = Dever::db('store/info')->find($v['store_id']); } else { $store['name'] = ''; } $goods = Dever::db('shop/sell_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/sell_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $paydate = isset($v['paydate']) && $v['paydate'] ? date('Y-m-d H:i', $v['paydate']) : '-'; $operdate = $v['fadate'] ? date('Y-m-d H:i',$v['fadate']) : '-'; // $operdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; if ($v['fdate']) { $fdate = strstr($v['fdate'], '-') ? $v['fdate'] : date('Y-m-d H:i', $v['fdate']); } else { $fdate = '-'; } $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id'], 'sell_order'); $total_cash = Dever::load("shop/lib/manage.getTotalCash", $v['id']); $v['refund_cash'] = $v['refund_cash'] ? $v['refund_cash'] : 0; $address = Dever::load('passport/address')->getOne($v['uid'], $v['address_id']); if (!$v['card_code_cash']) { $v['card_code_cash'] = 0; } if (!$v['coupon_cash']) { $v['coupon_cash'] = 0; } if (!$v['refund_cash']) { $v['refund_cash'] = 0; } #礼品卡 $card_name= ''; $code = Dever::db('card/code')->find(array('id'=>$v['card_code_id'])); if(isset($code) && $code && $code['card_id']){ $card = Dever::db('card/info')->find(array('id'=>$code['card_id'])); if(isset($card) && $card && $card['name']){ $card_name = $card['name']; } } foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] >= 7) { $v['price'] = 0; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $v['refund_cash'] = $v1['price']*$v1['num']; $refund_status = '已退款'; } else { $num = '0'; $v['refund_cash'] = '0'; $refund_status = '未退款'; } if ($k1 == 0) { $goods_price = $v['price']; $d_num = round($v['num'], 2); $d_total_cash = round($total_cash, 2); $d_price = round($v['price'], 2); $d_card_code_cash = round($v['card_code_cash'], 2); $d_wallet_cash = round($v['wallet_cash'], 2); $d_coupon_cash = round($v['coupon_cash'], 2); $d_discount_cash = round($v['discount_cash'], 2); } else { $goods_price = 0; $d_num = 0; $d_total_cash = 0; $d_price = 0; $d_card_code_cash = 0; $d_wallet_cash = 0; $d_coupon_cash = 0; $d_discount_cash = 0; } $d = array ( $v['order_num'], isset($address['contact']) ? $address['contact'] : '', isset($address['mobile']) ? $address['mobile'] . "\t" : '', isset($address['address_info']) ? $address['address_info'] : '', //$store['name'], $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['price'], 2), round($v1['num'], 2), round($v1['price']*$v1['num'], 2), round($goods_price, 2), $cdate, $paydate, $operdate, $fdate, $d_num, $d_total_cash, $d_price, $d_card_code_cash, $d_wallet_cash, $d_coupon_cash, $d_discount_cash, $status[$v['status']], $refund_status, round($v['refund_cash'], 2), $card_name, ); $body[] = $d; if ($goods_info['price_type'] > 2 && isset($goods_info['goods']) && is_array($goods_info['goods'])) { foreach ($goods_info['goods'] as $k2 => $v2) { if ($v2['code']) { //$v2['code'] = '-' . $v2['code']; } $p = $v2['price']; if (is_numeric($v2['num']) && is_numeric($v2['price'])) { $p = $v2['price']*$v2['num']; } $goods_price1 = 0; $d = array ( $v['order_num'], isset($address['contact']) ? $address['contact'] : '', isset($address['mobile']) ? $address['mobile'] . "\t" : '', isset($address['address_info']) ? $address['address_info'] : '', //$store['name'], $v2['code'] . "\t", $v2['name'] . '('.$goods_info['name'].')', $sku, round($v2['price'], 2), round($v2['num'], 2), $p, round($goods_price1, 2), $cdate, $paydate, $operdate, $fdate, '', '', '', '', '', '', '', $status[$v['status']], '', '', ); $body[] = $d; } } } } return Dever::excelExport($body, $header, $file); } # 门店订货单 public function buy_order($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('门店编号', '门店名称', '门店类型', '供货商', '订货单号', '订货总数量', '订货单总金额', '商品编码', '商品名称', '规格型号', '订货单价', '订货数量', '商品合计金额', '订货日期', '发货日期', '订货单状态', '退款状态', '退款金额'); $table = 'shop/info'; $body = array(); $status = Dever::db('shop/buy_order')->config['status']; //$refund_status = Dever::db('shop/buy_order')->config['refund_status']; $info_type = Dever::db($table)->config['config_type']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['type_id']); $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/buy_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $fdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; $ydate = ($ps && $ps['ydate']) ? date('Y-m-d H:i', $ps['ydate']) : '-'; $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id']); $source = Dever::load("shop/lib/manage.buyInfo", $v['source_type'], $v['source_id']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $v['refund_cash'] = $v1['price']*$v1['num']; $refund_status = '已退款'; } else { $num = '0'; $v['refund_cash'] = '0'; $refund_status = '未退款'; } $d = array ( $info['sid'], $info['name'], $info_type[$info['type']], $source, $v['order_num'], round($v['num'], 2), round($v['price'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['price'], 2), round($v1['num'], 2), round($v1['price']*$v1['num'], 2), $cdate, $fdate, $status[$v['status']], $refund_status, $v['refund_cash'], ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } # 仓库订货单 public function store_buy_order($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('仓库名称', '供货商', '订货单号', '订货总数量', '入库单价', '商品编码', '商品名称', '规格型号', '商品订货数量', '订货日期', '发货日期', '收货日期', '订货单状态', '已退商品数量'); $table = 'store/info'; $body = array(); $status = Dever::db('shop/buy_order')->config['status']; //$refund_status = Dever::db('shop/buy_order')->config['refund_status']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['type_id']); $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/buy_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $fdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; $ydate = ($ps && $ps['ydate']) ? date('Y-m-d H:i', $ps['ydate']) : '-'; $num = Dever::load("shop/lib/manage.buyInfoRefundNum", $v['id']); $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id']); $v['refund_cash'] = $v['refund_cash'] ? $v['refund_cash'] : 0; $source = Dever::load("shop/lib/manage.buyInfo", $v['source_type'], $v['source_id']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $refund_status = '已退款'; } else { $num = '0'; $refund_status = '未退款'; } if ($v['source_type'] == 2) { $v1['p_price'] = 0; } $d = array ( $info['name'], $source, $v['order_num'], round($v['num'], 2), round($v1['p_price'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['num'], 2), $cdate, $fdate, $ydate, $status[$v['status']], $num, ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } # 仓库发货单 public function store_buy_order_fa($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('仓库名称', '门店编号', '门店名称', '门店类型', '订货单号', '订货总数量', '订货单总金额', '商品编码', '商品名称', '规格型号', '订货单价', '订货数量', '商品合计金额', '订货日期', '发货日期', '订货单状态', '退款状态', '已退商品数量', '退款金额'); $table = 'shop/info'; $body = array(); $status = Dever::db('shop/buy_order')->config['status']; //$refund_status = Dever::db('shop/buy_order')->config['refund_status']; $info_type = Dever::db($table)->config['config_type']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['type_id']); $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/buy_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $fdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; $ydate = ($ps && $ps['ydate']) ? date('Y-m-d H:i', $ps['ydate']) : '-'; $num = Dever::load("shop/lib/manage.buyInfoRefundNum", $v['id']); $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id']); $v['refund_cash'] = $v['refund_cash'] ? $v['refund_cash'] : 0; $source = Dever::load("shop/lib/manage.buyInfo", $v['source_type'], $v['source_id']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $v['refund_cash'] = $v1['price']*$v1['num']; $refund_status = '已退款'; } else { $num = '0'; $v['refund_cash'] = '0'; $refund_status = '未退款'; } $d = array ( $source, $info['sid'], $info['name'], $info_type[$info['type']], $v['order_num'], round($v['num'], 2), round($v['price'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['price'], 2), round($v1['num'], 2), round($v1['price']*$v1['num'], 2), $cdate, $fdate, $status[$v['status']], $refund_status, $num, round($v['refund_cash'], 2), ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } # 仓库调拨单 public function store_buy_order_diao($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('发货仓库名称', '收货仓库名称', '订货单号', '订货总数量', '商品编码', '商品名称', '规格型号', '订货数量', '订货日期', '发货日期', '订货单状态', '退款状态', '已退商品数量'); $table = 'store/info'; $body = array(); $status = Dever::db('shop/buy_order')->config['status']; //$refund_status = Dever::db('shop/buy_order')->config['refund_status']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['type_id']); $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/buy_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $fdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; $ydate = ($ps && $ps['ydate']) ? date('Y-m-d H:i', $ps['ydate']) : '-'; $num = Dever::load("shop/lib/manage.buyInfoRefundNum", $v['id']); $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id']); $v['refund_cash'] = $v['refund_cash'] ? $v['refund_cash'] : 0; $source = Dever::load("shop/lib/manage.buyInfo", $v['source_type'], $v['source_id']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $v['refund_cash'] = $v1['price']*$v1['num']; $refund_status = '已退款'; } else { $num = '0'; $v['refund_cash'] = '0'; $refund_status = '未退款'; } $d = array ( $source, $info['name'], $v['order_num'], round($v['num'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['num'], 2), $cdate, $fdate, $status[$v['status']], $refund_status, $num, ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } # 工厂发货单 public function factory_buy_order_fa($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('工厂名称', '收件人名称', '收件人类型', '订货单号', '订货总数量', '订货单总金额', '商品编码', '商品名称', '规格型号', '商品进货单价', '订货数量', '商品合计金额', '订货日期', '发货日期', '订货单状态', '已退商品数量', '退款金额'); $table = 'shop/info'; $body = array(); $status = Dever::db('shop/buy_order')->config['status']; //$refund_status = Dever::db('shop/buy_order')->config['refund_status']; $info_type = Dever::db($table)->config['config_type']; $order_type = Dever::db('shop/buy_order')->config['config_type']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } if ($v['type'] == 1) { $info = Dever::db('shop/info')->find($v['type_id']); } elseif ($v['type'] == 2) { $info = Dever::db('store/info')->find($v['type_id']); } $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id'])); $ps = Dever::db('shop/buy_order_ps')->find(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); $fdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-'; $ydate = ($ps && $ps['ydate']) ? date('Y-m-d H:i', $ps['ydate']) : '-'; $num = Dever::load("shop/lib/manage.buyInfoRefundNum", $v['id']); $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id']); $v['refund_p_cash'] = $v['refund_p_cash'] ? $v['refund_p_cash'] : 0; $source = Dever::load("shop/lib/manage.buyInfo", $v['source_type'], $v['source_id']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } if ($v['status'] == 8 || $v1['status'] == 3) { $num = $v1['num']; $v['refund_p_cash'] = $v1['p_price']*$v1['num']; } else { $num = '0'; $v['refund_p_cash'] = '0'; } $d = array ( $source, $info['name'], $order_type[$v['type']], $v['order_num'], round($v['num'], 2), round($v['p_price'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['p_price'], 2), round($v1['num'], 2), round($v1['p_price']*$v1['num'], 2), $cdate, $fdate, $status[$v['status']], $num, round($v['refund_p_cash'], 2), ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } # 门店出库单 public function out_order($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('门店编号', '门店名称', '门店类型', '出库单号', '出库总数量', '出库总金额', '商品编码', '商品名称', '规格型号', '订货单价', '订货数量', '商品合计金额', '出库日期', '出库类型', '出库状态'); $table = 'shop/info'; $body = array(); $status = Dever::db('shop/out_order')->config['config_status']; $config_type = Dever::db('shop/out_order')->config['config_type']; $config_type = $config_type(); $info_type = Dever::db($table)->config['config_type']; foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['type_id']); $goods = Dever::db('shop/out_order_goods')->select(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } $d = array ( $info['sid'], $info['name'], $info_type[$info['type']], $v['order_num'], round($v['num'], 2), round($v['price'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['price'], 2), round($v1['num'], 2), round($v1['price']*$v1['num'], 2), $cdate, $config_type[$v['out_type']]['name'], $status[$v['status']], ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } # 仓库出库单 public function store_out_order($data) { if (!$data) { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); $header = array('仓库名称', '出库单号', '出库总数量', '出库总金额', '商品编码', '商品名称', '规格型号', '门店进货单价', '订货数量', '商品合计金额', '出库日期', '出库类型', '出库状态'); $table = 'store/info'; $body = array(); $status = Dever::db('shop/out_order')->config['config_status']; $config_type = Dever::db('shop/out_order')->config['config_type']; $config_type = $config_type(); foreach ($data as $k => $v) { if (!is_array($v)) { continue; } $info = Dever::db($table)->find($v['type_id']); $goods = Dever::db('shop/out_order_goods')->select(array('order_id' => $v['id'])); $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']); foreach ($goods as $k1 => $v1) { $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } $d = array ( $info['name'], $v['order_num'], round($v['num'], 2), round($v['price'], 2), $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v1['price'], 2), round($v1['num'], 2), round($v1['price']*$v1['num'], 2), $cdate, $config_type[$v['out_type']]['name'], $status[$v['status']], ); $body[] = $d; } } return Dever::excelExport($body, $header, $file); } public function goods_log() { //Array ( [search_option_state] => 1 [search_api_goods_id] => 猪肉 [search_api_goods-info-code] => [search_option_status] => 0 [search_option_store_id] => 6 [search_option_start_cdate] => [search_option_end_cdate] => [search_option_sday] => 0 ) $data = Dever::input(); $where = array(); if (isset($data['search_option_store_id']) && $data['search_option_store_id']) { $where['store_id'] = $data['search_option_store_id']; } if (isset($data['search_option_status']) && $data['search_option_status']) { $where['status'] = $data['search_option_status']; } if (isset($data['search_option_start_cdate']) && $data['search_option_start_cdate']) { $where['start'] = $data['search_option_start_cdate']; } if (isset($data['search_option_end_cdate']) && $data['search_option_end_cdate']) { $where['end'] = $data['search_option_end_cdate']; } if (isset($data['search_api_goods_id']) && $data['search_api_goods_id']) { $goods_info = Dever::db('goods/info')->like(array('name' => $data['search_api_goods_id'])); if ($goods_info) { $where['goods_id'] = array_keys($goods_info); } } if (isset($data['search_api_goods-info-code']) && $data['search_api_goods-info-code']) { $goods_sku = Dever::db('goods/info_sku')->like(array('code' => $data['search_api_goods-info-code'])); if ($goods_sku) { $where['sku_id'] = array_keys($goods_sku); } } $goods = Dever::db('store/goods_log')->getDataByDate($where); $file = '仓库调整明细'; $header = array('仓库名称', '商品编码', '商品名称', '规格型号', '当前库存', '占用库存', '在途库存', '总库存', '调整数量', '调整后库存', '调整后总库存', '调整时间'); $body = array(); if ($goods) { foreach ($goods as $k => $v) { $info = Dever::db('store/info')->find($v['store_id']); $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']); if (isset($goods_info['sku'])) { $sku = $goods_info['sku']['string']; } else { $sku = ''; } $cdate = date('Y-m-d H:i', $v['cdate']); $d = array ( $info['name'], $goods_info['code'] . "\t", $goods_info['name'], $sku, round($v['cur_num'], 2), round($v['sell_num'], 2), round($v['online_num'], 2), round($v['total_num'], 2), round($v['num'], 2), round($v['after_cur_num'], 2), round($v['after_total_num'], 2), $cdate, ); $body[] = $d; } } else { Dever::alert('无导出数据'); } return Dever::excelExport($body, $header, $file); } #门店列表数据导出 public function shop_info ($data) { $header = array('店铺id', '店铺编号-一般为5位数字,不能重复', '门店名称', '联系人姓名', '联系人电话', '营业状态', '门店类型-自营为平台店,当没有找到加盟店时,将自动获取平台店', '合作状态', '所属代理商名称', '所属代理商手机号', '分账商户号','录入时间'); $body = array(); if ($data) { $type = Dever::db('shop/info')->config['config_type']; foreach ($data as $k => $v) { if ($v['open'] == 1) { $open = '开启'; } else { $open = '关闭'; } if ($v['status'] == 1) { $status = '合作中'; } else { $status = '已终止合作'; } $member_name = ''; $member_mobile = ''; if ($v['agent_mid'] && $v['agent_mid']>0) { $member = Dever::db('agent/member')->find($v['agent_mid']); if ($member) { $member_name = $member['name']; $member_mobile = $member['mobile']; } } $d = array ( $v['id'], $v['sid'], $v['name'], $v['truename'], $v['mobile'], $open, $type[$v['type']], $status, $member_name, $member_mobile, $v['mid'], date('Y-m-d H:i',$v['cdate']), ); $body[] = $d; } } else { Dever::alert('无导出数据'); } $file = Dever::input('excel_name'); return Dever::excelExport($body, $header, $file); } }