123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062 |
- <?php
- namespace Shop\Src;
- use Dever;
- set_time_limit(0);
- class Excel
- {
- # 门店零售单
- public function 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'];
- $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);
- }
- }
|