Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d22cb187
authored
Mar 29, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加消息
parent
ce43f6b7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
28 deletions
app/Model/CmsModel.php
app/Model/CommonModel.php
app/Model/QuoteModel.php
config/website.php
app/Model/CmsModel.php
0 → 100644
View file @
d22cb187
<?php
namespace
App\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Request
;
use
Excel
;
use
DB
;
class
CmsModel
extends
Model
{
protected
$table
=
'user_info'
;
protected
$primaryKey
=
'userId'
;
public
$timestamps
=
false
;
// 获取用户指定字段
public
function
getUserInfo
(
$userId
,
$field
=
'name'
)
{
return
$this
->
where
(
'userId'
,
$userId
)
->
value
(
$field
);
}
// 查询用户前台ID
public
function
getWebUserId
(
$userId
)
{
return
$this
->
from
(
'lie_intracode'
)
->
where
(
'admin_id'
,
$userId
)
->
value
(
'user_id'
);
}
}
\ No newline at end of file
app/Model/CommonModel.php
View file @
d22cb187
...
@@ -5,6 +5,7 @@ namespace App\Model;
...
@@ -5,6 +5,7 @@ namespace App\Model;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Request
;
use
Request
;
use
DB
;
use
DB
;
use
App\Model\CmsModel
;
//公共模型
//公共模型
class
CommonModel
extends
Model
class
CommonModel
extends
Model
...
@@ -133,5 +134,66 @@ class CommonModel extends Model
...
@@ -133,5 +134,66 @@ class CommonModel extends Model
echo
json_encode
(
$supplierInfo
,
JSON_UNESCAPED_UNICODE
)
;
echo
json_encode
(
$supplierInfo
,
JSON_UNESCAPED_UNICODE
)
;
}
}
/**
* 发送短信、邮件
* @param [type] $userId [指定发送人的后台ID]
* @param [type] $contents [发送内容]
* @return [type] [description]
*/
public
function
send_msg
(
$userId
,
$contents
)
{
//调用消息接口
$url
=
Config
(
'website.api_domain'
)
.
'msg/sendmessagebyauto'
;
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
$keyword_text
=
'inquiry-text-msg'
;
$keyword_email
=
'inquiry-email-msg'
;
$CmsModel
=
new
CmsModel
;
$user_id
=
$CmsModel
->
getWebUserId
(
$userId
);
$email
=
$CmsModel
->
getUserInfo
(
$userId
,
'email'
);
$msg_info
=
[];
$msg_info
[
'data'
][
'contents'
]
=
$contents
;
$msg_info
=
json_encode
(
$msg_info
[
'data'
],
JSON_UNESCAPED_UNICODE
);
$msgData
=
[
"pf"
=>
1
,
"k1"
=>
$data
[
'k1'
],
"k2"
=>
$data
[
'k2'
],
'data'
=>
$msg_info
,
];
// 短信
if
(
$user_id
)
{
$msgData
[
'keyword'
]
=
$keyword_text
;
$msgData
[
'touser'
]
=
$user_id
;
$res
=
json_decode
(
curl
(
$url
,
$msgData
,
1
),
true
);
if
(
!
$res
||
$res
[
'err_code'
]
!=
0
)
return
false
;
}
// 邮件
if
(
$email
)
{
$msgData
[
'keyword'
]
=
$keyword_email
;
$msgData
[
'touser'
]
=
json_encode
([
$email
]);
$msgData
[
'is_ignore'
]
=
1
;
$res
=
json_decode
(
curl
(
$url
,
$msgData
,
1
),
true
);
if
(
!
$res
||
$res
[
'err_code'
]
!=
0
)
return
false
;
}
return
true
;
}
}
}
\ No newline at end of file
app/Model/QuoteModel.php
View file @
d22cb187
...
@@ -9,6 +9,7 @@ use Request;
...
@@ -9,6 +9,7 @@ use Request;
use
DB
;
use
DB
;
use
App\Model\OpLogModel
;
use
App\Model\OpLogModel
;
use
App\Model\UserModel
;
use
App\Model\UserModel
;
use
App\Model\InquiryModel
;
use
App\Model\InquiryItemsModel
;
use
App\Model\InquiryItemsModel
;
use
App\Model\InquiryItemsAssignModel
;
use
App\Model\InquiryItemsAssignModel
;
use
App\Model\SearchModel
;
use
App\Model\SearchModel
;
...
@@ -93,7 +94,7 @@ class QuoteModel extends Model
...
@@ -93,7 +94,7 @@ class QuoteModel extends Model
{
{
$page
=
$input
[
'page'
];
$page
=
$input
[
'page'
];
$limit
=
$input
[
'limit'
];
$limit
=
$input
[
'limit'
];
$type
=
$input
[
'type'
];
// 1-我的报价,2-所有报价
$type
=
$input
[
'type'
];
// 1-我的报价,2-所有报价
,3-报价草稿
$map
[
'inquiry_sn'
]
=
isset
(
$input
[
'inquiry_sn'
])
?
trim
(
$input
[
'inquiry_sn'
])
:
''
;
// 询价单号
$map
[
'inquiry_sn'
]
=
isset
(
$input
[
'inquiry_sn'
])
?
trim
(
$input
[
'inquiry_sn'
])
:
''
;
// 询价单号
$map
[
'goods_name'
]
=
isset
(
$input
[
'goods_name'
])
?
trim
(
$input
[
'goods_name'
])
:
''
;
// 型号
$map
[
'goods_name'
]
=
isset
(
$input
[
'goods_name'
])
?
trim
(
$input
[
'goods_name'
])
:
''
;
// 型号
...
@@ -137,11 +138,10 @@ class QuoteModel extends Model
...
@@ -137,11 +138,10 @@ class QuoteModel extends Model
}
else
if
(
!
empty
(
$map
[
'end_time'
]))
{
}
else
if
(
!
empty
(
$map
[
'end_time'
]))
{
$query
->
where
(
'q.create_time'
,
'<='
,
$map
[
'end_time'
]);
$query
->
where
(
'q.create_time'
,
'<='
,
$map
[
'end_time'
]);
}
}
})
});
->
where
(
'q.status'
,
'<>'
,
0
);
// 过滤报价草稿
if
(
$type
==
1
)
{
if
(
$type
==
1
)
{
$list
=
$list
->
where
(
'q.create_uid'
,
$input
[
'user_id'
])
;
$list
=
$list
->
where
(
'q.create_uid'
,
$input
[
'user_id'
])
->
where
(
'q.status'
,
'<>'
,
0
);
// 过滤报价草稿
}
else
if
(
$type
==
2
)
{
}
else
if
(
$type
==
2
)
{
$perm
=
new
PermController
;
$perm
=
new
PermController
;
$role
=
$perm
->
getUserRole
(
$input
[
'user_id'
],
$input
[
'email'
]);
// 用户角色
$role
=
$perm
->
getUserRole
(
$input
[
'user_id'
],
$input
[
'email'
]);
// 用户角色
...
@@ -150,6 +150,8 @@ class QuoteModel extends Model
...
@@ -150,6 +150,8 @@ class QuoteModel extends Model
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$input
[
'user_id'
]);
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$input
[
'user_id'
]);
$list
=
$list
->
whereIn
(
'q.create_uid'
,
$sub_sale_ids
);
$list
=
$list
->
whereIn
(
'q.create_uid'
,
$sub_sale_ids
);
}
}
$list
=
$list
->
where
(
'q.status'
,
'<>'
,
0
);
// 过滤报价草稿
}
elseif
(
@
$input
[
'inquiry_items_id'
]
>
0
)
{
}
elseif
(
@
$input
[
'inquiry_items_id'
]
>
0
)
{
$list
=
$list
->
where
(
'q.status'
,
0
)
->
where
(
'q.inquiry_items_id'
,
$input
[
'inquiry_items_id'
]);
$list
=
$list
->
where
(
'q.status'
,
0
)
->
where
(
'q.inquiry_items_id'
,
$input
[
'inquiry_items_id'
]);
}
}
...
@@ -326,7 +328,7 @@ class QuoteModel extends Model
...
@@ -326,7 +328,7 @@ class QuoteModel extends Model
if
(
!
$quote_info
)
return
[
1
,
'报价数据不存在'
];
if
(
!
$quote_info
)
return
[
1
,
'报价数据不存在'
];
try
{
try
{
// 询价明细单状态
// 询价明细单状态
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$quote_info
[
'inquiry_items_id'
])
->
value
(
'status'
);
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$quote_info
[
'inquiry_items_id'
])
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'新增报价失败,该询价明细已关闭'
];
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'新增报价失败,该询价明细已关闭'
];
...
@@ -337,8 +339,8 @@ class QuoteModel extends Model
...
@@ -337,8 +339,8 @@ class QuoteModel extends Model
$quote_info
[
'brand_name'
]
=
$brand
[
0
][
'brand_name'
];
$quote_info
[
'brand_name'
]
=
$brand
[
0
][
'brand_name'
];
unset
(
$quote_info
[
'brand_s'
]);
unset
(
$quote_info
[
'brand_s'
]);
$CommonModel
=
new
CommonModel
;
if
(
$quote_info
[
'currency'
]
==
2
)
{
if
(
$quote_info
[
'currency'
]
==
2
)
{
$CommonModel
=
new
CommonModel
;
$rate
=
$CommonModel
->
getRate
();
$rate
=
$CommonModel
->
getRate
();
$quote_info
[
'price_rmb'
]
=
$rate
?
number_format
(
$quote_info
[
'price_origin'
]
*
$rate
,
6
)
:
0
;
$quote_info
[
'price_rmb'
]
=
$rate
?
number_format
(
$quote_info
[
'price_origin'
]
*
$rate
,
6
)
:
0
;
}
}
...
@@ -382,13 +384,26 @@ class QuoteModel extends Model
...
@@ -382,13 +384,26 @@ class QuoteModel extends Model
$data
=
[];
$data
=
[];
$data
[
'types'
]
=
2
;
$data
[
'types'
]
=
2
;
$data
[
'relation_id'
]
=
$
quote_info
[
'inquiry_items_id'
]
;
$data
[
'relation_id'
]
=
$
res
->
id
;
$data
[
'relation_sn'
]
=
''
;
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'新增报价,报价单号:'
.
$quote_info
[
'quote_sn'
];
$data
[
'content'
]
=
'新增报价,报价单号:'
.
$quote_info
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$input
[
'user_name'
];
$data
[
'create_name'
]
=
$input
[
'user_name'
];
OpLogModel
::
log
(
$data
);
OpLogModel
::
log
(
$data
);
// 推送消息
$InquiryModel
=
new
InquiryModel
;
$inquiry_uid
=
$InquiryModel
->
where
(
'id'
,
$quote_info
[
'inquiry_id'
])
->
value
(
'create_uid'
);
// 询价人
if
(
$quote_info
[
'currency'
]
==
1
)
{
$price
=
'¥'
.
$quote_info
[
'price_rmb'
];
}
else
{
$price
=
'$'
.
$quote_info
[
'price_origin'
];
}
$contents
=
$input
[
'user_name'
]
.
'已报价,请及时查看!报价单号:'
.
$quote_info
[
'quote_sn'
]
.
',单价:'
.
$price
;
$CommonModel
->
send_msg
(
$inquiry_uid
,
$contents
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
return
[
1
,
$e
->
getMessage
()];
}
}
...
@@ -599,11 +614,12 @@ class QuoteModel extends Model
...
@@ -599,11 +614,12 @@ class QuoteModel extends Model
$map
[
'inquiry_items_id'
]
=
$input
[
'inquiry_items_id'
];
$map
[
'inquiry_items_id'
]
=
$input
[
'inquiry_items_id'
];
$map
[
'status'
]
=
0
;
// 草稿状态
$map
[
'status'
]
=
0
;
// 草稿状态
$count
=
$this
->
where
(
$map
)
->
count
();
$count
=
$this
->
where
(
$map
)
->
count
();
if
(
!
$count
)
return
[
1
,
'当前没有导入报价单'
];
if
(
!
$count
)
return
[
1
,
'当前没有导入报价单'
];
$quote_info
=
$this
->
where
(
$map
)
->
get
()
->
toArray
();
// 获取草稿信息
$this
->
where
(
$map
)
->
update
([
'status'
=>
1
]);
$this
->
where
(
$map
)
->
update
([
'status'
=>
1
]);
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
...
@@ -622,17 +638,36 @@ class QuoteModel extends Model
...
@@ -622,17 +638,36 @@ class QuoteModel extends Model
}
}
// 通知询价人,放入redis
// 通知询价人,放入redis
RedisDB
::
sadd
(
'frq_quote_urge'
,
$input
[
'inquiry_items_id'
]);
RedisDB
::
sadd
(
'frq_quote_urge'
,
$input
[
'inquiry_items_id'
]);
$data
=
[];
// 推送消息
$data
[
'types'
]
=
2
;
$InquiryModel
=
new
InquiryModel
;
$data
[
'relation_id'
]
=
$input
[
'inquiry_items_id'
];
$inquiry_uid
=
$InquiryModel
->
where
(
'id'
,
$quote_info
[
0
][
'inquiry_id'
])
->
value
(
'create_uid'
);
// 询价人
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'批量提交报价,询价型号:'
.
$input
[
'inquiry_goods_name'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$input
[
'user_name'
];
OpLogModel
::
log
(
$data
);
$contents
=
$input
[
'user_name'
]
.
'已报价,请及时查看!'
;
foreach
(
$quote_info
as
$v
)
{
$data
=
[];
$data
[
'types'
]
=
2
;
$data
[
'relation_id'
]
=
$v
[
'id'
];
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'批量提交报价,报价单号:'
.
$v
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$input
[
'user_name'
];
OpLogModel
::
log
(
$data
);
if
(
$v
[
'currency'
]
==
1
)
{
$price
=
'¥'
.
$v
[
'price_rmb'
];
}
else
{
$price
=
'$'
.
$v
[
'price_origin'
];
}
$contents
.=
'报价单号:'
.
$v
[
'quote_sn'
]
.
',单价:'
.
$price
.
';'
;
}
$CommonModel
=
new
CommonModel
;
$CommonModel
->
send_msg
(
$inquiry_uid
,
trim
(
$contents
,
';'
));
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
return
[
1
,
$e
->
getMessage
()];
}
}
...
...
config/website.php
View file @
d22cb187
...
@@ -49,24 +49,27 @@ return [
...
@@ -49,24 +49,27 @@ return [
),
),
"cookieDomain"
=>
".liexin.com"
,
"cookieDomain"
=>
".liexin.com"
,
"domain"
=>
"liexin.net"
,
"domain"
=>
"liexin.net"
,
'api_domain'
=>
'http://api.liexin.com/'
,
'frq_export_inquiry'
=>
'23'
,
//导出明细id
'frq_export_inquiry'
=>
'23'
,
//导出明细id
'frq_go_server'
=>
'http://frq.liexin.net'
,
//询价go 对外项目
'frq_url'
=>
'http://frq.liexin.net'
,
'frq_go_server'
=>
'http://frq.liexin.net'
,
//询价go 对外项目
'frq_url'
=>
'http://frq.liexin.net'
,
// 权限系统
// 权限系统
'perm_url'
=>
'http://perm.liexin.net'
,
'perm_url'
=>
'http://perm.liexin.net'
,
// 获取用户权限接口
// 获取用户权限接口
'perm_api'
=>
'http://perm.liexin.net/api/perms/'
,
'perm_api'
=>
'http://perm.liexin.net/api/perms/'
,
// 获取用户许可权限接口
// 获取用户许可权限接口
'check_access_api'
=>
'http://perm.liexin.net/api/perms/access'
,
'check_access_api'
=>
'http://perm.liexin.net/api/perms/access'
,
//上传图片接口地址
//上传图片接口地址
'UploadUrl'
=>
'http://api.liexin.com/oss/upload'
,
'UploadUrl'
=>
'http://api.liexin.com/oss/upload'
,
'UploadKey'
=>
'fh6y5t4rr351d2c3bryi'
,
'UploadKey'
=>
'fh6y5t4rr351d2c3bryi'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment