Commit f1e49309 authored by hujun's avatar hujun

提交分佣方业绩统计

parent b85d6604
...@@ -638,6 +638,7 @@ class OrderLog extends Basic ...@@ -638,6 +638,7 @@ class OrderLog extends Basic
$data['data'] = $bargain->addBargainCommission($this->params['id'], $this->agentId, $this->params['agent_id'], $data['data'] = $bargain->addBargainCommission($this->params['id'], $this->agentId, $this->params['agent_id'],
$this->params['role'], $this->params['scale_fee'], $this->params['scale'], $source); $this->params['role'], $this->params['scale_fee'], $this->params['scale'], $source);
$this->updatePerformance((int)$this->params['id'], (int)$this->params['agent_id']);
if ($data['data'] == 0) { if ($data['data'] == 0) {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Add the failure.'; $data['msg'] = 'Add the failure.';
...@@ -783,5 +784,35 @@ class OrderLog extends Basic ...@@ -783,5 +784,35 @@ class OrderLog extends Basic
} }
/**
* 更新个人业绩
*
* @param int $bargain_id
* @param int $agent_id
* @return bool
*/
private function updatePerformance(int $bargain_id = 0, int $agent_id = 0) : bool{
$where = [];
if ($bargain_id) {
$where['b.id'] = $bargain_id;
}
if ($agent_id) {
$where['a.id'] = $agent_id;
}
if (!empty($where)) {
//获取被修改人信息
$m_agent = new AAgents();
$agent_data = $m_agent->agentBragainDetail('a.id,a.store_id,a.district_id,b.create_time', ['b.id'=>$bargain_id]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
$date = date('Y-m-d', strtotime($agent_data['create_time']));
$sum->updateTotalByAgentId($agent_data['id'], $agent_data['store_id'], $agent_data['district_id'], $date); //被修改的人
}
return true;
}
} }
\ No newline at end of file
...@@ -390,6 +390,8 @@ class Finance extends Basic ...@@ -390,6 +390,8 @@ class Finance extends Basic
try { try {
$data['data'] = $bargain->addBargainCommission($this->params['id'], $this->userId, $this->params['agent_id'], $data['data'] = $bargain->addBargainCommission($this->params['id'], $this->userId, $this->params['agent_id'],
$this->params['role'], $this->params['scale_fee'], $this->params['scale'], 1); $this->params['role'], $this->params['scale_fee'], $this->params['scale'], 1);
$this->updatePerformance((int)$this->params['bargain_id'], (int)$this->params['agent_id']);
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->response(101, '内部错误,新增分佣提成失败!请联系运营。'); return $this->response(101, '内部错误,新增分佣提成失败!请联系运营。');
} }
......
...@@ -932,12 +932,6 @@ class OBargainModel extends Model ...@@ -932,12 +932,6 @@ class OBargainModel extends Model
$result = $this->insert($insert_data); $result = $this->insert($insert_data);
if ($result == 1) { if ($result == 1) {
$this->commit(); $this->commit();
$agent_data = $m_agent->verifyUser('store_id,district_id', '', [ 'id' => $agent_id ]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
$date = date('Y-m-d', strtotime($bargain_data['create_time']));
$sum->updateTotalByAgentId($agent_id, $agent_data['store_id'], $agent_data['district_id'], $date); //被修改的人
} else { } else {
$this->rollback(); $this->rollback();
$result = false; $result = false;
......
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