Commit 5df3a52d authored by zw's avatar zw

财务日报

parent d5d202b9
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
namespace app\api_broker\service; namespace app\api_broker\service;
use app\api_broker\controller\Agent;
use app\api_broker\service\VerifyService; use app\api_broker\service\VerifyService;
use app\model\AAgents; use app\model\AAgents;
use app\model\GHouses;
use app\model\ODaily; use app\model\ODaily;
use app\model\ODailyLog; use app\model\ODailyLog;
use app\model\OPayLogAdjustment; use app\model\OPayLogAdjustment;
...@@ -38,7 +40,7 @@ class DailyPaperService ...@@ -38,7 +40,7 @@ class DailyPaperService
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getDaily($agent_id, $store_id , $is_store, $daily_data) public function getDaily($agent_id, $store_id, $is_store, $daily_data)
{ {
//todo 1.if is_store身份是店长 2验证店长身份 3.验证是否有提交过当天的日报,提交过不能在提交,4.身份是财务,验证身份 //todo 1.if is_store身份是店长 2验证店长身份 3.验证是否有提交过当天的日报,提交过不能在提交,4.身份是财务,验证身份
...@@ -102,39 +104,117 @@ class DailyPaperService ...@@ -102,39 +104,117 @@ class DailyPaperService
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
private function getPayLogList($store_id){ private function getPayLogList($store_id)
{
$ids = $this->getAgentsByStoreId($store_id); $ids = $this->getAgentsByStoreId($store_id);
if(!$ids){ if (!$ids) {
return null; return null;
} }
$payLogModel = new OPayLogModel(); $payLogModel = new OPayLogModel();
//中介费入账 //中介费入账
$field = "a.id,c.id as bargain_id,b.house_id,c.price,a.money,a.pay_type,a.transfer_name, $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,c.is_open,a.is_dividend,a.receipt_number,a.create_time"; 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.agent_id"] = array("in", ($ids));
$params["a.is_del"] = 0; $params["a.is_del"] = 0;
$params["a.type"] = 91; $params["a.type"] = 91;
$params["c.father_id"] = 0; $params["c.father_id"] = 0;
$info["agency_fee"] = $payLogModel->selectPayLogListByBargain($field,$params); $info["agency_fee"] = $this->getHouseAndAgentInfo(
$payLogModel->selectPayLogListByBargain($field, $params)
);
//案场费入账 盘方 //案场费入账 盘方
$params["a.type"] = 92; $params["a.type"] = 92;
$info["case_fee"] = $payLogModel->selectPayLogListByBargain($field,$params); $info["case_fee"] = $this->getHouseAndAgentInfo(
$payLogModel->selectPayLogListByBargain($field, $params)
);
$field_money = "a.id,b.house_id,a.pay_type,a.transfer_name, d.report_agent_id,a.is_dividend,a.receipt_number,a.create_time"; $field_money = "a.id,b.house_id,a.pay_type,a.transfer_name, d.report_agent_id as agent_id,a.is_dividend,a.receipt_number,a.create_time";
//意向金 //意向金
$params["a.type"] = 10; $params["a.type"] = 10;
unset($params["c.father_id"]); unset($params["c.father_id"]);
$info["earnest_money"] = $payLogModel->selectPayLogListByBargainReport($field_money,$params); $info["earnest_money"] = $this->getHouseAndAgentInfo(
$payLogModel->selectPayLogListByBargainReport($field_money, $params)
);
//保管金 //保管金
$params["a.type"] = 30; $params["a.type"] = 30;
$info["custody_money"] = $payLogModel->selectPayLogListByBargainReport($field_money,$params); $info["custody_money"] = $this->getHouseAndAgentInfo(
$payLogModel->selectPayLogListByBargainReport($field_money, $params)
);
//调整出账 //调整出账
$field_adjustment = "b.id,c.house_id,a.income_time,b.type,a.receipt_number,a.create_time"; $field_adjustment = "b.id,c.house_id,a.agent_id,a.income_time,b.type,a.receipt_number,a.create_time";
$params_adjustment["a.agent_id"] = array("in",($ids)); $params_adjustment["a.agent_id"] = array("in", ($ids));
$params_adjustment["a.is_del"] = 0; $params_adjustment["a.is_del"] = 0;
$info["adjustment"] = $payLogModel->selectAdjustmentList($field_adjustment,$params_adjustment); $info["adjustment"] = $this->getHouseAndAgentInfo(
$payLogModel->selectAdjustmentList($field_adjustment, $params_adjustment)
);
return $info; return $info;
}
/**
* @param $data
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getHouseAndAgentInfo($data)
{
$agent_id_str = "";
$house_id_str = "";
if (count($data) > 0) {
foreach ($data as $k => $v) {
$agent_id_str .= $v["agent_id"] . ",";
$house_id_str .= $v["house_id"] . ",";
}
$agent_id_str = rtrim($agent_id_str, ",");
$house_id_str = rtrim($house_id_str, ",");
$agent_arr = $this->agentInfo($agent_id_str);
$house_arr = $this->houseInfo($house_id_str);
foreach ($data as $k => $v) {
foreach ($agent_arr as $value) {
if ($v["agent_id"] == $value["id"]) {
$data[$k]["agent_name"] = $value["name"];
$data[$k]["store_name"] = $value["store_name"];
}
}
foreach ($house_arr as $item) {
if ($v["house_id"] == $item["id"]) {
$data[$k]["house_address"] = $item["internal_address"];
}
}
}
}
return $data;
}
/**
* @param $agent_id_str
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @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);
}
/**
* @param $house_id_str
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function houseInfo($house_id_str){
$houseModel = new GHouses();
$params["id"] = array("in",($house_id_str));
return $houseModel->getHouseInfo("id,internal_address",$params);
} }
/** /**
...@@ -145,9 +225,10 @@ class DailyPaperService ...@@ -145,9 +225,10 @@ class DailyPaperService
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
private function getAgentsByStoreId($store_id){ private function getAgentsByStoreId($store_id)
{
$params["store_id"] = $store_id; $params["store_id"] = $store_id;
$arr_list = $this->aAgentsModel->getAgentById("id",$params); $arr_list = $this->aAgentsModel->getAgentById("id", $params);
$ids = ""; $ids = "";
if (count($arr_list) > 0) { if (count($arr_list) > 0) {
foreach ($arr_list as $item) { foreach ($arr_list as $item) {
......
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