Commit b36e06d3 by 朱继来

调整询价池

parent 7434bdb9
......@@ -11,7 +11,7 @@ class InquiryItemsAssignModel extends Model
protected $primaryKey = 'id';
public $timestamps = false;
// 指定或领取询价
// 领取询价
public function assign($inquiry_items_id, $assign_uid, $types=1)
{
$UserModel = new UserModel;
......@@ -20,6 +20,7 @@ class InquiryItemsAssignModel extends Model
$data['inquiry_items_id'] = $inquiry_items_id;
$data['assign_uid'] = $assign_uid;
$data['assign_name'] = $UserModel->FinduserInfoName($assign_uid);
$data['assign_type'] = 2;
$data['types'] = $types;
$data['create_time'] = time();
......
......@@ -92,13 +92,14 @@ class InquiryItemsModel extends Model
if (!$id) return [-1, '参数缺失'];
try {
$this->where('id', $id)->update(['assign_type' => 2]);
// $this->where('id', $id)->update(['assign_type' => 2]);
$InquiryItemsAssignModel = new InquiryItemsAssignModel;
$map = [];
$map['inquiry_items_id'] = $id;
$map['assign_uid'] = $input['user_id'];
$map['inquiry_items_id'] = $id;
$map['assign_uid'] = $input['user_id'];
$map['assign_type'] = 2;
$res = $InquiryItemsAssignModel->where($map)->value('id');
if ($res) return [-1, '该询价已领取'];
......@@ -108,14 +109,12 @@ class InquiryItemsModel extends Model
// 添加操作日志
$inquiry_items = $this->find($id);
$UserModel = new UserModel;
$data = [];
$data['types'] = 1;
$data['relation_id'] = $id;
$data['content'] = '领取询价,商品名称:'.$inquiry_items['goods_name'];
$data['create_uid'] = $input['user_id'];
$data['create_name'] = $UserModel->FinduserInfoName($input['user_id']);
$data['create_name'] = $input['user_name'];
\App\Model\OpLogModel::log($data);
} catch (Exception $e) {
......
......@@ -253,17 +253,20 @@ class InquiryModel extends Model
}
}
$query->whereIn('a.status', [-1, 1]);
if ($type == 1) {
$query->whereNotIn('b.status', [-1, 5]); // 询价池需过滤已关闭、已确认、指定和领取的询价
$time = time() - 7200; // 待报价的询价两小时后在询价池展示
$query->WhereRaw('((lie_c.assign_type=2 and lie_c.assign_uid <> '.$user_id.') or (lie_c.assign_type=1 and lie_b.status=1 and lie_b.create_time < ' . $time . '))');
if ($type == 1) { // 询价池需过滤已关闭、已确认、指定和领取的询价
$query->where('a.status', 1)
->whereNotIn('b.status', [-1, 5])
->where('b.assign_type', 2)
->whereRaw('(lie_c.assign_uid != '.$user_id.' or lie_c.assign_uid is NULL)');
// $time = time() - 7200; // 待报价的询价两小时后在询价池展示
// $query->WhereRaw('((lie_c.assign_type=2 and lie_c.assign_uid <> '.$user_id.') or (lie_c.assign_type=1 and lie_b.status=1 and lie_b.create_time < ' . $time . '))');
} else {
$query->whereIn('a.status', [-1, 1]);
}
});
if ($type == 4) { // 多条重复催价情况下去重
if ($type == 1 || $type == 4) { // 多条重复催价情况下去重
$list = $list->groupBy('b.id');
}
......
......@@ -10,6 +10,7 @@ use DB;
use App\Model\OpLogModel;
use App\Model\UserModel;
use App\Model\InquiryItemsModel;
use App\Model\InquiryItemsAssignModel;
use App\Model\SearchModel;
use App\Http\Controllers\PermController;
use App\Http\Controllers\ApiController;
......@@ -338,6 +339,17 @@ class QuoteModel extends Model
InquiryItemsModel::where('id', $quote_info['inquiry_items_id'])->update(['status' => 2]);
}
// 从询价池过来的,自动领取
$InquiryItemsAssignModel = new InquiryItemsAssignModel;
$map = [];
$map['inquiry_items_id'] = $quote_info['inquiry_items_id'];
$map['assign_uid'] = $input['user_id'];
$assign_id = $InquiryItemsAssignModel->where($map)->value('id');
if (!$assign_id) {
$InquiryItemsAssignModel->assign($quote_info['inquiry_items_id'], $input['user_id']);
}
// 通知询价人,放入redis
RedisDB::sadd('frq_quote_urge', $quote_info['inquiry_items_id']);
......@@ -562,6 +574,17 @@ class QuoteModel extends Model
InquiryItemsModel::where('id', $input['inquiry_items_id'])->update(['status' => 2]);
}
// 从询价池过来的,自动领取
$InquiryItemsAssignModel = new InquiryItemsAssignModel;
$where = [];
$where['inquiry_items_id'] = $input['inquiry_items_id'];
$where['assign_uid'] = $input['user_id'];
$assign_id = $InquiryItemsAssignModel->where($where)->value('id');
if (!$assign_id) {
$InquiryItemsAssignModel->assign($input['inquiry_items_id'], $input['user_id']);
}
// 通知询价人,放入redis
RedisDB::sadd('frq_quote_urge', $input['inquiry_items_id']);
......
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 sign in to comment