Commit a079fd68 authored by hujun's avatar hujun

编辑成交报告佣金

parent a7a702c5
......@@ -14,6 +14,7 @@ use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil;
use app\model\AAgents;
use app\model\OBargainModel;
use app\model\OFee;
use app\model\OPartialCommission;
use app\model\OPayLogModel;
use app\model\ORefundModel;
......@@ -192,6 +193,7 @@ class Finance extends Basic
* 修改成交报告中佣金和备注
*
* @return \think\Response
* @throws \Exception
*/
public function editBargainInfo() {
$data['code'] = 200;
......@@ -202,23 +204,27 @@ class Finance extends Basic
$data['code'] = 101;
$data['msg'] = 'Id is null.';
} else {
$bargain = new OBargainModel();
$m_bargain = new OBargainModel();
$m_fee = new OFee();
$update_data = [];
if (!empty($this->params['scale_fee'])) {
$update_data['scale_fee'] = $this->params['scale_fee'];
if (count($this->params['practical_fee']) > 5) {
return $this->response('101', '实收佣金数量超过限制');
}
if (!empty($this->params['practical_fee'])) {
$update_data['practical_fee'] = $this->params['practical_fee'];
if (!empty($this->params['commission'])) {
$update_data['commission'] = $this->params['commission'];
}
if (!empty($this->params['content'])) {
$update_data['content'] = $this->params['content'];
}
$data['data'] = $bargain->updateBargainById($this->params['id'], $update_data);
$data['data'] = $m_bargain->updateBargainById($this->params['id'], $update_data);
if ($data['data'] != 1) {
if ($data['data'] == 1) {
$m_fee->addFee($this->params['practical_fee'], $this->params['id'], 0, $this->userId);
} else {
$data['code'] = 101;
$data['msg'] = 'Modify the failure.';
}
......
......@@ -12,7 +12,7 @@ namespace app\model;
class OFee extends BaseModel
{
/**
* 根据成交报告查询
* 根据成交报告-实收佣金 或 税费开票 查询
*
* @param int $bargain_id
* @param int $type
......@@ -22,11 +22,45 @@ class OFee extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainFee(int $bargain_id, $type = 0, string $field = 'id as fee_id,tax_fee,create_time') {
public function getBargainFee(int $bargain_id, $type = 0, string $field = 'id as fee_id,fee,operation_date') {
return $this->field($field)
->where('bargain_id', $bargain_id)
->where('type', $type)
->select();
}
/**
* 根据成交报告-实收佣金 或 税费开票 查询数量
*
* @param int $bargain_id
* @param int $type
* @return int|string
*/
public function getBargainFeeTotal(int $bargain_id, int $type = 0) {
return $this->where('bargain_id', $bargain_id)
->where('type', $type)
->count();
}
/**
* 新增实收佣金 或 税费开票
*
* @param $data
* @param $bargain_id
* @param int $type 0实收佣金 1税费
* @param int $agent_id 操作人id
* @return array|false
* @throws \Exception
*/
public function addFee($data, $bargain_id, $type = 0, int $agent_id) {
$insert_data = [];
foreach ($data as $k => $v) {
$insert_data[$k]['bargain_id'] = $bargain_id;
$insert_data[$k]['fee'] = $v['fee'];
$insert_data[$k]['agent_id'] = $agent_id;
$insert_data[$k]['type'] = $type;
$insert_data[$k]['operation_date'] = $v['operation_date'];
}
return $this->saveAll($insert_data);
}
}
\ 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