...
|
...
|
@@ -501,6 +501,7 @@ class ThirdsendController extends HomeBaseController |
|
|
// 查询用户发布需求信息
|
|
|
$where_need['status'] = 3;
|
|
|
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time,pay_time,user_id')->select()->toArray();
|
|
|
$userNeedList['user_type'] = Db::name('Member')->where(['id'=>$userNeedList['user_id']])->value('type');
|
|
|
$time = time();
|
|
|
// 循环需求,查询相应报价
|
|
|
foreach ($userNeedList as $uNeedk => $uNeedv) {
|
...
|
...
|
@@ -579,6 +580,8 @@ class ThirdsendController extends HomeBaseController |
|
|
}else{
|
|
|
$get_list = $fin_arr;
|
|
|
}
|
|
|
}else{
|
|
|
$get_list = $fin_arr;
|
|
|
}
|
|
|
foreach ($else_changeList as $getk=>$getv){
|
|
|
if(in_array($getv,$get_list)){
|
...
|
...
|
@@ -587,6 +590,13 @@ class ThirdsendController extends HomeBaseController |
|
|
}else{
|
|
|
$change_final['id'] = $getv;
|
|
|
$change_final['status'] = 3;
|
|
|
// 中介报价未进入决赛,执行订单退款
|
|
|
$agencyInfo = Db::name('Agency')->alias('a')
|
|
|
->where(['a.id'=>$getv])
|
|
|
->join("hp_Member m", 'm.id = a.agency_id')
|
|
|
->field('a.*,m.company,m.type as user_type')
|
|
|
->find();
|
|
|
$refund_result = $this->agency_order_refund($agencyInfo,'中介报价未进入决赛圈退款',2);
|
|
|
}
|
|
|
$agencyModel = new AgencyModel();
|
|
|
$fianl_AgsaveFirst = $agencyModel->isUpdate(true)->save($change_final);
|
...
|
...
|
@@ -613,25 +623,8 @@ class ThirdsendController extends HomeBaseController |
|
|
if(!$fianl_AgsaveNext){
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 退回中介保证金
|
|
|
$add_a['user_id'] = $changeva['agency_id'];
|
|
|
$add_a['title'] = '报价人数不足';
|
|
|
$add_a['type'] = 1;
|
|
|
$add_a['reason'] = 1;
|
|
|
$add_a['money'] = $changeva['deposit'];
|
|
|
$add_a['create_time'] = time();
|
|
|
$add_a['update_time'] = time();
|
|
|
$amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
|
|
|
if (!$amoney_id) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 用户表增加金额
|
|
|
$where_member['type'] = 2;
|
|
|
$where_member['id'] = $changeva['agency_id'];
|
|
|
$add_money = Db::name('Member')->where($where_member)->setInc('money',$changeva['deposit']);
|
|
|
if (!$add_money) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 中介报价订单退款
|
|
|
$refund_result = $this->agency_order_refund($changeva,'中介报价少于3人退款',1);
|
|
|
|
|
|
}
|
|
|
$userSave_status['id'] = $uNeedv['id'];
|
...
|
...
|
@@ -641,28 +634,8 @@ class ThirdsendController extends HomeBaseController |
|
|
if(!$fianl_Ussave){
|
|
|
Db::rollback();
|
|
|
}
|
|
|
|
|
|
// 退回保证金
|
|
|
// 用户
|
|
|
// 加用户金额明细表
|
|
|
$add_del['need_id'] = $uNeedv['id'];
|
|
|
$add_del['user_id'] = $uNeedv['user_id'];
|
|
|
$add_del['title'] = '报价人数不足';
|
|
|
$add_del['reason'] = 1;
|
|
|
$add_del['type'] = 1;
|
|
|
$add_del['money'] = $uNeedv['pay_money'];
|
|
|
$add_del['create_time'] = time();
|
|
|
$add_del['update_time'] = time();
|
|
|
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
|
|
|
if (!$umoney_id) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
$where_memberNext['type'] = 1;
|
|
|
$where_memberNext['id'] = $uNeedv['user_id'];
|
|
|
$add_moneyNext = Db::name('Member')->where($where_memberNext)->setInc('money',$uNeedv['pay_money']);
|
|
|
if (!$add_moneyNext) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 用户需求订单退款
|
|
|
$refund_result = $this->need_order_refund($userNeedList,'报价人数不足',1);
|
|
|
|
|
|
}
|
|
|
} else {
|
...
|
...
|
@@ -674,27 +647,8 @@ class ThirdsendController extends HomeBaseController |
|
|
if(!$fianl_Ussave){
|
|
|
Db::rollback();
|
|
|
}
|
|
|
|
|
|
// 退回保证金
|
|
|
// 用户
|
|
|
// 加用户金额明细表
|
|
|
$add_del['need_id'] = $uNeedv['id'];
|
|
|
$add_del['user_id'] = $uNeedv['user_id'];
|
|
|
$add_del['title'] = '报价人数不足';
|
|
|
$add_del['type'] = 1;
|
|
|
$add_del['money'] = $uNeedv['pay_money'];
|
|
|
$add_del['create_time'] = time();
|
|
|
$add_del['update_time'] = time();
|
|
|
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
|
|
|
if (!$umoney_id) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
$where_memberNext['type'] = 1;
|
|
|
$where_memberNext['id'] = $uNeedv['user_id'];
|
|
|
$add_moneyNext = Db::name('Member')->where($where_memberNext)->setInc('money',$uNeedv['pay_money']);
|
|
|
if (!$add_moneyNext) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 用户需求订单退款
|
|
|
$refund_result = $this->need_order_refund($userNeedList,'报价人数不足',1);
|
|
|
|
|
|
}
|
|
|
// 插入数据库
|
...
|
...
|
@@ -724,7 +678,11 @@ class ThirdsendController extends HomeBaseController |
|
|
if (time() >= ($needv['choose_time'] + 259200)) {
|
|
|
$where_agency['need_id'] = $needv['id'];
|
|
|
$where_agency['status'] = 4;
|
|
|
$agency_list = Db::name('Agency')->where($where_agency)->select()->toArray();
|
|
|
$agency_list = Db::name('Agency')->alias('a')
|
|
|
->where($where_agency)
|
|
|
->join("hp_Member m", 'm.id = a.agency_id')
|
|
|
->field('a.*,m.company,m.type as user_type')
|
|
|
->select()->toArray();
|
|
|
if ($agency_list) {
|
|
|
$where_agencyUpdate['need_id'] = $needv['id'];
|
|
|
$where_agencyUpdate['status'] = 4;
|
...
|
...
|
@@ -741,39 +699,12 @@ class ThirdsendController extends HomeBaseController |
|
|
if (!$need_result) {
|
|
|
Db::rollback();
|
|
|
} else {
|
|
|
// 加用户金额明细表
|
|
|
$add_del['need_id'] = $needv['id'];
|
|
|
$add_del['user_id'] = $needv['user_id'];
|
|
|
$add_del['title'] = '未选择中介';
|
|
|
$add_del['type'] = 2;
|
|
|
$add_del['money'] = $needv['pay_money'];
|
|
|
$add_del['create_time'] = time();
|
|
|
$add_del['update_time'] = time();
|
|
|
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
|
|
|
if (!$umoney_id) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 中介金额明细表
|
|
|
foreach ($agency_list as $agenk=>$agenv){
|
|
|
$add_a['ag_id'] = $agenv['id'];
|
|
|
$add_a['user_id'] = $agenv['agency_id'];
|
|
|
$add_a['title'] = '用户未选择中介';
|
|
|
$add_a['type'] = 1;
|
|
|
$add_a['money'] = $agenv['deposit'];
|
|
|
$add_a['create_time'] = time();
|
|
|
$add_a['update_time'] = time();
|
|
|
$amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
|
|
|
if (!$amoney_id) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
$where_member['type'] = 2;
|
|
|
$where_member['id'] = $agenv['agency_id'];
|
|
|
$add_money = Db::name('Member')->where($where_member)->setInc('money',$agenv['deposit']);
|
|
|
if (!$add_money) {
|
|
|
Db::rollback();
|
|
|
if ($agency_list) {
|
|
|
foreach ($agency_list as $agency_key => $agency_val) {
|
|
|
// 中介报价订单退款
|
|
|
$this->agency_order_refund($agency_val, '用户未选择中标中介退款',3);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -825,24 +756,8 @@ class ThirdsendController extends HomeBaseController |
|
|
if (!$change_needFinal) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
// 增加用户保证金,余额
|
|
|
$add_del['need_id'] = $needv['id'];
|
|
|
$add_del['user_id'] = $needv['user_id'];
|
|
|
$add_del['title'] = '中介未确认';
|
|
|
$add_del['type'] = 1;
|
|
|
$add_del['money'] = $needv['pay_money'];
|
|
|
$add_del['create_time'] = time();
|
|
|
$add_del['update_time'] = time();
|
|
|
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
|
|
|
if (!$umoney_id) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
$where_member['type'] = 1;
|
|
|
$where_member['id'] = $needv['user_id'];
|
|
|
$add_money = Db::name('Member')->where($where_member)->setInc('money',$needv['pay_money']);
|
|
|
if (!$add_money) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
$need_list['user_type'] = Db::name('Member')->where(['id'=>$need_list['user_id']])->value('type');
|
|
|
$this->need_order_refund($agency,'中介未确认成交退款',5);
|
|
|
}
|
|
|
}
|
|
|
Db::commit();
|
...
|
...
|
|