Commit 3019bbe8 authored by hujun's avatar hujun

收款列表和导出

parent a26051ff
This diff is collapsed.
<?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
$params["a.is_del"] = 0;
return $this->db_->field($field)
->alias("a")
->join("o_order b", "a.order_id = b.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left')
->join("office_o_order b", "a.order_id = b.id", "left")
->join('office_g_room d', 'b.house_id = d.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)
->page($pageNo)
->order($order_)
......@@ -364,10 +365,11 @@ class OfficeOPayLogModel extends Model
{
$params["a.is_del"] = 0;
return $this->db_->alias("a")
->join("o_order b", "a.order_id = b.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left')
->join("office_o_order b", "a.order_id = b.id", "left")
->join('office_g_room d', 'b.house_id = d.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)
->count();
}
......
......@@ -1002,6 +1002,9 @@ Route::group('office_index', [
'houseAdd' => ['index/OfficeRoom/edit', ['method' => 'POST|GET']],//楼盘字典新增和编辑
'getRecords' => ['index/OfficeRoom/getRecords', ['method' => 'GET']],//盘方操作记录
'batchChangDish' => ['index/OfficeRoom/batchChangDish', ['method' => 'post']],//批量修改盘方
'getCollection' => ['index/OfficePayLog/getCollection', ['method' => 'GET']],//收款记录
'getCollectionExcel' => ['index/OfficePayLog/getCollectionExcel', ['method' => 'get']],//导出收款记录
]);
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