Commit 4d21634c by hcy001
parents 852a4d3e d7b747b6
......@@ -3,4 +3,5 @@
Homestead.yaml
Homestead.json
.idea
.env
\ No newline at end of file
.env
storage/logs/
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Model\CommonModel;
use App\Model\InquiryItemsAssignModel;
use App\Model\InquiryItemsReportModel;
use App\Model\InquiryModel;
use App\Model\InquiryItemsModel;
......@@ -99,6 +100,41 @@ class ApiController extends Controller
ExportLayui((new QuoteModel())->ItemsList($input));
}
// 已领取列表
private function GetAssignList($input, $id){
$inquiry_items_id = $input['inquiry_items_id'];
$p = $input['p'] ? $input['p'] : 1;
$limit = $input['limit'] ? $input['limit'] : 10;
$InquiryItemsAssignModel = new InquiryItemsAssignModel;
$list = $InquiryItemsAssignModel->GetAssignList($inquiry_items_id, $p, $limit);
if ($list['data'] && is_array($list['data'])){
$InquiryItemsModel = new InquiryItemsModel();
$inquire_item_info = $InquiryItemsModel->where('id', $inquiry_items_id)->first()->toArray();
if ($inquire_item_info){
// 获取领取了询价单后已报价的uids
$QuoteModel = new QuoteModel();
$assign_uids = array_column($list['data'], 'assign_uid');
$quoted_uids = $QuoteModel->GetQuotedUids($inquiry_items_id, $assign_uids);
foreach ($list['data'] as $k => &$assign_item){
$assign_item['goods_name'] = $inquire_item_info['goods_name'];
$assign_item['brand_name'] = $inquire_item_info['brand_name'];
$assign_item['status_name'] = "已领取";
$assign_item['create_time'] = date("Y-m-d H:i:s", $assign_item['create_time']);
}
// 判断当前用户是否有对该询价单报价,如果有报价,那么过滤
if (in_array($assign_item['assign_uid'], $quoted_uids)){
unset($list['data'][$k]);
}
}
}
$data = [0, '成功', $list['data'], $list['total']];
ExportLayui($data);
}
//搜索品牌
private function ApiBrandList($input, $id){
(new CommonModel())->BrandList($input['k'],@$input["types"] ? @$input["types"] : 1);
......@@ -143,6 +179,7 @@ class ApiController extends Controller
private function ApiInquiryExport($input){
(new ExportModel())->InquiryExport($input,$this->user_id);
}
//生成报价pdf
private function ApiOfferPdf($request){
(new CommonModel())->Pdf();
......@@ -194,6 +231,8 @@ class ApiController extends Controller
Export((new InquiryItemsModel())->import($input));
}
// 删除报价草稿
public function ApiDeleteQuoteDraft($input, $id)
{
......
......@@ -41,6 +41,7 @@ class ServerController extends Controller
$server->addMethod('InquiryServer',$this);
$server->handle();
}
public function InquiryServer($info){
$res= (new InquiryModel())->getList(json_decode($info,true),1);
return ExportLayuiReturn($res);
......
......@@ -8,7 +8,7 @@ defined('REPORT_APP_NAME') or define('REPORT_APP_NAME', 'frq_api');
defined('LOG_FILE_SIZE') or define('LOG_FILE_SIZE', 2097152); //2MB
// 设定错误和异常处理
error_reporting(0);
error_reporting(E_ERROR);
LogReport::auto();
......
<?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
......@@ -63,5 +63,4 @@ class ExportModel
echo self::push($data);
}
}
\ No newline at end of file
......@@ -11,6 +11,12 @@ class InquiryItemsAssignModel extends Model
protected $primaryKey = 'id';
public $timestamps = false;
// 领取类型 1 指定 2 领取
const ASSIGN_TYPE_BIND = 1;
const ASSIGN_TYPE_SELECTED = 2;
// 领取询价
public function assign($inquiry_items_id, $assign_uid, $types=1)
{
......@@ -27,6 +33,24 @@ class InquiryItemsAssignModel extends Model
return $this->insert($data);
}
public function GetAssignList($inquiry_items_id, $p, $limit)
{
return $this
->where("inquiry_items_id", $inquiry_items_id)
->where("assign_type", self::ASSIGN_TYPE_SELECTED)
->orderBy('id','desc')
->paginate($limit ? $limit : 10, ['*'], 'p', $p ? $p : 1)
->toArray();
}
public function GetAssignCountByInquiryId($inquiry_items_id)
{
return $this
->where("inquiry_items_id", $inquiry_items_id)
->count();
}
// 删除
public function delAssign($inquiry_items_id, $assign_uid, $types=1)
{
......
......@@ -25,6 +25,12 @@ class InquiryItemsModel extends Model
return strtotime(parent::fromDateTime($value));
}
public function GetInquireItemsListByIds($ids)
{
return $this->whereIn("id", $ids)->get()->toArray();
}
//生成报价单详情
public function ItemsOfferDetail($inquiry_id)
{
......@@ -109,6 +115,11 @@ class InquiryItemsModel extends Model
// 添加操作日志
$inquiry_items = $this->find($id);
// 检查询价单状态,如果状态为默认的 待报价 状态,那么更改为 已领取状态
if ($inquiry_items['status'] == InquiryMap::status_ready){
$this->where('id', $id)->update(['status' => InquiryMap::status_fix]);
}
$data = [];
$data['types'] = 1;
$data['relation_id'] = $id;
......@@ -250,6 +261,8 @@ class InquiryItemsModel extends Model
if(count($assignInsert) >0){ #插入指定人
(new InquiryItemsAssignModel())->insert($assignInsert);
}
$this->where('id', $inquiryItemsId)->update(['status' => 4]); // 存在指定采购,则标记状态为已领取
}
#日志
......@@ -331,6 +344,8 @@ class InquiryItemsModel extends Model
if(count($assignInsert) >0){ #插入指定人
$InquiryItemsAssignModel->insert($assignInsert);
}
$this->where('id', $inquiry_items_id)->update(['status' => 4]); // 存在指定采购,则标记状态为已领取
}
#发送消息
......
......@@ -217,7 +217,7 @@ class InquiryItemsReportModel extends Model
* 判断是否能生成销售单
*/
public function checkOrder($input){
$check = $this->where(["price_origin"=>0,"price_rmb"=>0])->whereIn("id",explode(",",$input["inquiry_items_id"]))->count();
$check = $this->where(["price_origin"=>0,"price_rmb"=>0])->whereIn("id",explode(",",$input["report_ids"]))->count();
return $check >0 ? [1001,"没有销售报价的报价单不能生成销售订单"] : [0,"通过"];
}
/*
......
......@@ -20,6 +20,12 @@ class InquiryModel extends Model
protected $primaryKey = 'id';
public $timestamps = false;
public function GetInquiryListByIds($ids)
{
return $this->whereIn("id", $ids)->get()->toArray();
}
/**
* 询价列表
*/
......@@ -77,7 +83,6 @@ class InquiryModel extends Model
}
}
});
#不同类别查询
switch (@$input["types"]) {
case "1": //我的询价
......@@ -119,6 +124,8 @@ class InquiryModel extends Model
$QuoteModel = new QuoteModel();
$InquiryItemsAssignModel = new InquiryItemsAssignModel();
$BestGoodsModel = new BestGoodsModel();
$Redis = \RedisDB::connection();
foreach ($list['data'] as $k => &$v) {
$inquiry_items_id = $v["id"]; #明细id
......@@ -166,6 +173,11 @@ class InquiryModel extends Model
$v['inquiry_sn_origin'] = $v["inquiry_sn"];
// 查询历史报价数
$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集合中检查是否有新的报价
if ($export == 0){
$res = $Redis->SISMEMBER('frq_quote_urge', $v['id']);
......@@ -246,8 +258,7 @@ class InquiryModel extends Model
->join('inquiry_items_urge as u', 'b.id', '=', 'u.inquiry_items_id')
->where('c.assign_uid', $user_id);
}
$list = $list->select(DB::Raw("lie_a.inquiry_sn,lie_a.currency,lie_a.status as status_a,lie_a.user_name,lie_a.com_name,lie_a.create_name,lie_a.create_time as inquiry_ctime, lie_b.*, lie_c.id as c_id, lie_c.assign_type as c_assign_type"))
$list = $list->select(DB::Raw("lie_a.inquiry_sn,lie_a.currency,lie_a.status as status_a,lie_a.user_name,lie_a.com_name,lie_a.create_name,lie_a.create_time as inquiry_ctime, lie_a.remark as inquiry_remark, lie_b.*, lie_c.id as c_id, lie_c.assign_type as c_assign_type"))
->where(function ($query) use ($input, $type, $user_id) {
foreach ($input as $k => $v) {
$v = trim($v);
......@@ -310,7 +321,6 @@ class InquiryModel extends Model
// $tmp = vsprintf($tmp, $list->getBindings());
// echo $tmp;
// exit;
$page = isset($input['p']) ? $input['p'] : $input['page'];
$list = $list->orderBy('b.id', 'desc')->paginate(@$input['limit'] ? $input["limit"] : 10, ['*'], 'p', @$page ? $page : 1)->toArray();
......@@ -318,6 +328,8 @@ class InquiryModel extends Model
$QuoteModel = new QuoteModel();
$InquiryItemsUrgeModel = new InquiryItemsUrgeModel;
$InquiryItemsAssignModel = new InquiryItemsAssignModel;
foreach ($list['data'] as $k => &$v) {
//报价
......@@ -353,6 +365,9 @@ class InquiryModel extends Model
}
}
$v['assign_count'] = $InquiryItemsAssignModel->GetAssignCountByInquiryId($v['id']);
$v['delivery_time'] = $v['delivery_time'] > 6 ? ($v['delivery_time']/7).'周' : $v['delivery_time']."天";
}
return [0, '成功', $list['data'], $list['total']];
......
......@@ -3,7 +3,7 @@ namespace App\map;
//询价枚举
class InquiryMap{
//状态 -1:已关闭 1:待报价 2:已报价 3:已选中 4:已固定 5:已确认
//状态 -1:已关闭 1:待报价 2:已报价 3:已选中 4:已领取 5:已确认
const status_close = -1;
const status_ready = 1;
const status_replay = 2;
......@@ -15,7 +15,7 @@ class InquiryMap{
self::status_ready => "待报价",
self::status_replay => "已报价",
self::status_check => "已选中",
self::status_fix => "已固定",
self::status_fix => "已领取",
self::status_sure => "已确认",
];
......
......@@ -41,6 +41,7 @@ $app->singleton(
App\Exceptions\Handler::class
);
$app->useStoragePath(APP_STORAGE_PATH);
/*
|--------------------------------------------------------------------------
| Return The Application
......
......@@ -122,11 +122,11 @@ return [
],
'mongodb' => [
'driver' => 'mongodb',
'host' => get_resource_config_section('rabbit', 'rabbit')['host'],
'database' => get_resource_config_section('rabbit', 'rabbit')['db'],
'username' => get_resource_config_section('rabbit', 'rabbit')['user'],
'password' => get_resource_config_section('rabbit', 'rabbit')['passwd'],
'port' => get_resource_config_section('rabbit', 'rabbit')['port'],
'host' => get_resource_config_section('mongodb', 'mongo')['host'],
'database' => get_resource_config_section('mongodb', 'mongo')['db'],
'username' => get_resource_config_section('mongodb', 'mongo')['user'],
'password' => get_resource_config_section('mongodb', 'mongo')['passwd'],
'port' => get_resource_config_section('mongodb', 'mongo')['port'],
// 'options' => [
// 'database' => 'ichunt' // sets the authentication database required by mongo 3
// ]
......
......@@ -12,10 +12,14 @@ define('STATUS_ILLEGAL_PARAM',300); //操作被拒绝,可能是参数不合法
define('STATUS_ERROR',400); //列表的数据已被穷尽,没有更多数据
define('STATUS_UNKNOWN',500); //服务器未知错误
$EnvLoader = new Loader(dirname( $_SERVER['DOCUMENT_ROOT'] ) . '/.env');
$EnvLoader->load();
$RESOURCE_CONFIG_DIR = $EnvLoader->getEnvironmentVariable("RESOURCE_CONFIG_DIR");
$APP_STORAGE_PATH = $EnvLoader->getEnvironmentVariable("APP_STORAGE_PATH");
$default_env_file = dirname( $_SERVER['DOCUMENT_ROOT'] ) . '/.env';
$RESOURCE_CONFIG_DIR = $APP_STORAGE_PATH = '';
if (file_exists($default_env_file)){
$EnvLoader = new Loader($default_env_file);
$EnvLoader->load();
$RESOURCE_CONFIG_DIR = $EnvLoader->getEnvironmentVariable("RESOURCE_CONFIG_DIR");
$APP_STORAGE_PATH = $EnvLoader->getEnvironmentVariable("APP_STORAGE_PATH");
}
// 定义资源配置文件目录
define('RESOURCE_CONFIG_DIR' , ($RESOURCE_CONFIG_DIR) ? $RESOURCE_CONFIG_DIR : '/data2/liexin_config');
......
<?php
return [
'quote_status' => [ // 报价状态
-1 => '已撤销',
0 => '草稿',
1 => '已报价',
2 => '已选中',
......
......@@ -18,7 +18,6 @@ ini_set('mongo.long_as_object', 1);
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/../bootstrap/autoload.php';
/*
......
No preview for this file type
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