Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
f20d83a3
Commit
f20d83a3
authored
Nov 05, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mongoDbupdate
parent
fc94ffd1
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
55 additions
and
9 deletions
+55
-9
ApiConst.php
application/library/Our/ApiConst.php
+1
-0
ArrayConst.php
application/library/Our/ArrayConst.php
+2
-0
AbstractClient.php
application/library/Our/Controller/AbstractClient.php
+2
-0
DbNameConst.php
application/library/Our/DbNameConst.php
+1
-0
DescribeConst.php
application/library/Our/DescribeConst.php
+3
-0
OrderService.php
application/models/Business/Order/OrderService.php
+3
-1
OrderLog.php
application/models/DAO/Order/OrderLog.php
+15
-0
MongoDb.php
application/models/Mongo/MongoDb.php
+16
-7
Shopkeeper.php
application/modules/Client/controllers/Shopkeeper.php
+1
-1
User.php
application/modules/Client/controllers/User.php
+1
-0
application.ini
conf/application.ini
+10
-0
No files found.
application/library/Our/ApiConst.php
View file @
f20d83a3
...
...
@@ -178,6 +178,7 @@ class ApiConst
const
refundApplyOnlyMoney
=
1
;
const
refundApply
=
2
;
const
refundApplyPlatform
=
3
;
const
sellerUpdateOrderAmount
=
4
;
const
goodsStateWaitSend
=
1
;
const
goodsStateWaitRecieve
=
2
;
...
...
application/library/Our/ArrayConst.php
View file @
f20d83a3
...
...
@@ -112,6 +112,8 @@ class ArrayConst
ApiConst
::
refundApplyOnlyMoney
=>
'买家申请退款'
,
ApiConst
::
refundApply
=>
'买家申请退货退款'
,
ApiConst
::
refundApplyPlatform
=>
'买家申请平台介入'
,
ApiConst
::
sellerUpdateOrderAmount
=>
'卖家修改订单金额'
,
);
const
couponState
=
array
(
...
...
application/library/Our/Controller/AbstractClient.php
View file @
f20d83a3
...
...
@@ -20,6 +20,7 @@ abstract class Controller_AbstractClient extends \Our\Controller_Abstract {
public
$storeId
;
public
$sellerName
;
public
$sellerId
;
public
$memberName
;
/**
* api控制器直接输出json格式数据,不需要渲染视图
*/
...
...
@@ -34,6 +35,7 @@ abstract class Controller_AbstractClient extends \Our\Controller_Abstract {
$sess
=
\Yaf\Session
::
getInstance
();
$sess
->
start
();
$this
->
memberId
=
$sess
->
get
(
'member_id'
);
$this
->
memberName
=
$sess
->
get
(
'member_name'
);
$this
->
storeId
=
$sess
->
get
(
'store_id'
);
$this
->
sellerName
=
$sess
->
get
(
'seller_name'
);
$this
->
sellerId
=
$sess
->
get
(
'seller_id'
);
...
...
application/library/Our/DbNameConst.php
View file @
f20d83a3
...
...
@@ -11,5 +11,6 @@ class DbNameConst {
const
salveDBConnectName
=
'resources.database.slave.params'
;
const
masterDBConnectName
=
'resources.database.params'
;
const
drawSource
=
'resources.database.drawSource.params'
;
const
mongoDBConnectName
=
'resources.database.mongo.params'
;
}
\ No newline at end of file
application/library/Our/DescribeConst.php
View file @
f20d83a3
...
...
@@ -175,5 +175,8 @@ class DescribeConst
const
updateSuccess
=
'修改成功'
;
const
updateFail
=
'修改失败'
;
//订单日志角色
const
buyerLog
=
'买家'
;
const
sellerLog
=
'商家'
;
}
?>
\ No newline at end of file
application/models/Business/Order/OrderService.php
View file @
f20d83a3
...
...
@@ -823,9 +823,10 @@ class OrderServiceModel extends \Business\AbstractModel
}
public
function
updateOrderAmount
(
$storeId
,
$orderId
,
$newOrderAmount
)
public
function
updateOrderAmount
(
$storeId
,
$orderId
,
$newOrderAmount
,
$memberName
)
{
$orderDao
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
// $orderLogDao=\DAO\Order\OrderLogModel::getInstance(DbNameConst::masterDBConnectName);
$orderDetail
=
$orderDao
->
getByOrderId
(
$orderId
,
$orderDao
->
getOrderDetailField
());
$orderDetail
=
$orderDetail
[
ApiConst
::
arrBegin
];
if
(
$orderDetail
[
'storeId'
]
!=
$storeId
){
...
...
@@ -836,6 +837,7 @@ class OrderServiceModel extends \Business\AbstractModel
}
$data
[
'order_amount'
]
=
$newOrderAmount
;
$res
=
$orderDao
->
updateByOrderId
(
$data
,
$orderId
);
// $orderLogDao->add($orderDetail['orderId'],ArrayConst::logMsgType[ApiConst::sellerUpdateOrderAmount],DescribeConst::sellerLog,$memberName,$orderDetail['orderState']);
return
$res
;
}
...
...
application/models/DAO/Order/OrderLog.php
100755 → 100644
View file @
f20d83a3
...
...
@@ -38,7 +38,22 @@ class OrderLogModel extends \DAO\AbstractModel
{
//$this->setDb();
}
public
function
addLogToMongo
(
$log
){
$mongoDb
=
new
\Mongo\MongoDbModel
();
$res
=
$mongoDb
->
insert
(
'han_order_log'
,
$log
);
return
$res
;
}
//添加日志
public
function
add
(
$orderId
,
$logMsg
,
$logRole
,
$logUser
,
$logOrderState
){
$data
[
'order_id'
]
=
$orderId
;
$data
[
'log_msg'
]
=
$logMsg
;
$data
[
'log_role'
]
=
$logRole
;
$data
[
'log_user'
]
=
$logUser
;
$data
[
'log_orderstate'
]
=
$logOrderState
;
$data
[
'log_time'
]
=
TIMESTAMP
;
return
$this
->
addLogToMongo
(
$data
);
}
public
function
addLog
(
$log
){
$this
->
setDb
(
$this
->
dbName
);
$logId
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
rows
(
$log
)
->
execute
();
...
...
application/models/Mongo/MongoDb.php
View file @
f20d83a3
<?php
namespace
Mongo
;
use
Our\Common
;
use
Our\DbNameConst
;
/**
* Mongodb 基本操作API,支持基本类似关系统型数据库的操作接口
*
...
...
@@ -100,20 +103,26 @@ class MongoDbModel {
* 'cmd'=>'$', // 修改器命令前缀
* )
*/
public
function
__construct
(
$config
=
array
(
'host'
=>
'192.168.1.201'
,
'port'
=>
27017
,
'db'
=>
'local'
,
'cmd'
=>
'$'
)){
$server
=
sprintf
(
"mongodb://%s:%s/%s"
,
$config
[
'host'
],
$config
[
'port'
],
$config
[
'db'
]);
// echo "connect\n";
public
function
__construct
(
$conf
=
array
(
'host'
=>
'192.168.1.201'
,
'port'
=>
27017
,
'db'
=>
'qmcs'
,
'cmd'
=>
'$'
)){
// $server = sprintf("mongodb://%s:%s/%s", $config['host'], $config['port'], $config['db']);
$config
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
$config
=
\Our\Common
::
getConfig
(
DbNameConst
::
mongoDBConnectName
);
$config
[
'cmd'
]
=
'$'
;
$server
=
Common
::
format
(
"mongodb://
{
0}:{1}@{2}:{3}/{4
}
"
,
$config
[
'username'
],
$config
[
'password'
],
$config
[
'hostname'
],
$config
[
'port'
],
$config
[
'database'
]);
try
{
$this
->
_mongo
=
new
\MongoClient
(
$server
,
array
(
'connect'
=>
true
));
// 立即连接
$options
[
'connect'
]
=
TRUE
;
if
(
isset
(
$config
[
'password'
])
&&
$config
[
'password'
])
{
$options
[
'password'
]
=
$config
[
'password'
];
}
$this
->
_mongo
=
new
\MongoClient
(
$server
,
$options
);
// 立即连接
}
catch
(
MongoConnectionException
$e
){
if
(
self
::
DEBUG
)
{
echo
$e
->
getMessage
();
}
return
false
;
}
$this
->
selectDB
(
$config
[
'db'
]);
$this
->
selectDB
(
$config
[
'database'
]);
// 命令前缀
if
(
!
isset
(
$config
[
'cmd'
])){
$this
->
_cmd
=
ini_get
(
'mongo.cmd'
);
...
...
application/modules/Client/controllers/Shopkeeper.php
View file @
f20d83a3
...
...
@@ -342,7 +342,7 @@ class ShopkeeperController extends \Our\Controller_AbstractClient {
ErrorModel
::
throwException
(
CodeConfigModel
::
paramsError
);
}
$orderService
=
\Business\Order\OrderServiceModel
::
getInstance
();
$res
=
$orderService
->
updateOrderAmount
(
$this
->
storeId
,
$orderId
,
$orderAmount
);
$res
=
$orderService
->
updateOrderAmount
(
$this
->
storeId
,
$orderId
,
$orderAmount
,
$this
->
memberName
);
if
(
$res
!==
false
){
$this
->
success
(
$res
,
\Our\DescribeConst
::
updateSuccess
);
}
...
...
application/modules/Client/controllers/User.php
View file @
f20d83a3
...
...
@@ -65,6 +65,7 @@ class UserController extends \Our\Controller_AbstractIndex {
$this
->
sess
[
'member_id'
]
=
(
int
)
$member
[
'member_id'
];
$this
->
sess
[
'store_id'
]
=
(
int
)
$seller
[
'storeId'
];
$this
->
sess
[
'seller_name'
]
=
$seller
[
'sellerName'
];
$this
->
sess
[
'member_name'
]
=
$member
[
'member_name'
];
$this
->
sess
[
'seller_id'
]
=
$seller
[
'sellerId'
];
$this
->
sess
[
NameConst
::
sessionKey
]
=
$this
->
key
;
$member
[
NameConst
::
sessionKey
]
=
$this
->
key
;
...
...
conf/application.ini
View file @
f20d83a3
...
...
@@ -271,6 +271,16 @@ resources.database.drawSource.params.password = "123456"
resources.database.drawSource.params.charset
=
"UTF8"
resources.database.drawSource.params.driver_options.1002
=
"SET NAMES utf8"
; mongodb
resources.database.mongo.params.driver
=
"scram"
resources.database.mongo.params.hostname
=
"192.168.1.201"
resources.database.mongo.params.port
=
27017
resources.database.mongo.params.database
=
"qmcs"
resources.database.mongo.params.username
=
"qmcs"
resources.database.mongo.params.password
=
"123456asdfgh"
resources.database.mongo.params.charset
=
"UTF8"
resources.database.mongo.params.driver_options.1002
=
"SET NAMES utf8"
password.key
=
'~!@#$`1234qwertasdfgzxcvb'
;
redis.database.params.host
=
"127.0.0.1"
...
...
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