Commit 73ead1f1 authored by zw's avatar zw

财务日报

parent 08ebb18c
<?php
namespace app\app_broker\controller;
use app\api_broker\extend\Basic;
use app\app_broker\service\DailyPaperService;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/17
* Time : 11:09 AM
* Intro:
*/
class DailyPaper extends Basic
{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new DailyPaperService();
}
/**
* 财务日报
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function dailyDetail(){
$params = $this->params;
$params = array(
"store_id" => 1,//门店id
"is_store" => 0,//身份是否是店长,财务显示不一样 0店长 1财务
"daily_data" => "2018-12-01"
);
if(!isset($params["store_id"]) || !isset($params["is_store"]) || !isset($params["daily_data"])){
return $this->response("101","请求参数错误");
}
$store_id = $params["store_id"];
$is_store = $params["is_store"];
$daily_data = $params["daily_data"];
$result = $this->service_->getDaily($this->agentId,$store_id,$is_store,$daily_data);
if($result["code"] == 101){
return $this->response("101",$result["msg"]);
}else{
return $this->response("200","success",$result["data"]);
}
}
}
\ No newline at end of file
<?php
namespace app\app_broker\service;
use app\api_broker\service\VerifyService;
use app\model\AAgents;
use app\model\ODaily;
use app\model\ODailyLog;
use app\model\OPayLogModel;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/17
* Time : 11:21 AM
* Intro:
*/
class DailyPaperService
{
private $oDailyModel;
private $aAgentsModel;
public function __construct()
{
$this->oDailyModel = new ODaily();
$this->aAgentsModel = new AAgents();
}
/**
* 获取日报详情
* @param $agent_id
* @param $store_id
* @param $is_store
* @param $daily_data
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDaily($agent_id, $store_id , $is_store, $daily_data)
{
//todo 1.if is_store身份是店长 2验证店长身份 3.验证是否有提交过当天的日报,提交过不能在提交,4.身份是财务,验证身份
//todo 5.查询详细数据, 6.查询财务审核记录 7.判断此身份财务是否审核过,审核过不能再审核。
$result = [];
$agent_info_arr["agent_id"] = $agent_id;
$agent_info_field = "id,name,store_id,district_id,level";
$agent_info = $this->aAgentsModel->getAgentById($agent_info_field, $agent_info_arr);
if (count($agent_info) <= 0) {
return ["code" => 101, "msg" => "经纪人信息错误"];
}
$agent_info = $agent_info[0];
//获取日报详情
$daily_info = $this->getDailyInfo($agent_id, $daily_data);
$result["is_commit"] = 1;
switch ($is_store) {
case 0:
if ($agent_info["level"] != 20 && $agent_info["level"] != 30) {
return ["code" => 101, "msg" => "非店长不能查看日报"];
}
//证明店长提交过
if (count($daily_info) > 0) {
$result["commit_info"] = $daily_info[0];
} else {
$result["is_commit"] = 0;
//todo 统计各金额
//todo 直接返回数据,没提交的没有财务审核无需向后走
}
break;
case 1:
//验证财务角色
if (count($daily_info) <= 0) {
return ["code" => 101, "msg" => "请求异常,没找到此日报"];
}
break;
default:
}
$checkList = $this->getCheckList($daily_info[0]["id"]);
if (count($checkList) > 0) {
$result["check_list"] = $checkList;
}
//todo 获取各个list
$result["list"] = $this->getPayLogList($store_id);
return ["code" => 200, "data" => $result];
}
/**
* 获取各个状态的记录
* @param $store_id
* @return null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getPayLogList($store_id){
$ids = $this->getAgentsByStoreId($store_id);
if(!$ids){
return null;
}
$payLogModel = new OPayLogModel();
//中介费入账
$field = "a.id,c.id as bargain_id,b.house_id,c.price,c.commission,a.money,a.pay_type,a.transfer_name,
d.report_agent_id,c.is_open,a.is_dividend,a.create_time";
$params["a.agent_id"] = array("in",($ids));
$params["a.is_del"] = 0;
$params["a.type"] = 91;
$params["c.father_id"] = 0;
$info["agency_fee"] = $payLogModel->selectPayLogList($field,$params);
//案场费入账 盘方
$params["a.type"] = 92;
$info["case_fee"] = $payLogModel->selectPayLogList($field,$params);
//意向金
$params["a.type"] = 10;
$info["earnest_money"] = $payLogModel->selectPayLogList($field,$params);
//保管金
$params["a.type"] = 30;
$info["custody_money"] = $payLogModel->selectPayLogList($field,$params);
//调整出账
return $info;
}
/**
* 根据门店id获取此门店的经纪人id string
* @param $store_id
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getAgentsByStoreId($store_id){
$params["store_id"] = $store_id;
$arr_list = $this->aAgentsModel->getAgentById("id",$params);
$ids = "";
if (count($arr_list) > 0) {
foreach ($arr_list as $item) {
$ids .= $item["id"] . ",";
}
}
$ids = rtrim($ids, ",");
return $ids;
}
/**
* 获取财务审核列表
* @param $daily_id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getCheckList($daily_id)
{
$field = "id,daily_id,operation_id,operation_name,remark,alipay,tenpay,realty_pay,family_pay,private_bank,
cash,pos,other_bank,create_time,update_time";
$params["daily_id"] = $daily_id;
$params["is_del"] = 0;
$oDailyLog = new ODailyLog();
return $oDailyLog->getDailyLogList($field, $params, 1, 15);
/**
* `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '财务日报审核日志',
* `daily_id` int(10) unsigned DEFAULT NULL COMMENT '财务日报id',
* `operation_id` int(10) unsigned DEFAULT NULL COMMENT '审核人',
* `operation_name` varchar(60) DEFAULT NULL COMMENT '审核人名字',
* `remark` varchar(255) DEFAULT NULL COMMENT '备注',
* `alipay` decimal(10,2) DEFAULT NULL COMMENT '支付宝转账',
* `tenpay` decimal(10,2) DEFAULT NULL COMMENT '微信转账',
* `realty_pay` decimal(10,2) unsigned DEFAULT NULL COMMENT '地产转账',
* `family_pay` decimal(10,2) unsigned DEFAULT NULL COMMENT '世家公账',
* `private_bank` decimal(10,2) unsigned DEFAULT NULL COMMENT '3000账号',
* `cash` decimal(10,2) unsigned DEFAULT NULL COMMENT '现金',
* `pos` decimal(10,2) unsigned DEFAULT NULL COMMENT 'pos机',
* `other_bank` decimal(10,2) DEFAULT NULL COMMENT '其他',
* `is_del` tinyint(1) unsigned DEFAULT '0' COMMENT '0正常1删除',
* `status` tinyint(1) unsigned DEFAULT '0' COMMENT '审核状态0已提交 1未审核 2已审核',
* `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
* `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8
*/
}
public function dailyBin()
{
/**
* CREATE TABLE `o_daily` (
* `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '财务日报',
* `agent_id` int(10) unsigned DEFAULT NULL COMMENT '提交人id',
* `agent_name` varchar(60) DEFAULT NULL COMMENT '提交人姓名',
* `store_id` int(10) DEFAULT NULL COMMENT '提交人门店id',
* `district_id` int(10) unsigned DEFAULT NULL COMMENT '提交人部门id',
* `daily_date` date DEFAULT NULL COMMENT '财务日报日期',
* `alipay` decimal(10,2) DEFAULT NULL COMMENT '支付宝转账',
* `tenpay` decimal(10,2) DEFAULT NULL COMMENT '微信转账',
* `realty_pay` decimal(10,2) unsigned DEFAULT NULL COMMENT '地产转账',
* `family_pay` decimal(10,2) unsigned DEFAULT NULL COMMENT '世家公账',
* `private_bank` decimal(10,2) unsigned DEFAULT NULL COMMENT '3000账号',
* `cash` decimal(10,2) unsigned DEFAULT NULL COMMENT '现金',
* `pos` decimal(10,2) unsigned DEFAULT NULL COMMENT 'pos机',
* `other_bank` decimal(10,2) DEFAULT NULL COMMENT '其他',
* `is_del` tinyint(1) unsigned DEFAULT '0' COMMENT '0正常1删除',
* `status` tinyint(1) unsigned DEFAULT '0' COMMENT '审核状态0已提交 1未审核 2已审核',
* `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
* `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8
*/
}
/**
* 获取提交的日报记录
* @param $agent_id
* @param $daily_data
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function getDailyInfo($agent_id, $daily_data)
{
$field_info_field = "id,agent_id,agent_name,daily_date,alipay,tenpay,realty_pay,family_pay,private_bank,
cash,pos,other_bank,status,create_time,update_time";
$daily_info_params["agent_id"] = $agent_id;
$daily_info_params["daily_date"] = $daily_data;
return $this->oDailyModel->getDailyList($field_info_field, $daily_info_params, 1, 1);
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/17
* Time : 11:26 AM
* Intro:
*/
class ODaily extends Model{
protected $table = "o_daily";
private $db_;
public function __construct()
{
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $params
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDailyList($field,$params,$page_no,$page_size){
$where_ = [];
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
$where_["is_del"] = 0;
return $this->db_
->field($field)
->where($where_)
->page($page_no)
->limit($page_size)
->select();
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/17
* Time : 2:36 PM
* Intro:
*/
class ODailyLog extends Model
{
protected $table = "o_daily_log";
private $db_;
public function __construct()
{
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $params
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDailyLogList($field,$params,$page_no,$page_size){
$where_ = [];
if(isset($params["daily_id"])){
$where_["daily_id"] = $params["daily_id"];
}
if(isset($params["is_del"])){
$where_["is_del"] = $params["is_del"];
}
return $this->db_
->field($field)
->where($where_)
->order("create_time desc")
->page($page_no)
->limit($page_size)
->select();
}
}
\ No newline at end of file
...@@ -455,4 +455,23 @@ class OPayLogModel extends Model ...@@ -455,4 +455,23 @@ class OPayLogModel extends Model
->where($where_) ->where($where_)
->select(); ->select();
} }
/**
* @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 selectPayLogList($filed,$params){
return $this->db_
->field($filed)
->alias("a")
->join("o_order b","a.order_id = b.id","left")
->join("o_bargain c","c.order_id = b.id","left")
->join("o_report d","a.report_id = d.id","left")
->where($params)
->select();
}
} }
\ No newline at end of file
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