Commit eb7f5609 authored by zw's avatar zw

调整

parent cb42ed6e
......@@ -217,7 +217,7 @@ class OrderLog extends Basic
// `type` '付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他',
//`pay_type` '支付方式 10支付宝 20 微信 30pos机器 40转账 50现金',
// `money` '入账金额 存分',
// `money` '入账金额',
"collecting_bill" => [ { "type" : 10, "pay_type" : 10, "money" : 1100 }, { "type" :10, "pay_type" : 10, "money": 1200 } ],
"house_number" => "3301号",
"industry_type" => "asdasdasd",
......
......@@ -16,6 +16,7 @@ use think\Request;
class PayLog extends Basic
{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
......@@ -45,14 +46,24 @@ class PayLog extends Basic
}
public function adjustment(){
/**
* 剩余可以调整或退款的钱
* @return \think\Response
*/
public function adjustment()
{
$params = $this->params;
$params = array(
/* $params = array(
"pay_id" => 1,
);
if(empty($params["pay_id"])){
return $this->response("101","请求参数错误");
);*/
if (empty($params["pay_id"])) {
return $this->response("101", "请求参数错误");
}
$result = $this->service_->adjustment($params["pay_id"]);
if ($result == -1) {
return $this->response("101", "不存在此条记录");
}
$this->service_->adjustment($params["pay_id"]);
return $this->response("200","success",["residue_money"=>$result]);
}
}
\ No newline at end of file
......@@ -29,21 +29,27 @@ class PayLogService
return $this->payLogModel->getBeforeBillInfo($filed, ["order_id" => $order_id]);
}
/**
* 计算可以分佣的金额
* @param $pay_id
* @return int
*/
public function adjustment($pay_id){
//todo 1.计算剩余金额 查询调整表 2.减去退款 3.减去转账
$filed = "house_number,industry_type";
$filed = "id,money";
$pay_log_arr = $this->payLogModel->getBeforeBillInfo($filed, ["id" => $pay_id]);
if(count($pay_log_arr) < 0){
return ["code" => 101,"msg"=>"不存在此条收款记录"];
return -1;
}
$pay_log_arr = $pay_log_arr[0];
$where_["paylog_id"] = $pay_id;
$where_["is_del"] = 0;
$adjustment_arr = $this->payLogAdjustmentModel->getAdjustmentList($where_,"id,money");
if(count($adjustment_arr) > 0){
//调整
$adjustment_sum = $this->payLogAdjustmentModel->getAdjustmentSum("money",$where_);
}
$residue_money = $pay_log_arr["money"] - $adjustment_sum["money"];
return $residue_money;
}
......
......@@ -35,6 +35,17 @@ class OPayLogAdjustment extends Model{
->select();
}
public function getAdjustmentSum($field, $params)
{
$data = $this->db_
->where($params)
->sum("money");
//echo $this->getLastSql();
return $data;
}
/**
* @param $field
* @param $params
......
......@@ -728,6 +728,7 @@ Route::group('broker', [
'editExclusive' => [ 'api_broker/Shop/editExclusive', [ 'method' => 'get|post' ] ],
'getBeForNum' => ['api_broker/PayLog/getBeForNum', ['method' => 'get|post']],
'adjustment' => ['api_broker/PayLog/adjustment', ['method' => 'get|post']],
]);
......
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