Commit 6cd20ffd authored by clone's avatar clone

报备跟进收款退款成交报告

parent a88780ad
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\OrderLogService;
use app\model\OMarchInModel;
use app\model\ORefundModel;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/31
* Time : 14:46
* Intro:
*/
class OrderLog extends Basic
{
private $o_march_in_model;
private $o_refund_model;
private $service_;
function __construct()
{
$this->o_march_in_model = new OMarchInModel();
$this->o_refund_model = new ORefundModel();
$this->service_ = new OrderLogService();
}
/**
* 进场
* @return \think\Response
*/
public function marchIn()
{
$params = $this->params;
if (!isset($params["march_in_area"]) || !isset($params["reception_id"]) || !isset($params["report_id"])
|| !isset($params["order_id"]) || !isset($params["order_no"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"reception_id" => 1,//带看经纪人id
"report_id" => 1,//报备id
"order_id" =>1, //关联order表id
"order_no" =>1, //订单no
"march_in_remark" =>1, //进场备注
"march_in_img" =>1, //备注图片
"march_in_area" =>1, //进场地址
);*/
$is_ok = $this->o_march_in_model->addMarchIn($params);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
} else {
return $this->response("101", "request faild");
}
}
/**
* 收款
* @return \think\Response
*/
public function collectingBill()
{
$params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["collecting_bill"]) || !isset($params["collecting_bill"][0]["type"]) || !isset($params["house_number"])
|| !isset($params["industry_type"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"agent_id" => 1,//收款经纪人id
"report_id" => 1,//报备id
"order_id" => 1, //关联order表id
"order_no" => 1, //订单no
// `type` '付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他',
//`pay_type` '支付方式 10支付宝 20 微信 30pos机器 40转账 50现金',
// `money` '入账金额 存分',
"collecting_bill" => [ [ "type" => 10, "pay_type" => 10, "money" => 1100 ], [ "type" => 10, "pay_type" => 10, "money" => 1200 ] ],
"house_number" => "3301号",
"industry_type" => "asdasdasd",
"remark" => "没什么备注",
"transfer_img" => "12312312312"
);*/
$remark = isset($params["remark"]) ? $params["remark"] : "";
$transfer_img = isset($params["transfer_img"]) ? $params["transfer_img"] : "";
$is_ok = $this->service_->addCollectingBill($params["agent_id"], $params["report_id"], $params["order_id"], $params["order_no"],
$params["collecting_bill"], $params["house_number"], $params["industry_type"], $remark, $transfer_img);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
}
return $this->response("101", "request faild");
}
/**
* 新增退款申请
* @return \think\Response
*/
public function refund()
{
$params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["refund_money"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"agent_id" => 1,//退款经纪人id
"report_id" => 1,//报备id
"order_id" => 1, //关联order表id
"order_no" => 1, //订单no
"refund_money" => 1200, //退款金额 存分
"name" => "qweqwe", //收款人姓名
"bank" => "asdasdasd", //收款人银行
"card_no" => "123123123123", //银行卡号
"remark" => "没什么备注",
"remark_img" => "12312312312"
);*/
$is_ok = $this->o_refund_model->addRefund($params);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
}
return $this->response("101", "request faild");
}
/**
* 成交报告
* @return \think\Response
*/
public function bargain()
{
$params = $this->params;
if (!isset($params["submit_agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["trade_type"]) || !isset($params["price"]) || !isset($params["commission"])
|| !isset($params["commission_arr"][0]["role"]) || !isset($params["commission_arr"][0]["agent_id"])
|| !isset($params["commission_arr"][0]["scale"]) || !isset($params["commission_arr"][0]["scale_fee"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"submit_agent_id" => 1,//申请经纪人id
"report_id" => 1,//报备id
"order_id" => 1, //关联order表id
"order_no" => 1, //订单no
"trade_type" => 1, //成交类型 10出租 20 增佣 30 代理 40 好处费
"price" => 1, //成交价格 存分
"commission" => 1, //佣金 存分
//`role` '分佣方 1盘方 2客方 3 反签 4独家 5合作方',
//`agent_id`'分佣经纪人id',
//`scale`'分佣比例 如 5表示百分之5',
// `scale_fee` '应分佣金 存分 ',
"commission_arr" => [ [ "role" => 10, "agent_id" => 10, "scale" => 10, "scale_fee" => 1222 ],
[ "role" => 10, "agent_id" => 10, "scale" => 10, "scale_fee" => 1222 ] ],
);*/
$is_ok = $this->service_->addBargain($params["submit_agent_id"], $params["report_id"], $params["order_id"], $params["order_no"],
$params["trade_type"], $params["price"], $params["commission"], $params["commission_arr"]);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
}
return $this->response("101", "request faild");
}
}
\ No newline at end of file
......@@ -31,21 +31,21 @@ class Report extends Basic
*/
public function report()
{
$params = $this->params;
if (!isset($params['report_agent_id']) || !isset($params['report_store_id']) || !isset($params['user_id']) ||
!isset($params['house_ids']) || !isset($params['vehicle']) ) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"report_agent_id" => 1,//报备经纪人id
"report_store_id" => 1,//门店id
"user_id" => 1,//用户id
"house_ids" => "1,2,3",//楼盘id
"vehicle" => 10,//交通工具
"intro" => "123123123",//备注
"predict_see_time" => date("Y-m-d H:i:s", time()),//预计到看时间
);*/
$params = $this->params;
if (!isset($params['report_agent_id']) || !isset($params['report_store_id']) || !isset($params['user_id']) ||
!isset($params['house_ids']) || !isset($params['vehicle'])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"report_agent_id" => 1,//报备经纪人id
"report_store_id" => 1,//门店id
"user_id" => 1,//用户id
"house_ids" => "1,2,3",//楼盘id
"vehicle" => 10,//交通工具
"intro" => "123123123",//备注
"predict_see_time" => date("Y-m-d H:i:s", time()),//预计到看时间
);*/
//todo 检查经纪人状态 basic类做
//todo 验证用户id是否正常
......@@ -59,10 +59,10 @@ class Report extends Basic
$predict_see_time = $params["predict_see_time"];
$is_ok = $this->service_->verifyReport($agent_id, $store_id, $user_id, $house_ids, $vehicle, $intro, $predict_see_time);
if($is_ok > 0){
return $this->response("200","request success",[]);
}else{
return $this->response("101","save exception");
if ($is_ok > 0) {
return $this->response("200", "request success", []);
} else {
return $this->response("101", "save exception");
}
......@@ -81,7 +81,8 @@ class Report extends Basic
* 新增跟进
* @return \think\Response
*/
public function addFollowUp(){
public function addFollowUp()
{
/*$params = array(
"report_id" => 1,
"agent_id" => 12,
......@@ -106,33 +107,45 @@ class Report extends Basic
}
$is_ok = $this->fulModel->addFollowUpLog($params);
if($is_ok > 0){
return $this->response("200","request success",[]);
}else{
return $this->response("101","request error");
if ($is_ok > 0) {
return $this->response("200", "request success", []);
} else {
return $this->response("101", "request error");
}
}
public function getFollowUpList(){
$params = array(
"report_id" => 1,// 报备id
"agent_id" => 1,//非必填 经纪人id
);
/**
* 获取跟进记录列表
* @return \think\Response
*/
public function getFollowUpList()
{
/* $params = array(
"report_id" => 1,// 报备id
"agent_id" => 1,//非必填 经纪人id 没有就获取最新一条跟进记录
);*/
$params = $this->params;
if(!isset($params["report_id"])){
if (!isset($params["report_id"])) {
return $this->response("101", "请求参数错误");
}
$field_ = "id,report_id,agent_id,user_type,decision_maker,industry_type,area_requirement,price_requirement,province
,city,district,business_area,other_area,explain,explain_img,create_time,update_time";
$where_ = [];
$order_ = "crate_time desc";
$where_ = [];
$where_["report_id"] = $params["report_id"];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"];
}
$result = $this->fulModel->selectFollowUpList($field_,$where_);
$result = $this->fulModel->selectFollowUpList($field_, $where_,$order_);
if (count($result) > 0) {
return $this->response("200", "request success", $result);
} else {
return $this->response("300", "not fund list", []);
}
return $this->response("101", "request error");
}
}
\ No newline at end of file
<?php
namespace app\api_broker\service;
use app\model\OBargainModel;
use app\model\OPayLogModel;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/1
* Time : 13:58
* Intro:
*/
class OrderLogService
{
private $payLogModel;
private $bargainModel;
function __construct()
{
$this->payLogModel = new OPayLogModel();
$this->bargainModel = new OBargainModel();
}
/**
*批量插入收款记录
* @param $agent_id
* @param $report_id
* @param $order_id
* @param $order_no
* @param $collecting_bill
* @param $house_number
* @param $industry_type
* @param $remark
* @param $transfer_img
* @return int
*/
public function addCollectingBill($agent_id, $report_id, $order_id, $order_no, $collecting_bill, $house_number,
$industry_type, $remark, $transfer_img)
{
$bill_arr = [];
foreach ($collecting_bill as $collecting) {
if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) {
array_push($bill_arr, $this->collectingBillBin($collecting, $agent_id, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img));
}
}
//todo if bill_arr not null, save database table
if (!empty($bill_arr)) {
return $this->payLogModel->addPayLog($bill_arr);
}
return 0;
}
private function collectingBillBin($collecting_arr, $agent_id, $report_id, $order_id, $order_no, $house_number,
$industry_type, $remark, $transfer_img)
{
$arr["report_id"] = $report_id;
$arr["order_no"] = $order_no;
$arr["order_id"] = $order_id;
$arr["agent_id"] = $agent_id;
$arr["type"] = $collecting_arr["type"];
$arr["pay_type"] = $collecting_arr["pay_type"];
$arr["money"] = $collecting_arr["money"];
$arr["house_number"] = $house_number;
$arr["industry_type"] = $industry_type;
$arr["remark"] = $remark;
$arr["transfer_img"] = $transfer_img;
$arr["create_time"] = date("Y-m-d H:i:s", time());
$arr["update_time"] = date("Y-m-d H:i:s", time());
return $arr;
}
/**
* 批量插入成交报告
* @param $submit_agent_id
* @param $report_id
* @param $order_id
* @param $order_no
* @param $trade_type
* @param $price
* @param $commission
* @param $commission_arr
* @return int
*/
public function addBargain($submit_agent_id, $report_id, $order_id, $order_no, $trade_type, $price, $commission, $commission_arr)
{
$bargain_arr = [];
foreach ($commission_arr as $commission_val) {
if (isset($collecting["role"]) && isset($collecting["agent_id"]) && isset($collecting["scale"]) && isset($collecting["scale_fee"])) {
array_push($bargain_arr, $this->bargainBin($commission_val, $submit_agent_id, $report_id, $order_id,
$order_no, $trade_type, $price, $commission));
}
}
//todo if bill_arr not null, save database table
if (!empty($bargain_arr)) {
return $this->bargainModel->addBargain($bargain_arr);
}
return 0;
}
private function bargainBin($commission_val, $submit_agent_id, $report_id, $order_id, $order_no, $trade_type, $price, $commission)
{
$arr["report_id"] = $report_id;
$arr["order_no"] = $order_no;
$arr["order_id"] = $order_id;
$arr["submit_agent_id"] = $submit_agent_id;
$arr["trade_type"] = $trade_type;
$arr["price"] = $price;
$arr["commission"] = $commission;
$arr["role"] = $commission_val["role"];
$arr["agent_id"] = $commission_val["agent_id"];
$arr["scale"] = $commission_val["scale"];
$arr["scale_fee"] = $commission_val["scale_fee"];
$arr["create_time"] = date("Y-m-d H:i:s", time());
$arr["update_time"] = date("Y-m-d H:i:s", time());
return $arr;
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User: zw
......@@ -22,7 +24,13 @@ class FollowUpLogModel extends Model
$this->db_ = Db::name($this->table);
}
public function addFollowUpLog($params){
/**
* 新增跟进
* @param $params
* @return int
*/
public function addFollowUpLog($params)
{
$params["create_time"] = date("Y-m-d H:i:s", time());
$params["update_time"] = date("Y-m-d H:i:s", time());
......@@ -37,7 +45,31 @@ class FollowUpLogModel extends Model
}
}
public function selectFollowUpList($field_,$where_){
/**
* 获取跟进数据
* @param $field_
* @param $where_
* @param $order_
* @return false|\PDOStatement|string|\think\Collection
*/
public function selectFollowUpList($field_, $where_, $order_)
{
if (isset($where_["agent_id"])) {
$data = $this->db_
->field($field_)
->where($where_)
->order($order_)
->select();
} else {
$data = $this->db_
->field($field_)
->where($where_)
->order($order_)
->limit(1)
->select();
}
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/2/1
* Time : 17:15
* Intro:
*/
class OBargainModel extends Model
{
protected $table = "o_bargain";
private $db_;
function __construct()
{
$this->db_ = Db::name($this->table);
}
public function addBargain($params)
{
Db::startTrans();
try {
$this->db->inserAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/1
* Time : 13:32
* Intro:
*/
class OMarchInModel extends Model
{
protected $table = "o_march_in";
private $db_model;
function __construct()
{
$this->db_model = Db::name($this->table);
}
/**
* 新增跟进信息
* @param $params
* @return int
*/
public function addMarchIn($params)
{
$params["create_time"] = date("Y-m-d H:i:s", time());
$params["update_time"] = date("Y-m-d H:i:s", time());
Db::startTrans();
try {
$this->db->inser($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/1
* Time : 14:44
* Intro:
*/
class OPayLogModel extends Model
{
protected $table = "o_paylog";
private $db_;
function __construct()
{
$this->db_ = Db::name($this->table);
}
public function addPayLog($params)
{
Db::startTrans();
try {
$this->db->inserAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/1
* Time : 16:02
* Intro:
*/
class ORefundModel extends Model{
protected $table = "o_refund";
private $db_;
function __construct()
{
$this->db_=Db::name($this->table);
}
/**
* 新增退款记录
* @param $params
* @return int|string
*/
public function addRefund($params){
$refund_arr = [];
if(isset($params["agent_id"])){
$refund_arr["agent_id"] = $params["agent_id"];
}
if(isset($params["report_id"])){
$refund_arr["report_id"] = $params["report_id"];
}
if(isset($params["order_id"])){
$refund_arr["order_id"] = $params["order_id"];
}
if(isset($params["order_no"])){
$refund_arr["order_no"] = $params["order_no"];
}
if(isset($params["refund_money"])){
$refund_arr["refund_money"] = $params["refund_money"];
}
if(isset($params["name"])){
$refund_arr["name"] = $params["name"];
}
if(isset($params["bank"])){
$refund_arr["bank"] = $params["bank"];
}
if(isset($params["card_no"])){
$refund_arr["card_no"] = $params["card_no"];
}
if(isset($params["remark"])){
$refund_arr["remark"] = $params["remark"];
}
if(isset($params["remark_img"])){
$refund_arr["remark_img"] = $params["remark_img"];
}
$refund_arr["create_time"] = date("Y-m-d H:i:s",time());
$refund_arr["update_time"] = date("Y-m-d H:i:s",time());
Db::startTrans();
try {
$id = $this->db_->insert($refund_arr);
Db::commit();
return $id;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
}
\ No newline at end of file
......@@ -195,8 +195,11 @@ Route::group('task',[
'exclusiveExpirationTime' => [ 'task/exclusive/exclusiveExpirationTime', [ 'method' => 'get' ]] //独家过期时间
]);
Route::group('broker',[
'report' => [ 'api_broker/FollowUp/report', [ 'method' => 'get|post' ]] //报备
Route::group('broker', [
'report' => [ 'api_broker/Report/report', [ 'method' => 'get|post' ] ], //报备
'addFollowUp' => [ 'api_broker/Report/addFollowUp', [ 'method' => 'get|post' ] ], //新增跟进
'getFollowUpList' => [ 'api_broker/Report/getFollowUpList', [ 'method' => 'get|post' ] ],
'marchIn' => [ 'api_broker/OrderLog/marchIn', [ 'method' => 'get|post' ] ],
]);
//Route::miss('api/index/miss');//处理错误的url
\ 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