Commit 692be23e authored by hujun's avatar hujun

财务结单判断

parent a425126d
...@@ -1193,7 +1193,6 @@ class Finance extends Basic ...@@ -1193,7 +1193,6 @@ class Finance extends Basic
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/ */
public function checkOver() public function checkOver()
{ {
...@@ -1202,6 +1201,13 @@ class Finance extends Basic ...@@ -1202,6 +1201,13 @@ class Finance extends Basic
} }
$m_bargain = new OBargainModel(); $m_bargain = new OBargainModel();
$m_partial_commission = new OPartialCommission();
$confirm_status = $m_partial_commission->checkConfirmStatus($this->params['bargain_id']);
if ($confirm_status) {
return $this->response(101, '请确认分佣');
}
$insert_data['audit_id'] = $this->userId; $insert_data['audit_id'] = $this->userId;
$insert_data['audit_name'] = $this->userName; $insert_data['audit_name'] = $this->userName;
......
...@@ -434,11 +434,10 @@ class OBargainModel extends Model ...@@ -434,11 +434,10 @@ class OBargainModel extends Model
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/ */
public function addCheckBargain(int $id, array $data, int $source, int $status): bool public function addCheckBargain(int $id, array $data, int $source, int $status): bool
{ {
// $this->startTrans(); $this->startTrans();
$bargain_data = $this->field('id,report_id,agent_id,order_no,order_id')->where([ $bargain_data = $this->field('id,report_id,agent_id,order_no,order_id')->where([
'id' => $id, 'id' => $id,
'status' => [ 'in', '10,11' ] 'status' => [ 'in', '10,11' ]
...@@ -492,10 +491,10 @@ class OBargainModel extends Model ...@@ -492,10 +491,10 @@ class OBargainModel extends Model
$this->where('id', $bargain_data['id'])->setField('status', 21); $this->where('id', $bargain_data['id'])->setField('status', 21);
} }
// $this->commit(); $this->commit();
$result = true; $result = true;
} else { } else {
// $this->rollback(); $this->rollback();
$result = false; $result = false;
} }
} else { } else {
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace app\model; namespace app\model;
use think\Exception;
class OPartialCommission extends BaseModel class OPartialCommission extends BaseModel
{ {
protected $table = "o_partial_commission"; protected $table = "o_partial_commission";
...@@ -298,4 +300,41 @@ class OPartialCommission extends BaseModel ...@@ -298,4 +300,41 @@ class OPartialCommission extends BaseModel
->group('a.agent_id') ->group('a.agent_id')
->count(); ->count();
} }
/**
* 检查是否有未结单分佣
*
* @param $bargain_id
* @return int 0 无 1 有
*/
public function checkConfirmStatus($bargain_id) {
$result = 0;
try {
$data = $this->field('confirm_status')
->alias('a')
->join('o_bargain b', 'a.bargain_id = b.id', 'left')
->where('b.id', $bargain_id)
->whereor('b.father_id', $bargain_id)
->where('a.is_del', 0)
->select();
if (empty($data[0]['confirm_status'])) {
$result = 1;
} else {
foreach ($data as $k=>$v) {
if ($v['confirm_status'] == 0) {
$result = 1;
break;
}
}
}
} catch (Exception $e) {
$result = 0;
}
return $result;
}
} }
\ 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