config; return $config['config_audit_type'][$audit_type] . $config['config_audit'][$audit]; } public function statDate($type, $day) { if ($type == 1) { $string = 'Y年m月'; } else { $string = 'Y年W周'; } return date($string, $day); } public function statYes($info, $type) { $table = 'cash/' . $type; $info = is_array($info) ? $info : Dever::db($table)->one($info); $other = Dever::db($type . '/info')->find($info[$type . '_id']); return $this->statDate($info['type'], $info['day']) . '与'.$other['name'].'对账单款项是否正确
对账金额¥' . $info['cash'] . '元'; } public function statTime($start, $end) { return date('Y-m-d', $start) . ' ~ ' . date('Y-m-d', $end); } public function orderUpdate($id, $name, $data) { Dever::config('base')->hook = true; $update = array(); $audit = Dever::param('audit', $data); $info = Dever::db('cash/order')->one($id); if ($audit > 1 && $info['refund_id'] && $info['refund_id'] > 0) { Dever::load('shop/lib/refund')->set('buy')->action($info['refund_id'], $audit, false, false); if ($audit == 2) { Dever::db('cash/order')->update(array('where_id' => $id, 'status' => 2)); } } } # 审核对账 public function audit_api() { $id = Dever::input('id'); $type = Dever::input('type', 'shop'); $table = 'cash/' . $type; $info = Dever::db($table)->one($id); if ($info) { Dever::db($table)->update(array('where_id' => $id, 'status' => 2)); } return 'reload'; } # 审核对账 public function audit_other_api() { $id = Dever::input('id'); $type = Dever::input('type', 'shop'); $table = 'cash/' . $type; $info = Dever::db($table)->one($id); if ($info) { Dever::db($table)->update(array('where_id' => $id, $type . '_status' => 2)); } return 'reload'; } # 查看对账单详情 public function view_api() { $id = Dever::input('id'); if (!$id) { return false; } $show = Dever::input('show', 1); $type = Dever::input('type', 'shop'); if ($type == 'shop') { $name = '门店'; } elseif ($type == 'store') { $name = '仓库'; } elseif ($type == 'factory') { $name = '工厂'; } $table = 'cash/' . $type; $config = Dever::db($table)->config; $info = Dever::db($table)->one($id); $status = $config['config_status'][$info['status']]; $other_status = $config['config_status'][$info[$type . '_status']]; $other = Dever::db($type . '/info')->find($info[$type . '_id']); $html = '
对账单详情
'; $html .= ''; $html .= ''; $html .= ''; if ($type == 'store') { $html .= ''; } else { $html .= ''; } if ($show == 1) { $html .= ''; $html .= ''; } else { $html .= ''; } $button = array(); if ($show == 1) { if ($info['status'] == 1) { $url = Dever::url('lib/set.audit&id='.$id.'&type=' . $type, 'cash'); $button[] = ''; } $config['phone'] = '联系人:' . $other['truename'] . ',联系电话:' . $other['mobile']; $button[] = ''; $info['start'] = date('Y-m-d H:i:s', $info['start']); $info['end'] = date('Y-m-d H:i:s', $info['end']); $out = Dever::url('database.list_excel?project=cash&table=order&search_option_status=2&search_option_state=1&search_option_start_cdate=' . $info['start'] . '&search_option_end_cdate=' . $info['end'], 'manage'); $button[] = '导出对账单'; } else { if ($info[$type . '_status'] == 1 && $show != 1) { $url = Dever::url('lib/set.audit_other&id='.$id.'&type=' . $type, 'cash'); $button[] = ''; } $config = Dever::load('factory/admin/auth.config'); $config['phone'] = '联系电话:' . $config['dz_phone']; $button[] = ''; $info['start'] = date('Y-m-d H:i:s', $info['start']); $info['end'] = date('Y-m-d H:i:s', $info['end']); $button[] = '打印对账单'; } $html .= ''; $html .= '
对账'.$name.' '.$this->table(false, array(array($other['name']))).'
对账周期 '.$this->table(false, array(array($this->statTime($info['start'], $info['end'])))).'
对账商品数量 '.$this->table(false, array(array($info['num']))).'
对账金额 '.$this->table(false, array(array('¥' . $info['cash'] . '元'))).'
'.$name.'对账状态 '.$this->table(false, array(array($other_status))).'
平台对账状态 '.$this->table(false, array(array($status))).'
对账状态 '.$this->table(false, array(array($other_status))).'
功能按钮 '.$this->table(false, array($button)).'
'; $where['type'] = 1; $where['type_id'] = $info[$type . '_id']; $where['status'] = 2; $data = Dever::db('cash/order')->select_page($where); if ($data) { $head = array('结算单号', '订货单号', '结算类型', '下单日期', '完成日期', '结算日期', '对账金额', '结算状态'); if ($type == 'store') { $head[6] = '对账数量'; } $body = array(); $config = Dever::db('cash/order')->config; foreach ($data as $k => $v) { $cdate = date('Y-m-d H:i', $v['cdate']); $fdate = $v['fdate'] ? date('Y-m-d H:i', $v['fdate']) : ''; $operdate = $v['operdate'] ? date('Y-m-d H:i', $v['operdate']) : ''; if ($type == 'store') { $cash = $v['num']; } elseif ($type == 'factory') { $cash = $v['p_cash']; } else { $cash = $v['cash']; } if ($show == 1) { $url = Dever::url('project/database/list?project=shop&table=buy_order_goods&order_id='.$v['source_order_id'].'&page_type=1', 'manage'); $v['source_order_num'] = ''.$v['source_order_num'].''; } $body[] = array ( $v['order_num'], $v['source_order_num'], $config['config_jstype'][$v['jstype']], $cdate, $fdate, $operdate, $cash, '已入账' ); } $page = Dever::page("current"); $html .= '
对账清单
' . $this->table($head, $body) . $page . '
'; } $html .= '
'; return '
' . $html . '
'; } private function table($head, $data) { $html = ''; if ($head) { $html = ''; $html .= ''; foreach ($head as $k => $v) { $html .= ''; } $html .= ''; $html .= ''; foreach ($data as $k => $v) { $html .= ''; foreach ($v as $k1 => $v1) { $html .= ''; } $html .= ''; } $html .= ''; $html .= '
'.$v.'
'.$v1.'
'; } else { foreach ($data as $k => $v) { $html .= ''; foreach ($v as $k1 => $v1) { $html .= $v1 . '    '; } $html .= ''; } } return $html; } }