Commit 751fae8f authored by zw's avatar zw

收款

parent 2c9803ff
......@@ -189,21 +189,25 @@ class OrderLog extends Basic
}
return $this->response("101", "request faild");
}
/**
* 收款
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws Exception
*/
public function collectingBill()
{
$params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["agent_id"]) || !isset($params["report_id"]) || !isset($params["order_id"]) || !isset($params["order_no"])
|| !isset($params["collecting_bill"]) || !isset($params["house_number"]) || !isset($params["industry_type"])) {
if (!isset($params["agent_id"]) || !isset($params["agent_id"]) || !isset($params["report_id"]) ||
!isset($params["order_id"]) || !isset($params["order_no"]) | !isset($params["collecting_bill"]) ||
!isset($params["house_number"]) || !isset($params["industry_type"]) || !isset($params["is_dividend"]) ) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"agent_id" => 1,//收款经纪人id
"agent_name" => 1,//收款经纪人id
......@@ -218,19 +222,28 @@ class OrderLog extends Basic
"house_number" => "3301号",
"industry_type" => "asdasdasd",
"remark" => "没什么备注",
"transfer_img" => "12312312312"
"transfer_img" => "12312312312",
"is_dividend" => 1, //是否分红 1否 0是
"last_transfer_time" => "2018-10-18", //最后转定时间
);*/
$params["collecting_bill"] = json_decode($params["collecting_bill"], true);
$remark = isset($params["remark"]) ? $params["remark"] : "";
$transfer_img = isset($params["transfer_img"]) ? $params["transfer_img"] : "";
$source = $params["source"] ? $params["source"] : 0;
$is_ok = $this->service_->addCollectingBill($params["agent_id"], $params["agent_name"], $params["report_id"], $params["order_id"], $params["order_no"],
$params["collecting_bill"], $params["house_number"], $params["industry_type"], $remark, $transfer_img, $source);
$income_time = isset($params["income_time"]) ? $params["income_time"] : "";
$is_ok = $this->service_->addCollectingBill($params["agent_id"], $params["agent_name"], $params["report_id"],
$params["order_id"], $params["order_no"], $params["collecting_bill"], $params["house_number"], $params["industry_type"],
$remark, $transfer_img, $source,$income_time,$params["is_dividend"],$params["last_transfer_time"]);
if ($is_ok > 0) {
return $this->response("200", "request success", [ "bill_id" => $is_ok ]);
}elseif($is_ok == -1){
return $this->response("101", "付款类型或支付方式错误");
}
return $this->response("101", "request faild");
}
......
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\PayLogService;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/13
* Time : 3:41 PM
* Intro:
*/
class PayLog extends Basic
{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new PayLogService();
}
public function getBeForNum()
{
$params = $this->params;
/* $params = array(
"order_id" => 15523, //关联order表id
);*/
if (!isset($params["order_id"])) {
return $this->response("101", "订单编号不能为空");
}
$billInfo = $this->service_->getBeForNum($params["order_id"]);
if (count($billInfo) > 0) {
return $this->response("200", "request success", $billInfo[0]);
} else {
return $this->response("200", "request null");
}
}
}
\ No newline at end of file
......@@ -54,6 +54,7 @@ class OrderLogService
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\Exception
*/
public function addCollectingBillV2($agent_id, $agent_name, $report_id, $order_id, $order_no, $collecting_bill, $house_number,
$industry_type, $remark, $transfer_img, $source, $income_time)
......@@ -64,11 +65,11 @@ class OrderLogService
if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) {
if ($father_id == 0) {
$params = $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time);
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time,0,0);
$father_id = $this->payLogModel->insertPayLog($params);
} else {
array_push($bill_arr, $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time));
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time,0,0));
}
}
}
......@@ -100,29 +101,40 @@ class OrderLogService
* @param $remark
* @param $transfer_img
* @param $source
* @param $income_time
* @param $is_dividend
* @param $last_transfer_time
* @return int|string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addCollectingBill($agent_id, $agent_name, $report_id, $order_id, $order_no, $collecting_bill, $house_number,
$industry_type, $remark, $transfer_img, $source)
$industry_type, $remark, $transfer_img, $source, $income_time,$is_dividend,$last_transfer_time)
{
$bill_arr = $params = [];
$father_id = 0;
foreach ($collecting_bill as $collecting) {
if (isset($collecting["type"]) && isset($collecting["pay_type"]) && isset($collecting["money"])) {
if(!$this->verifyType($collecting["type"],$collecting["pay_type"],$last_transfer_time)){
return -1;
}
if ($father_id == 0) {
$params = $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img, $source);
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time,$is_dividend,$last_transfer_time);
$father_id = $this->payLogModel->insertPayLog($params);
} else {
array_push($bill_arr, $this->collectingBillBin($father_id, $collecting, $agent_id, $agent_name, $report_id, $order_id, $order_no,
$house_number, $industry_type, $remark, $transfer_img, $source));
$house_number, $industry_type, $remark, $transfer_img, $source, $income_time,$is_dividend,$last_transfer_time));
}
}
}
if ($father_id > 0) {
//保存图片
$oImgModel = new OImg();
$oImgModel->addImgAll($father_id, 2, $transfer_img);
$pushMarchIn = new PushMessageService();
$pushMarchIn->pushMarchInMessage($params["report_id"], 2, $agent_id); //推送
}
......@@ -133,8 +145,72 @@ class OrderLogService
return $father_id;
}
/**
* @param $type
* @param $pay_type
* @param $last_transfer_time
* @return bool
*/
private function verifyType($type,$pay_type,$last_transfer_time){
switch ($type){
case 10:
case 11:
case 20:
case 21:
case 30:
case 40:
case 41:
case 42:
case 50:
case 60:
break;
default:
return false;
}
switch ($pay_type){
case 10:
case 20:
case 30:
case 40:
case 50:
case 60:
case 70:
case 80:
case 90:
if(!$last_transfer_time){
return false;
}
break;
case 91:
case 92:
break;
default:
return false;
}
return true;
}
/**
* @param $father_id
* @param $collecting_arr
* @param $agent_id
* @param $agent_name
* @param $report_id
* @param $order_id
* @param $order_no
* @param $house_number
* @param $industry_type
* @param $remark
* @param $transfer_img
* @param $source
* @param $income_time
* @param $is_dividend
* @param $last_transfer_time
* @return mixed
*/
private function collectingBillBin($father_id, $collecting_arr, $agent_id, $agent_name, $report_id, $order_id, $order_no, $house_number,
$industry_type, $remark, $transfer_img, $source, $income_time)
$industry_type, $remark, $transfer_img, $source, $income_time,$is_dividend,$last_transfer_time)
{
$arr["report_id"] = $report_id;
......@@ -156,6 +232,12 @@ class OrderLogService
if ($income_time) {
$arr["income_time"] = date("Y-m-d H:i:s", $income_time);
}
if($is_dividend){
$arr["is_dividend"] = $is_dividend;
}
if($last_transfer_time){
$arr["last_transfer_time"] = date("Y-m-d H:i:s", $income_time);
}
return $arr;
}
......
<?php
namespace app\api_broker\service;
use app\model\OPayLogModel;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/13
* Time : 3:45 PM
* Intro:
*/
class PayLogService
{
private $payLogModel;
public function __construct()
{
$this->payLogModel = new OPayLogModel();
}
public function getBeForNum($order_id)
{
$filed = "house_number,industry_type";
return $this->payLogModel->getBeforeBillInfo($filed, ["order_id" => $order_id]);
}
}
\ No newline at end of file
......@@ -725,6 +725,8 @@ Route::group('broker', [
'getExclusive' => [ 'api_broker/Shop/getExclusive', [ 'method' => 'get|post' ] ],
'editExclusive' => [ 'api_broker/Shop/editExclusive', [ 'method' => 'get|post' ] ],
'getBeForNum' => ['api_broker/PayLog/getBeForNum', ['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