Commit a998c550 by 杜文军

优选

parent 5c2a0402
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class BestGoodsModel extends Model
{
protected $connection = 'rfq';
protected $table = 'best_goods';
protected $primaryKey = 'id';
const STATUS_ENABLE = 1; // 有效
const STATUS_DISABLE = 2; // 无效
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public function GetList($where = [], $page = 1, $limit = 10)
{
if ($where) {
$list = $this->where($where)->orderBy('id', 'desc')->paginate($limit, ['*'], 'p', $page)->toArray();
} else {
$list = $this->select()->orderBy('id', 'desc')->paginate($limit, ['*'], 'p', $page)->toArray();
}
return $list;
}
public function getCountByWhere($where = [])
{
if ($where) {
return $this->where($where)->count();
} else {
return $this->count();
}
}
public function GetListByIds($ids)
{
return $this->whereIn("id", $ids)->get()->toArray();
}
public function updateByIds($ids, $data)
{
return $this->whereIn("id", $ids)->update($data);
}
}
\ No newline at end of file
...@@ -124,6 +124,8 @@ class InquiryModel extends Model ...@@ -124,6 +124,8 @@ class InquiryModel extends Model
$QuoteModel = new QuoteModel(); $QuoteModel = new QuoteModel();
$InquiryItemsAssignModel = new InquiryItemsAssignModel(); $InquiryItemsAssignModel = new InquiryItemsAssignModel();
$BestGoodsModel = new BestGoodsModel();
$Redis = \RedisDB::connection(); $Redis = \RedisDB::connection();
foreach ($list['data'] as $k => &$v) { foreach ($list['data'] as $k => &$v) {
$inquiry_items_id = $v["id"]; #明细id $inquiry_items_id = $v["id"]; #明细id
...@@ -173,6 +175,8 @@ class InquiryModel extends Model ...@@ -173,6 +175,8 @@ class InquiryModel extends Model
// 查询历史报价数 // 查询历史报价数
$v['history_quote_count'] = $QuoteModel->GetHistoryQuotedCount($v['goods_name']); $v['history_quote_count'] = $QuoteModel->GetHistoryQuotedCount($v['goods_name']);
// 查询优选匹配数
$v['best_count'] = $BestGoodsModel->getCountByWhere([["goods_name", '=', $v['goods_name']], ["g_status", '=', BestGoodsModel::STATUS_ENABLE]]);
// 在Redis集合中检查是否有新的报价 // 在Redis集合中检查是否有新的报价
if ($export == 0){ if ($export == 0){
......
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