Commit 3019bbe8 authored by hujun's avatar hujun

收款列表和导出

parent a26051ff
<?php
namespace app\index\controller;
use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil;
use app\model\OfficeOBargainModel;
use app\model\OfficeOPayLogAdjustment;
use app\model\OfficeOPayLogModel;
use app\model\OfficeORefundModel;
use app\model\OfficeOReportModel;
use think\Request;
class OfficePayLog extends Basic
{
private $m_bargain;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->m_bargain = new OfficeOBargainModel();
}
/**
* 收款记录
*
* @return \think\Response|\think\response\View|void
*/
public function getCollection() {
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$data = [];
$where['a.is_del'] = 0;
$is_show = 0;
$msg = '';
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
$is_show = 1;
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = ['between time', [
$this->params['start_time'] . ' 00:00:00', $this->params['end_time'] . ' 23:59:59'
]];
$is_show = 1;
}
/*提交时间 end*/
/*入账日期 start*/
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00'];
$is_show = 1;
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['between time', [
$this->params['income_start_time'] . ' 00:00:00', $this->params['income_end_time'] . ' 23:59:59'
]];
$is_show = 1;
}
/*入账日期 end*/
/*收款确认日期 start*/
if (!empty($this->params['open_time_start']) && empty($this->params['open_end_time'])) {
$where['a.open_time'] = ['> time', $this->params['open_time_start'] . ' 00:00:00'];
$is_show = 1;
}
if (!empty($this->params['open_time_end']) && empty($this->params['open_time_start'])) {
$where['a.open_time'] = ['< time', $this->params['open_time_end'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['open_time_end']) && !empty($this->params['open_time_start'])) {
$where['a.open_time'] = ['between time', [
$this->params['open_time_start'] . ' 00:00:00', $this->params['open_time_end'] . ' 23:59:59'
]];
$is_show = 1;
}
/*入账日期 end*/
//商铺地址
if (!empty($this->params['internal_address'])) {
$where['g.address'] = ['like', '%' . $this->params['internal_address'] . '%'];
$is_show = 1;
}
//商铺ID
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
$is_show = 1;
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id'];
$is_show = 1;
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id'];
$is_show = 1;
}
//提交人姓名
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
$is_show = 1;
}
//入账方式
if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type'];
$is_show = 1;
}
//入账类型
if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type'];
$is_show = 1;
}
//来源
if ($this->params['source'] > -1) {
if ($this->params['source'] == 1) {
$where['a.source'] =['in', '0,1'];
} else {
$where['a.source'] = $this->params['source'];
}
$is_show = 1;
}
if (!empty($this->params['bargain_id'])) {
$order_id = $this->m_bargain->getFieldValue('order_id', ['id'=>$this->params['bargain_id'],'father_id'=>0]);
if (!empty($order_id)) {
$where[] = ['EXP', 'a.order_id='.$order_id];
}
$is_show = 1;
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (!empty($this->params['bargain_id'])) {
$where['a.bargain_id'] = $this->params['bargain_id'];
}
if (!empty($this->params['source_type'])) {
$where['a.bargain_id'] = $this->params['bargain_id'];
}
if (is_numeric($this->params['source_type'])) {
if($this->params['source_type'] == 1){
$where['a.source'] = array('neq',2);
}else{
$where['a.source'] = 2;
}
}
//案场费和中介费是否开业
if (isset($this->params['is_open'])) {
if ($this->params['is_open'] == 1) {
$where['a.is_open'] = 1;
} else {
$where['a.is_open'] = 0;
}
if (!isset($where['a.type'])) {
$where['a.type'] = ['in', '91,92'];
}
$is_show = 1;
}
if (isset($this->params['is_normality']) && $this->params['is_normality'] == 1) {
$where[] = ['EXP', '(select id from o_refund where pay_log_id=a.id and is_del = 0 group by pay_log_id) is null'];
$where[] = ['EXP', '(select id from o_paylog_adjustment where paylog_id=a.id and is_del = 0 group by paylog_id) is null '];
$is_show = 1;
}
try {
$order = new OfficeOPayLogModel();
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,a.last_transfer_time,a.industry_type,a.agent_id,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_pay_adjustment = new OfficeOPayLogAdjustment();
$m_refund = new OfficeORefundModel();
foreach ($list as $k=>$v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id'=> $v['id'],'is_del'=>0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id'=> $v['id'],'is_del'=>0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id'=> $v['id'],'is_del'=>0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id',['pay_log_id'=>$v['id'],'is_del'=>0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$list[$k]['bargain_id'] = empty($v['bargain_id'])? '':$v['bargain_id'];
} else {
$list[$k]['bargain_id'] = '';
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
}
$data['list'] = $list;
//加时间条件
if ($is_show) {
$where['a.source'] = array('neq',2);
$data['money_total'] = $order->getMoneyTotal($where, 'a.money'); //收款总计(正常)
$where['a.source'] = 2;
$data['money_change_total'] = $order->getMoneyTotal($where, 'a.money'); //收款总计(调整)
$where['a.source'] = array('neq',2);
$data['real_money_total'] = $order->getMoneyTotal($where, 'a.real_money'); //实付总计(正常)
$where['a.source'] = 2;
$data['real_money_change_total'] = $order->getMoneyTotal($where, 'a.real_money'); //实付总计(调整)
} else {
$data['money_total'] = '';
$data['money_change_total'] = '';
$data['real_money_total'] = '';
$data['real_money_change_total'] = '';
}
$data['list'] = $this->numberTransitionString($data['list']);
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
if ($this->params['excel'] == 1) {
return $this->error($msg);
}
}
return $this->response(200, $msg, $data);
}
/**
* 收款记录 Excel
*/
public function getCollectionExcel() {
set_time_limit(0);
$pageNo = 1;
$pageSize = 10000;
$data = [];
$where['a.is_del'] = 0;
$is_show = 0;
$msg = '';
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = ['between time', [
$this->params['start_time'] . ' 00:00:00', $this->params['end_time'] . ' 23:59:59'
]];
}
/*提交时间 end*/
/*入账日期 start*/
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00'];
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['between time', [
$this->params['income_start_time'] . ' 00:00:00', $this->params['income_end_time'] . ' 23:59:59'
]];
}
/*入账日期 end*/
//商铺地址
if (!empty($this->params['internal_address'])) {
$where['g.address'] = ['like', '%' . $this->params['internal_address'] . '%'];
}
//商铺ID
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id'];
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id'];
}
//提交人姓名
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
}
//入账方式
if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type'];
}
//入账类型
if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type'];
}
//来源
if ($this->params['source'] > -1) {
$where['a.source'] = $this->params['source'];
}
if (!empty($this->params['bargain_id'])) {
$order_id = $this->m_bargain->getFieldValue('order_id', ['id'=>$this->params['bargain_id'],'father_id'=>0]);
if (!empty($order_id)) {
$where[] = ['EXP', 'a.order_id='.$order_id];
}
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (!empty($this->params['bargain_id'])) {
$where['a.bargain_id'] = $this->params['bargain_id'];
}
//案场费和中介费是否开业
if (isset($this->params['is_open'])) {
if ($this->params['is_open'] == 1) {
$where['a.is_open'] = 1;
} else {
$where['a.is_open'] = 0;
}
$where['a.type'] = ['in', '91,92'];
}
if (isset($this->params['is_normality']) && $this->params['is_normality'] == 1) {
$where[] = ['EXP', '(select id from o_refund where pay_log_id=a.id and is_del = 0 group by pay_log_id) is null'];
$where[] = ['EXP', '(select id from o_paylog_adjustment where paylog_id=a.id and is_del = 0 group by paylog_id) is null '];
}
try {
$order = new OfficeOPayLogModel();
if (empty($this->params['excel'])) {
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,a.last_transfer_time,a.industry_type,a.agent_id,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$m_pay_adjustment = new OfficeOPayLogAdjustment();
$m_report = new OfficeOReportModel();
$m_refund = new OfficeORefundModel();
foreach ($list as $k=>$v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id'=> $v['id'],'is_del'=>0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id'=> $v['id'],'is_del'=>0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id'=> $v['id'],'is_del'=>0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id',['pay_log_id'=>$v['id'],'is_del'=>0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$bargain_data = $this->m_bargain->getDetail('id,father_id', ['order_id'=>$v['order_id']]);
$bargain_id = $bargain_data['id'];
if ($bargain_data['father_id'] != 0) {
$bargain_id = $bargain_data['father_id'];
}
$list[$k]['bargain_id'] = empty($bargain_id)? '':$bargain_id;
} else {
$list[$k]['bargain_id'] = '';
}
$list[$k]['current_agent_name'] = $list[$k]['store_name'] = "";
if (($v['type'] == 92 || $v['type'] == 91) && $v['bargain_id'] > 0) {
$bargain_where[] = ['EXP','a.id ='.$v['bargain_id'].' or father_id='. $v['bargain_id']];
$bargain_where['a.status'] = ['in','10,11,13'];
$bargain_where['a.role'] = ['in','3,4,5'];
$bargain_data = $this->m_bargain->agentBargainAll('a.role,a.scale,b.name', $bargain_where);
$role_arr = [1=>'盘方', 2=>'客方',3=>'反签',4=>'独家',5=>'合作方',6=>'APP盘下载方',7=>'APP客下载方'];
$name = '';
foreach ($bargain_data as $k2=>$v2) {
$name .= $v2['name'] . '('.$role_arr[$v2['role']].$v2['scale'].'%),';
}
$list[$k]['current_agent_name'] = rtrim($name,',');
}
if ($v['type'] == 10 || $v['type'] == 30) {
if (isset($house_data[0]['f_id'])) {
$current_agent_name = $m_report->selectReportById('report_agent_name,report_store_id', ['id'=>$v['f_id']]);
$list[$k]['current_agent_name'] = empty($current_agent_name[0]['report_agent_name']) ? "" : $current_agent_name[0]['report_agent_name'];
}
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
}
$data['list'] = $list;
// //加时间条件
// if ($is_show) {
// $data['money_total'] = $order->getMoneyTotal($where, 'a.real_money'); //总额
// } else {
// $data['money_total'] = '';
// }
$data['list'] = $this->numberTransitionString($data['list']);
$excel_data = [];
foreach ($data['list'] as $k => $v) {
$excel_data_ = [];
$excel_data_[] = $v['create_time'];//提交时间
$excel_data_[] = $v['id'];//收款ID
$excel_data_[] = $v['order_id'];//带看ID
$excel_data_[] = $v['bargain_id'];//成交报告ID
$excel_data_[] = $v['income_time'];//入账日期
$excel_data_[] = $v['agent_name'];//提交人
$excel_data_[] = $v['current_agent_name'];//对应业务员
// $excel_data_[] = $v['store_name'];//所属门店
$excel_data_[] = $v['type'];//类型
$excel_data_[] = $v['money'];//收款金额
$excel_data_[] = $v['real_money'];//实付金额
$excel_data_[] = $v['transaction_fee'];//手续费
$excel_data_[] = $v['pay_type'];//支付方式
if ($v['source'] == 2) { //调整收款(调整ID:[%= it[item]['source_id'] %])
$excel_data_[] = '调整入账(调整ID:'.$v['source_id'];//来源
} else { //正常收款
$excel_data_[] = '正常入账';//来源
}
if ($v['is_refund'] != 1 && !$v['is_adjustment']) {
$excel_data_[] = '正常';
} else if ($v[ 'is_refund' ] == 1 && $v[ 'is_adjustment' ]) {
$excel_data_[] = '被调整+被退款';
} else if ($v[ 'is_refund' ] == 1) {
$excel_data_[] = '被退款';
} else {
$excel_data_[] = '被调整';
}
$excel_data[] = $excel_data_;
}
$export = new ExportExcelUntil();
$title = ['提交时间', '收款ID', '带看ID', '成交报告ID', '入账日期', '提交人', '对应业务员', '类型', '收款金额(元)', '实付金额', '手续费','支付方式', '来源', '状态'];
$export->exportTable('收款记录', $excel_data, 12, '收款记录', $title);
}
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
return $this->error($msg);
}
}
/**
* 返回对应类型
*
* @param $data
* @return mixed
*/
public function numberTransitionString($data) {
//pay_type支付方式 10施总支付宝 11林老师支付宝 20 施总微信 21林老师微信 30pos机器 40地产转账 41世家公账 42 3000账号 50现金 60其他
//type付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他 90佣金 91中介费 92 案场费
foreach ($data as $k => $v) {
switch ($v['type']) {
case 10 :
$data[$k]['type'] = '意向金';break;
case 20 :
$data[$k]['type'] = '定金';break;
case 30 :
$data[$k]['type'] = '保管金';break;
case 40 :
$data[$k]['type'] = '押金';break;
case 50 :
$data[$k]['type'] = '租金';break;
case 60 :
$data[$k]['type'] = '进场费';break;
case 70 :
$data[$k]['type'] = '转让费';break;
case 80 :
$data[$k]['type'] = '其他';break;
case 90 :
$data[$k]['type'] = '佣金';break;
case 91 :
$data[$k]['type'] = '中介费';break;
case 92 :
$data[$k]['type'] = '案场费';break;
}
switch ($v['pay_type']) {
case 10 :
$data[$k]['pay_type'] = '施总支付宝';break;
case 11 :
$data[$k]['pay_type'] = '林老师支付宝';break;
case 20 :
$data[$k]['pay_type'] = '施总微信';break;
case 21 :
$data[$k]['pay_type'] = '林老师微信';break;
case 30 :
if ($v['source'] == 0) {
$data[$k]['pay_type'] = 'POS机器';
} elseif ($v['source'] == 1){
$data[$k]['pay_type'] = '智能POS机器';
}
break;
case 40 :
$data[$k]['pay_type'] = '地产转账';break;
case 41 :
$data[$k]['pay_type'] = '世家公账';break;
case 42 :
$data[$k]['pay_type'] = '3000账号';break;
case 50 :
$data[$k]['pay_type'] = '现金';break;
default :
$data[$k]['pay_type'] = '其他';
}
}
return $data;
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/13
* Time : 4:29 PM
* Intro:
*/
class OfficeOPayLogAdjustment extends BaseModel{
protected $table = "office_o_paylog_adjustment";
private $db_;
public function __construct()
{
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAdjustmentList($field, $params){
return $this->db_
->field($field)
->where($params)
->select();
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAdjustmentListByOrderId($field,$params){
$where_ = [];
if(isset($params["order_id"])){
$where_["b.order_id"] = $params["order_id"];
}
if(isset($params["is_del"])){
$where_["a.is_del"] = $params["is_del"];
}
return $this->db_
->field($field)
->alias("a")
->join("o_paylog b","a.paylog_id=b.id")
->join("o_paylog d","a.new_paylog_id=d.id")
->join("a_agents c","a.operation_id=c.id")
->where($where_)
->select();
}
public function getAdjustmentSum($field, $params)
{
$data = $this->db_
->where($params)
->sum($field);
//echo $this->getLastSql();
return $data;
}
/**
* @param $field
* @param $params
* @return int|mixed
*/
public function getFieldValue($field,$params) {
return $this->db_->where($params)
->value($field);
}
/**
* @param $field
* @param $params
* @return int|mixed
*/
public function getFieldColumn($field,$params) {
return $this->db_->where($params)
->column($field);
}
public function addAdjustment($params){
Db::startTrans();
try {
$res = $this->insertGetId($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
$res = 0;
}
return $res;
}
/**
* @param $pageNo
* @param $pageSize
* @param string $order_
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAdjustmentListLimit($pageNo, $pageSize, $order_='a.id desc', $field, $params){
return $this->db_->field($field)
->alias("a")
->join("o_paylog b", "a.paylog_id = b.id", "left")
->join("a_agents d", "a.operation_id = d.id", "left")
->join("o_order e", "b.order_id = e.id")
->limit($pageSize)
->page($pageNo)
->order($order_)
->where($params)
->select();
}
/**
* @param $params
* @return int|string
*/
public function getAdjustmentListTotal($params) {
return $this->db_->alias('a')
->join("o_paylog b", "a.paylog_id = b.id", "left")
->join("a_agents d", "a.operation_id = d.id", "left")
->join("o_order e", "b.order_id = e.id")
->where($params)
->count('a.id');
}
/**
* 调整计算
*
* @param $params
* @return float|int
*/
public function getMoneyTotal($params) {
return $this->db_->alias('a')
->join("o_paylog b", "a.paylog_id = b.id", "left")
->join("a_agents d", "a.operation_id = d.id", "left")
->join("o_order e", "b.order_id = e.id")
->where($params)
->sum('a.money');
}
/**
* @param $params
* @return int|string
*/
public function updatePayLogAdjustment($params)
{
$id = $params["id"];
unset($params["id"]);
Db::startTrans();
try {
$id = $this->db_->where([ "id" => ['in', $id] ])->update($params);
Db::commit();
return $id;
} catch (\Exception $e) {
echo $this->getLastSql();
dump("error:" . $e);
Db::rollback();
return 0;
}
}
/**
* @param $field
* @param $where
* @return float|int
*/
public function sumMoney($field, $where) {
return $this->db_->alias('a')
->join('o_paylog b','a.new_paylog_id=b.id', 'left')
->where($where)
->sum($field);
}
}
\ No newline at end of file
...@@ -341,10 +341,11 @@ class OfficeOPayLogModel extends Model ...@@ -341,10 +341,11 @@ class OfficeOPayLogModel extends Model
$params["a.is_del"] = 0; $params["a.is_del"] = 0;
return $this->db_->field($field) return $this->db_->field($field)
->alias("a") ->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("office_o_order b", "a.order_id = b.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left') ->join('office_g_room d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'a.agent_id=e.id', 'left') ->join('a_agents e', 'a.agent_id=e.id', 'left')
->join('o_bargain f', 'a.bargain_id=f.id', 'left') ->join('office_o_bargain f', 'a.bargain_id=f.id', 'left')
->join('office_g_building g', 'd.building_id=g.id','left')
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->order($order_) ->order($order_)
...@@ -364,10 +365,11 @@ class OfficeOPayLogModel extends Model ...@@ -364,10 +365,11 @@ class OfficeOPayLogModel extends Model
{ {
$params["a.is_del"] = 0; $params["a.is_del"] = 0;
return $this->db_->alias("a") return $this->db_->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("office_o_order b", "a.order_id = b.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left') ->join('office_g_room d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'a.agent_id=e.id', 'left') ->join('a_agents e', 'a.agent_id=e.id', 'left')
->join('o_bargain f', 'a.bargain_id=f.id', 'left') ->join('office_o_bargain f', 'a.bargain_id=f.id', 'left')
->join('office_g_building g', 'd.building_id=g.id','left')
->where($params) ->where($params)
->count(); ->count();
} }
......
...@@ -1002,6 +1002,9 @@ Route::group('office_index', [ ...@@ -1002,6 +1002,9 @@ Route::group('office_index', [
'houseAdd' => ['index/OfficeRoom/edit', ['method' => 'POST|GET']],//楼盘字典新增和编辑 'houseAdd' => ['index/OfficeRoom/edit', ['method' => 'POST|GET']],//楼盘字典新增和编辑
'getRecords' => ['index/OfficeRoom/getRecords', ['method' => 'GET']],//盘方操作记录 'getRecords' => ['index/OfficeRoom/getRecords', ['method' => 'GET']],//盘方操作记录
'batchChangDish' => ['index/OfficeRoom/batchChangDish', ['method' => 'post']],//批量修改盘方 'batchChangDish' => ['index/OfficeRoom/batchChangDish', ['method' => 'post']],//批量修改盘方
'getCollection' => ['index/OfficePayLog/getCollection', ['method' => 'GET']],//收款记录
'getCollectionExcel' => ['index/OfficePayLog/getCollectionExcel', ['method' => 'get']],//导出收款记录
]); ]);
Route::group('office_api', [ Route::group('office_api', [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment