Commit 713faeb4 authored by zw's avatar zw

财务日报

parent 34f3f489
......@@ -31,12 +31,12 @@ class DailyPaper extends Basic
*/
public function dailyDetail(){
$params = $this->params;
$params = array(
/* $params = array(
"store_id" => 73,//门店id
"is_store" => 0,//身份是否是店长,财务显示不一样 0店长 1财务
"daily_data" => "2018-12-01"
);
$this->agentId = 74;
$this->agentId = 74;*/
if(!isset($params["store_id"]) || !isset($params["is_store"]) || !isset($params["daily_data"])){
return $this->response("101","请求参数错误");
}
......
......@@ -70,9 +70,10 @@ class DailyPaperService
$result["commit_info"] = $daily_info[0];
} else {
$result["is_commit"] = 0;
//todo 统计各金额
//todo 直接返回数据,没提交的没有财务审核无需向后走
//todo 统计各金额
$result["total_info"] = $this->getTotal($store_id, $daily_data);
return ["code" => 200, "data" => $result];
}
break;
case 1:
......@@ -89,22 +90,101 @@ class DailyPaperService
if (count($checkList) > 0) {
$result["check_list"] = $checkList;
}
//todo 获取各个list
$result["list"] = $this->getPayLogList($store_id);
$result["list"] = $this->getPayLogList($store_id, $daily_data);
//todo 统计各金额
$result["total_info"] = $this->getTotal($store_id, $daily_data);
return ["code" => 200, "data" => $result];
}
/**
* 获取总数
* @param $store_id
* @return array|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getTotal($store_id, $daily_data)
{
$ids = $this->getAgentsByStoreId($store_id);
if (!$ids) {
return null;
}
//中介费入账
$field = "sum(money) as money,pay_type";
$params["agent_id"] = array("in", ($ids));
$params["is_del"] = 0;
$params["create_time"] = array("between", array($daily_data, $daily_data . " 23:59:59"));
$payLogModel = new OPayLogModel();
$total_arr = $payLogModel->getTotal($field, $params, "pay_type");
$total["alipay"] = 0;
$total["tenpay"] = 0;
$total["pos"] = 0;
$total["realty_pay"] = 0;
$total["family_pay"] = 0;
$total["private_bank"] = 0;
$total["cash"] = 0;
$total["other_bank"] = 0;
if (count($total_arr) <= 0) {
return $total;
}
foreach ($total_arr as $item) {
switch ($item["pay_type"]) {
case 10:
$total["alipay1"] = $item["money"];
break;
case 11:
$total["alipay2"] = $item["money"];
break;
case 20:
$total["tenpay1"] = $item["money"];
break;
case 21:
$total["tenpay2"] = $item["money"];
break;
case 30:
$total["pos"] = $item["money"];
break;
case 40:
$total["realty_pay"] = $item["money"];
break;
case 41:
$total["family_pay"] = $item["money"];
break;
case 42:
$total["private_bank"] = $item["money"];
break;
case 50:
$total["cash"] = $item["money"];
break;
case 60:
$total["other_bank"] = $item["money"];
break;
}
}
$total["alipay"] = $total["alipay1"] + $total["alipay2"];
$total["tenpay"] = $total["tenpay1"] + $total["tenpay2"];
unset($total["alipay1"]);
unset($total["alipay2"]);
unset($total["tenpay1"]);
unset($total["tenpay2"]);
return $total;
}
/**
* 获取各个状态的记录
* @param $store_id
* @param $daily_data
* @return null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getPayLogList($store_id)
private function getPayLogList($store_id, $daily_data)
{
$ids = $this->getAgentsByStoreId($store_id);
if (!$ids) {
......@@ -115,6 +195,7 @@ class DailyPaperService
$field = "a.id,c.id as bargain_id,b.house_id,c.price,a.money,a.pay_type,a.transfer_name,
d.report_agent_id as agent_id,c.is_open,a.is_dividend,a.receipt_number,a.create_time";
$params["a.agent_id"] = array("in", ($ids));
$params["a.create_time"] = array("between", array($daily_data, $daily_data . " 23:59:59"));
$params["a.is_del"] = 0;
$params["a.type"] = 91;
$params["c.father_id"] = 0;
......@@ -199,9 +280,10 @@ class DailyPaperService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function agentInfo($agent_id_str){
$params["a.id"] = array("in",($agent_id_str));
return $this->aAgentsModel->getAgentsInfoByAgentId("a.id,a.name,b.store_name",$params);
private function agentInfo($agent_id_str)
{
$params["a.id"] = array("in", ($agent_id_str));
return $this->aAgentsModel->getAgentsInfoByAgentId("a.id,a.name,b.store_name", $params);
}
/**
......@@ -211,10 +293,11 @@ class DailyPaperService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function houseInfo($house_id_str){
private function houseInfo($house_id_str)
{
$houseModel = new GHouses();
$params["id"] = array("in",($house_id_str));
return $houseModel->getHouseInfo("id,internal_address",$params);
$params["id"] = array("in", ($house_id_str));
return $houseModel->getHouseInfo("id,internal_address", $params);
}
/**
......
......@@ -494,6 +494,14 @@ class OPayLogModel extends Model
}
/**
* @param $filed
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectAdjustmentList($filed,$params)
{
return $this->db_->field($filed)
......@@ -504,6 +512,23 @@ class OPayLogModel extends Model
->select();
}
/**
* @param $filed
* @param $params
* @param $group
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTotal($filed,$params,$group){
return $this->db_
->field($filed)
->where($params)
->group($group)
->select();
}
/**
* @param $field
* @param $where
......
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