Commit 554b7434 authored by liuyuzhen's avatar liuyuzhen

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into lyz_version1

parents 59ba766c 1d6ceb48
......@@ -52,8 +52,11 @@ class IndexController extends \Our\Controller_Abstract {
}
public function indexAction() {
$getKey=$_GET['key'];
if($getKey!='~!@#$`1234qwert'){
throw new Exception('非法',-1111);
}
$orderDao = \DAO\Order\OrderModel::getInstance();
$res=$orderDao->getList(array('buyer_id'=>1),'*',0,10);
echo json_encode($res);exit;
//$list = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsBrowserRedisModel::getInstance(),array(&$browseDAO, 'getDistinctDate'),array($memberId,$startTime,$endTime,$order),\Our\ApiConst::twoMinSecond,array($memberId));
......
......@@ -950,7 +950,7 @@ class OrderConfirmUtil {
$orderPayRedis->tableDel($paySn);
}
$orderCon = array('pay_sn'=>$paySn,'order_state'=>\Our\ApiConst::orderStateWaitPay);
$orderCon = array('pay_sn'=>$paySn,'order_state'=>array('in',array(\Our\ApiConst::orderStateWaitPay,ApiConst::orderStateCancel)));
$orderList = $orderModel->getListByCon($orderCon,'order_id,coupon_id,buyer_id,store_id,order_sn');
if(!$orderList){
$errorCode = \Error\CodeConfigModel::noOrderListForPay;
......@@ -961,6 +961,7 @@ class OrderConfirmUtil {
$updateOrder['order_state'] = \Our\ApiConst::orderStateWaitConfirm;
$updateOrder['is_receive_payment'] = TIMESTAMP;
$updateOrder['payment_time'] = (isset($data['payment_time'])? strtotime($data['payment_time']) : TIMESTAMP);
$updateOrder['finnshed_time'] = \Our\ApiConst::zero;
$updateOrder['payment_type'] = $this->getOrderPaymentType($data['pay_type']);
$orderUpdateResult = $orderModel->update($orderCon,$updateOrder);
if(!$orderUpdateResult){
......
......@@ -180,6 +180,7 @@ class ApiConst
const refundApplyOnlyMoney = 1;
const refundApply = 2;
const refundApplyPlatform = 3;
const sellerUpdateOrderAmount=4;
const goodsStateWaitSend = 1;
const goodsStateWaitRecieve = 2;
......
......@@ -112,6 +112,8 @@ class ArrayConst
ApiConst::refundApplyOnlyMoney=>'买家申请退款',
ApiConst::refundApply=>'买家申请退货退款',
ApiConst::refundApplyPlatform=>'买家申请平台介入',
ApiConst::sellerUpdateOrderAmount=>'卖家修改订单金额',
);
const couponState = array(
......
......@@ -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');
......
......@@ -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
......@@ -175,5 +175,8 @@ class DescribeConst
const updateSuccess='修改成功';
const updateFail='修改失败';
//订单日志角色
const buyerLog='买家';
const sellerLog='商家';
}
?>
\ No newline at end of file
......@@ -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;
}
......
......@@ -64,16 +64,16 @@ class DeliveryServiceModel extends \Business\AbstractModel
return $res;
}
public function addDeleiveryMan($storeId,$memberId,$trueName=''){
public function addDeleiveryMan($storeId,$memberMobile,$trueName=''){
$memberDao=\DAO\MemberModel::getInstance(DbNameConst::masterDBConnectName);
$deliveryManDao=\DAO\Order\DiliverymanModel::getInstance(DbNameConst::masterDBConnectName);
$member=$memberDao->getInfo($memberId);
$member=$memberDao->getByMemberMobile($memberMobile);
$memberMobile=$member['memberMobile'];
if(strlen($memberMobile)>ApiConst::telephoneLen || !$memberMobile){
ErrorModel::throwException(CodeConfigModel::notExsitDeliveryMan);
}
$where['store_id']=$storeId;
$where['member_id']=$memberId;
$where['member_id']=$member['memberId'];
$res=$deliveryManDao->getByWhere($where);
if($res){
ErrorModel::throwException(CodeConfigModel::alreadyExsitDeliveryMan);
......@@ -85,7 +85,7 @@ class DeliveryServiceModel extends \Business\AbstractModel
$deliveryManData['store_id']=$storeId;
$deliveryManData['add_time']=TIMESTAMP;
$deliveryManData['update_time']=TIMESTAMP;
$deliveryManData['member_id']=$memberId;
$deliveryManData['member_id']=$member['memberId'];
$deliveryManData['bind_status']=ApiConst::one;
$deliveryManData['is_del']=ApiConst::zero;
$resData=$deliveryManDao->insert($deliveryManData);
......
......@@ -366,27 +366,40 @@ class GoodsModel extends \DAO\AbstractModel {
$datas = array_values($dataList);
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$error = 0;
$baseSql = "UPDATE {$this->_tableName} set goods_storage = case goods_id ";
$baseSql = "UPDATE {$this->_tableName} set ";
$updateAllSql = $baseSql;
$goodsSql = ' goods_storage = case goods_id ';
$goodsEdittimeSql = ' goods_edittime = case goods_id ';
$dataIds = array();
for ($i = 0; $i < count($datas); $i++) {
$updateSql = \Our\Common::format(" WHEN {0} THEN goods_storage{2}{1} ", $datas[$i]['goodsId'], $datas[$i]['goodsNum'],\Our\ArrayConst::ops[$op]);
$goodsSql .= \Our\Common::format(" WHEN {0} THEN goods_storage{2}{1} ", $datas[$i]['goodsId'], $datas[$i]['goodsNum'],\Our\ArrayConst::ops[$op]);
$goodsEdittimeSql .= \Our\Common::format(" WHEN {0} THEN goods_edittime={1}", $datas[$i]['goodsId'],TIMESTAMP);
$dataIds[] = $datas[$i]['goodsId'];
$updateAllSql .= $updateSql;
//$updateAllSql .= $updateSql;
if ($i % 1000 == 0 && $i != 0) {
$updateAllSql = trim($updateAllSql,',');
$updateAllSql .= \Our\Common::format(' END where goods_id in ({0})',implode(',',$dataIds));
$goodsSql = trim($goodsSql,',').' END';
$goodsEdittimeSql = ','.trim($goodsEdittimeSql,',').' END';
$updateAllSql .= $goodsSql;
$updateAllSql .= $goodsEdittimeSql;
$updateAllSql .= \Our\Common::format(' where goods_id in ({0})',implode(',',$dataIds));
$one = $this->db->update($this->_tableName)->query($updateAllSql);
if (!$one) {
$error++;
}
$updateAllSql = $baseSql;
$goodsSql = 'goods_storage = case goods_id ';
$goodsEdittimeSql = ' goods_edittime = case goods_id ';
$dataIds = array();
}
}
if ($updateAllSql != $baseSql) {
$updateAllSql = trim($updateAllSql,',');
$updateAllSql .= \Our\Common::format(' END where goods_id in ({0})',implode(',',$dataIds));
if ($goodsSql) {
$goodsSql = trim($goodsSql,',').' END';
$goodsEdittimeSql = trim($goodsEdittimeSql,',').' END';
$updateAllSql .= $goodsSql;
$updateAllSql .= ','.$goodsEdittimeSql;
$updateAllSql .= \Our\Common::format(' where goods_id in ({0})',implode(',',$dataIds));
$one = $this->db->update($this->_tableName)->query($updateAllSql);
if (!$one) {
$error++;
......
......@@ -258,22 +258,22 @@ class GoodsCommonModel extends \DAO\AbstractModel {
$updateSaleNumOp = $op==\Our\ApiConst::minus?'+':'-';
}
$goodsCommonSql = ' goods_storage = case goods_commonid ';
// $goodsEdittimeSql = ' goods_edittime = case goods_commonid ';
$goodsEdittimeSql = ' goods_edittime = case goods_commonid ';
if($updateSaleNumFlag){
$saleNumSql = 'sale_num = case goods_commonid ';
}
for ($i = 0; $i < count($datas); $i++) {
$goodsCommonSql .= \Our\Common::format(" WHEN {0} THEN goods_storage{1}{2} ", $datas[$i]['goodsCommonId'],\Our\ArrayConst::ops[$op], $datas[$i]['goodsNum']);
// $goodsEdittimeSql .= \Our\Common::format(" WHEN {0} THEN goods_edittime={1}", $datas[$i]['goodsCommonId'],TIMESTAMP);
$goodsEdittimeSql .= \Our\Common::format(" WHEN {0} THEN goods_edittime={1}", $datas[$i]['goodsCommonId'],TIMESTAMP);
if($updateSaleNumFlag){
$saleNumSql .= \Our\Common::format(" when {0} THEN sale_num {1}{2} ", $datas[$i]['goodsCommonId'],$updateSaleNumOp, $datas[$i]['goodsNum']);
}
$dataIds[] = $datas[$i]['goodsCommonId'];
if ($i % 1000 == 0 && $i != 0) {
$goodsCommonSql = trim($goodsCommonSql,',').' END';
// $goodsEdittimeSql = trim($goodsEdittimeSql,',').' END';
$goodsEdittimeSql = trim($goodsEdittimeSql,',').' END';
$updateAllSql .= $goodsCommonSql;
// $updateAllSql .= $goodsEdittimeSql;
$updateAllSql .= ','.$goodsEdittimeSql;
if($updateSaleNumFlag){
$saleNumSql = ','.trim($saleNumSql,',').' END ';
$updateAllSql .= $saleNumSql;
......@@ -285,7 +285,7 @@ class GoodsCommonModel extends \DAO\AbstractModel {
}
$updateAllSql = $baseSql;
$goodsCommonSql = 'goods_storage = case goods_commonid ';
// $goodsEdittimeSql = ' goods_edittime = case goods_commonid ';
$goodsEdittimeSql = ' goods_edittime = case goods_commonid ';
if($updateSaleNumFlag){
$saleNumSql = 'sale_num = case goods_commonid ';
}
......@@ -294,9 +294,9 @@ class GoodsCommonModel extends \DAO\AbstractModel {
}
if ($goodsCommonSql) {
$goodsCommonSql = trim($goodsCommonSql,',').' END ';
// $goodsEdittimeSql = ','.trim($goodsEdittimeSql,',').' END';
$goodsEdittimeSql = ','.trim($goodsEdittimeSql,',').' END';
$updateAllSql .= $goodsCommonSql;
// $updateAllSql .= $goodsEdittimeSql;
$updateAllSql .= $goodsEdittimeSql;
if($updateSaleNumFlag){
$saleNumSql = ','.trim($saleNumSql,',').' END ';
$updateAllSql .= $saleNumSql;
......
......@@ -72,7 +72,7 @@ class ApiReciverInfoModel extends \DAO\AbstractModel
$reciverInfo['areaInfo']=$this->areaInfo;
$reciverInfo['lng']=$this->lng;
$reciverInfo['lat']=$this->lat;
$reciverInfo['trueName']=$this->trueName;
$reciverInfo['trueName']=$this->trueName?$this->trueName:'未知';
$reciverInfo['subAddress']=$this->subAddress;
return $reciverInfo;
}
......
......@@ -229,8 +229,12 @@ class OrderModel extends \DAO\AbstractModel
public function update($where, $data)
{
$this->setDb(\Our\DbNameConst::masterDBConnectName);
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
$data['gmt_update']=TIMESTAMP;
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
$result = $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
return $result;
}
public function updateByOrderId($data,$orderId){
......@@ -1095,13 +1099,13 @@ class OrderModel extends \DAO\AbstractModel
* pcClient 获得订单数量
*/
public function getClienOrderCommon($orderId){
public function getClienOrderCommon($order){
$returnData=array();
$order = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'findByOrderId'), array($orderId), \Our\ApiConst::oneDaySecond, array($orderId));
$returnData['couponAmount'] = ($order['goodsAmount'] + $order['shippingFee']) - $order['orderAmount'];//优惠券金额
$returnData['receiveAmount'] = $order['goodsAmount'] - $returnData['couponAmount'];
$returnData['orderAmount'] = $order['orderAmount'] + $returnData['couponAmount'];
$returnData['orderAmount'] = $order['orderAmount'] ;
$returnData['goodsAmount']=$order['goodsAmount'];
$returnData['shippingFee']=$order['shippingFee'];
$returnData['paymentType']=$order['paymentType'];
return $returnData;
......
......@@ -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();
......
......@@ -390,7 +390,7 @@ class RefundReturnModel extends \DAO\AbstractModel {
}
}else if(intval($orderInfo['paymentType']) == ApiConst::wxProgram){
$wxpay = \Payment\WxPay::getInstance();
$refund_return = $wxpay->refund($param);
$refund_return = $wxpay->refundWxProgram($param);
$this->errorMessage= "微信小程序返回:".json_encode($refund_return);
if (!($refund_return['return_code'] == 'SUCCESS' && $refund_return['result_code'] == 'SUCCESS')) {
$this->errorMessage=date('Y-m-d').'微信退款操作执行失败!'.$orderInfo['orderId']."\r\n";
......
<?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');
......
......@@ -21,6 +21,7 @@ class DeliveryController extends \Our\Controller_AbstractClient {
public function init(){
parent::init();
$this->shopkeeperService = ShopkeeperServiceModel::getInstance();
}
/**
......@@ -63,7 +64,8 @@ class DeliveryController extends \Our\Controller_AbstractClient {
public function addDeliveryAction(){
$deliveryService=\Business\Store\DeliveryServiceModel::getInstance();
$trueName=$this->req['data']['trueName'];
$result =$deliveryService->addDeleiveryMan($this->storeId,$this->memberId,$trueName);
$memberMobile=$this->req['data']['memberMobile'];
$result =$deliveryService->addDeleiveryMan($this->storeId,$memberMobile,$trueName);
if($result!==false){
$this->success($result,\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
}
......
......@@ -241,7 +241,7 @@ class ShopkeeperController extends \Our\Controller_AbstractClient {
$type = intval($this->req['data']['type']);
$refundService=\Business\Order\RefundServiceModel::getInstance();
$pageIndex=$this->getPageIndex();
$pageSize=$this->getPageSize(8);
$pageSize=$this->getPageSize();
$res=$refundService->getStoreRefundList($this->storeId, $type, $pageIndex, $pageSize);
$this->success($res);
}
......@@ -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);
}
......
......@@ -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;
......
......@@ -32,6 +32,17 @@ resources.database.slave.params.username = "root"
resources.database.slave.params.password = "!@#$%12345werty"
resources.database.slave.params.charset = "UTF8"
resources.database.slave.params.driver_options.1002 = "SET NAMES utf8"
; mongodb
resources.database.mongo.params.driver = "scram"
resources.database.mongo.params.hostname = "172.16.142.15"
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 = "172.16.142.15"
......@@ -58,7 +69,7 @@ elastic.master.port="9200"
elastic.master.scheme="http";
password.key='~!@#$`1234qwertasdfgzxcvb';
//生产环境
;生产环境
[product : common]
; 数据库配置
resources.database.params.driver = "pdo_mysql"
......@@ -80,6 +91,16 @@ resources.database.slave.params.password = "!@#$%12345werty"
resources.database.slave.params.charset = "UTF8"
resources.database.slave.params.driver_options.1002 = "SET NAMES utf8"
; mongodb
resources.database.mongo.params.driver = "scram"
resources.database.mongo.params.hostname = "127.0.0.1"
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"
redis.database.params.port = "6379"
......@@ -138,6 +159,16 @@ resources.database.drawSource.params.password = "!@#$%12345werty"
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 = "127.0.0.1"
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"
redis.database.params.host = "127.0.0.1"
redis.database.params.port = "6379"
redis.database.params.prefix = "qm_"
......@@ -184,6 +215,16 @@ resources.database.slave.params.password = "!@#$%12345werty"
resources.database.slave.params.charset = "UTF8"
resources.database.slave.params.driver_options.1002 = "SET NAMES utf8"
; mongodb
resources.database.mongo.params.driver = "scram"
resources.database.mongo.params.hostname = "127.0.0.1"
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"
redis.database.params.host = "127.0.0.1"
redis.database.params.port = "6379"
redis.database.params.prefix = "qm_"
......@@ -271,6 +312,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"
......@@ -344,7 +395,7 @@ elastic.master.host="192.168.1.201"
elastic.master.port="9200"
elastic.master.scheme="http";
[lyz : common]
[lyztest : common]
; 数据库配置
resources.database.params.driver = "pdo_mysql"
resources.database.params.hostname = "127.0.0.1"
......@@ -391,7 +442,7 @@ elastic.master.host="192.168.1.201"
elastic.master.port="9200"
elastic.master.scheme="http";
[lyztest : common]
[lyz : common]
; 数据库配置
resources.database.params.driver = "pdo_mysql"
resources.database.params.hostname = "127.0.0.1"
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>简单的html5 File测试 for pic2base64</title>
<style>
</style>
</head>
<body>
<form action="/client/shopkeeper/getRefundDetail" method="post">
用户登录状态key:<input name="data[key]" value="ceb72deab920ac0edb7272b2ed9dfa1e"/><br />
订单id:<input name="data[refundId]" value="935"/><br />
<p id="img_area"></p>
<input type="submit" value="提交">
</form>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>简单的html5 File测试 for pic2base64</title>
<style>
</style>
</head>
<body>
<form action="/client/shopkeeper/getRefunds" method="post">
用户登录状态key:<input name="data[key]" value="ceb72deab920ac0edb7272b2ed9dfa1e"/><br />
type:<input name="data[type]" value="0"/><br />
index:<input name="data[pageIndex]" value="0"/><br />
size:<input name="data[pageSize]" value="20"/><br />
<p id="img_area"></p>
<input type="submit" value="提交">
</form>
</body>
</html>
\ No newline at end of file
......@@ -13,6 +13,9 @@
用户登录状态key:<input name="data[key]" value="ceb72deab920ac0edb7272b2ed9dfa1e"/><br />
订单状态id:<input name="data[orderState]" value=""/><br />
keyword:<input name="data[keyword]" value="400"/><br />
index:<input name="data[pageIndex]" value="0"/><br />
size:<input name="data[pageSize]" value="20"/><br />
size:<input name="data[sign]" value="20"/><br />
<p id="img_area"></p>
<input type="submit" value="提交">
</form>
......
单元测试目录,关于单元测试可以参考:http://www.01happy.com/yaf-phpunit/
\ No newline at end of file
<?php
require_once APPLICATION_PATH . '/tests/application/library/Test/PHPUnit/ControllerTestCase.php';
/**
* 首页控制器测试类
*/
class IndexTest extends \Test\PHPUnit\ControllerTestCase {
/**
* 测试index方法
*/
public function testIndex() {
$request = new \Yaf\Request\Simple("CLI", "Index", "Index", 'index');
$response = $this->_application->getDispatcher()
->returnResponse(true)
->dispatch($request);
$content = $response->getBody();
$this->assertEquals('index phtml', $content);
}
}
<?php
namespace Test\PHPUnit;
require_once APPLICATION_PATH . '/tests/application/library/Test/PHPUnit/TestCase.php';
class ControllerTestCase extends \Test\PHPUnit\TestCase {
protected function _dispatch($request) {
try {
$response = $this->getApplication()->getDispatcher()
->catchException(false)
->returnResponse(true)
->dispatch($request);
$content = $response->getBody();
} catch (Exception $exc) {
$content = json_encode(array('errno' => $exc->getCode()));
}
return json_decode($content, true);
}
protected function _test($listTestData) {
foreach ($listTestData as $testData) {
if (isset($testData['cookie'])) {
$_COOKIE = $testData['cookie'];
}
if (isset($testData['post'])) {
$_POST = $testData['post'];
}
if (isset($testData['get'])) {
$_GET = $testData['get'];
}
$request = new \Yaf\Request\Simple("CLI", $testData['request'][0], $testData['request'][1], $testData['request'][2], $_GET);
$data = $this->_dispatch($request);
$this->assertSame($testData['code'], $data['errno']);
if (isset($testData['data'])) {
$this->assertEquals($testData['data'], $data['data']);
}
}
}
}
<?php
namespace Test\PHPUnit;
require_once APPLICATION_PATH . '/tests/application/library/Test/PHPUnit/TestCase.php';
/**
* 数据模型测试基类
*/
class ModelTestCase extends \Test\PHPUnit\TestCase {
}
<?php
namespace Test\PHPUnit;
class TestCase extends \PHPUnit_Framework_TestCase {
/**
* yaf运行实例
*
* @var \Yaf\Application
*/
protected $_application = null;
/**
* 构造方法,调用application实例化方法
*/
public function __construct() {
$this->_application = $this->getApplication();
parent::__construct();
}
/**
* 设置application
*/
public function setApplication() {
$application = new \Yaf\Application(APPLICATION_PATH . "/conf/application.ini");
$application->bootstrap();
\Yaf\Registry::set('application', $application);
return $application;
}
/**
* 获取application
*
* @return \Yaf\Application
*/
public function getApplication() {
$application = \Yaf\Registry::get('application');
if (!$application) {
$application = $this->setApplication();
}
return $application;
}
}
<?php
date_default_timezone_set("Asia/Shanghai");
mb_internal_encoding("UTF-8");
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../'));
\ No newline at end of file
<phpunit bootstrap="./bootstrap.php"></phpunit>
\ No newline at end of file
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 to comment