Commit 0c91faa2 authored by hujun's avatar hujun

修改成交报告分佣方-方法优化

parent d7843f65
......@@ -2705,6 +2705,98 @@ class Finance extends Basic
return $this->response(200, '修改成功', $data);
}
/**
* 成交报告分佣方详情
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargainCommissionV2()
{
if (empty($this->params['bargain_id'])) {
return $this->response(101, '成交报告id为空');
}
$field = 'a.id,a.scale,a.agent_id,a.role,a.scale_fee,b.scale as new_scale,b.should_commission,a.father_id,a.create_time,c.income_time';
$data = $this->m_bargain->getBargainPartialRealDetail($field, ['id' => $this->params['bargain_id']]);
if (empty($data)) {
return $this->response(101, '没有记录');
}
if ($this->request->isGet()) {
$data['scale'] = empty($data['new_scale']) ? $data['scale'] : $data['new_scale'];
$data['scale_fee'] = empty($data['should_commission']) ? $data['scale_fee'] : $data['should_commission'];
$s_redis = new RedisCacheService();
$agent_data = $s_redis->getRedisCache(2, $data['agent_id']);
$data['district_name'] = $agent_data['district_name'];
$data['store_name'] = $agent_data['store_name'];
$data['name'] = $agent_data['name'];
$data['phone'] = $agent_data['phone'];
$data['store_id'] = $agent_data['store_id'];
$data['district_id'] = $agent_data['district_id'];
return $this->response(200, '', $data);
}
if (empty($this->params['agent_id'])) {
return $this->response(101, '经纪人id为空');
}
if (empty($this->params['scale'])) {
return $this->response(101, '分佣比例为空');
}
$update['agent_id'] = $this->params['agent_id'];
$update['scale'] = $this->params['scale'];
$update['role'] = $this->params['role'];
$update['scale_fee'] = $this->params['scale_fee'];
$num = $this->m_bargain->updateBargainById($this->params['bargain_id'], $update); //更改分佣方
if (!$num) {
return $this->response(101, '修改失败');
}
$comm = new OPartialCommission();
$partial_data['scale'] = $this->params['scale'];
$partial_data['role'] = $this->params['role'];
$partial_data['should_commission'] = $this->params['scale_fee'];
$partial_data['agent_id'] = $this->params['agent_id'];
$comm->editData($partial_data, $this->params['bargain_id'], 'bargain_id');
/*记录日志 start*/
$father_id = $this->params['bargain_id'];
if ($data['father_id'] == 0) {
$father_id = $data['father_id'];
}
$content = '';
if ($data['agent_id'] != $this->params['agent_id']) {
$redis = new RedisCacheService();
$old_agent = $redis->getRedisCache(2, $data['agent_id']);
$this->totalOfficialReceiptsV2($old_agent['id'], $old_agent['district_id'], $old_agent['store_id'], $data['create_time'], $data['income_time']);
$content .= '【分佣方:' . $old_agent['name'] . '-' . $old_agent['phone'] . '】';
$new_agent = $redis->getRedisCache(2, $this->params['agent_id']);
$this->totalOfficialReceiptsV2($new_agent['id'], $new_agent['district_id'], $new_agent['store_id'], $data['create_time'], $data['income_time']);
$content .= '【修改为:' . $new_agent['name'] . '-' . $new_agent['phone'] . '】';
}
if ($this->params['scale'] != $data['scale']) {
$content .= '【分佣比例修改为:' . $this->params['scale'] . '】';
}
if ($this->params['scale_fee'] != $data['scale_fee']) {
$content .= '【应分佣金修改为:' . $this->params['scale_fee'] . '】';
}
if (!empty($content)) {
$this->editRecordLog($father_id, '【编号:' . $father_id . '】' . $content);
}
/*记录日志 end*/
return $this->response(200, '修改成功');
}
/**
* 撤销成交报告
*
......
......@@ -1729,4 +1729,32 @@ class OBargainModel extends Model
->where($where)
->select();
}
/**
* @param $filed
* @param $params
* @return array|false|\PDOStatement|string|Model
*/
public function getBargainPartialRealDetail($filed, $params)
{
$where_ = $whereOr_ = [];
if (isset($params["bargain_id"])) {
$where_["a.id"] = $params["bargain_id"];
$whereOr_["a.father_id"] = $params["bargain_id"];
}
if (isset($params['id'])) {
$where_['a.id'] = $params['id'];
}
return $this->db_
->field($filed)
->alias("a")
->join("o_partial_commission b", "a.id = b.bargain_id", "left")
->join("o_real_income c", "b.real_income_id = c.id", "left")
->where($where_)
->whereOr($whereOr_)
->order("a.id asc")
->find();
}
}
\ No newline at end of file
......@@ -283,7 +283,7 @@ Route::group('index', [
'checkOver' => ['index/Finance/checkOver', ['method' => 'POST']], //财务结单
'delPartialCommission' => ['index/Finance/delPartialCommission', ['method' => 'POST']], //删除分佣方
'delTaxes' => ['index/Finance/delTaxes', ['method' => 'POST']], //删除开票税费
'getBargainCommission' => ['index/Finance/getBargainCommission', ['method' => 'GET|POST']], //获取成交报告分佣方佣金和修改
'getBargainCommission' => ['index/Finance/getBargainCommissionV2', ['method' => 'GET|POST']], //获取成交报告分佣方佣金和修改
'dailyList' => ['index/Finance/dailyList', ['method' => 'GET']], //财务日报列表
'dailyDetailsFinance' => ['index/Finance/dailyDetails', ['method' => 'GET|POST']], //财务日报详情
'addReceiptImg' => ['index/Finance/addReceiptImg', ['method' => 'post|get']],//收款图片信息保存
......
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