Browse Source

订单接口ok

shish 6 years ago
parent
commit
f126d41af7

+ 1 - 0
app/admin/config/params.php

@@ -1,3 +1,4 @@
 <?php
 return [
+	'pageSize'=>20,
 ];

+ 1 - 0
app/admin/controllers/BaseController.php

@@ -64,6 +64,7 @@ class BaseController extends PublicController
 		Yii::$app->params['merchantId'] = $merchantId;
 		Yii::$app->params['merchant'] = $merchant;
 		$this->adminId = $adminId;
+		$this->merchantId = $merchantId;
 		return parent::beforeAction($action);
 	}
 	

+ 15 - 408
app/admin/controllers/OrderController.php

@@ -19,426 +19,33 @@ use common\services\xhUserAlipayService;
 use common\components\page;
 use common\components\configDict;
 
-class OrderController extends BackendController
+class OrderController extends BaseController
 {
 	
-	public function actionComplete()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhOrder::find();
-		$merchantId = $this->merchantId;
-		$query->where(['merchantId' => $merchantId]);
-		$currentShopId = $this->admin['currentShopId'];
-		$query->andWhere(['shopId' => $currentShopId]);
-		if (isset($get['payStatus']) && $get['payStatus'] >= 0) {
-			$query->andWhere(['payStatus' => $get['payStatus']]);
-		}
-		$content = '';
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['bookMobile' => $content]);
-			} elseif (is_numeric($content)) {
-				$query->andWhere(['id' => $content]);
-			} else {
-				$query->andWhere(['like', 'bookName', $content]);
-			}
-		}
-		$query->orderBy('createTime desc');
-		$countQuery = clone $query;
-		$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
-		$models = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
-		$reachPeriodName = configDict::getConfig('reachPeriodName');
-		$payStatusName = configDict::getConfig('payStatusName');
-		return $this->render('complete', ['models' => $models, 'payStatusName' => $payStatusName, 'reachPeriodName' => $reachPeriodName, 'pages' => $pages, 'content' => $content, 'merchant' => $this->merchant]);
-	}
-	
-	public function actionUnInform()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhOrder::find();
-		$merchantId = $this->merchantId;
-		$query->where(['merchantId' => $merchantId]);
-		$currentShopId = $this->admin['currentShopId'];
-		$query->andWhere(['shopId' => $currentShopId]);
-		if (isset($get['payStatus']) && $get['payStatus'] >= 0) {
-			$query->andWhere(['payStatus' => $get['payStatus']]);
-		}
-		$content = '';
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['bookMobile' => $content]);
-			} elseif (is_numeric($content)) {
-				$query->andWhere(['id' => $content]);
-			} else {
-				$query->andWhere(['like', 'bookName', $content]);
-			}
-		}
-		$query->orderBy('createTime desc');
-		$countQuery = clone $query;
-		$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
-		$models = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
-		$reachPeriodName = configDict::getConfig('reachPeriodName');
-		$payStatusName = configDict::getConfig('payStatusName');
-		return $this->render('unInform', ['models' => $models, 'payStatusName' => $payStatusName, 'reachPeriodName' => $reachPeriodName, 'pages' => $pages, 'content' => $content, 'merchant' => $this->merchant]);
-	}
-	
-	public function actionUnSend()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhOrder::find();
-		$merchantId = $this->merchantId;
-		$query->where(['merchantId' => $merchantId]);
-		$currentShopId = $this->admin['currentShopId'];
-		$query->andWhere(['shopId' => $currentShopId]);
-		if (isset($get['payStatus']) && $get['payStatus'] >= 0) {
-			$query->andWhere(['payStatus' => $get['payStatus']]);
-		}
-		$content = '';
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['bookMobile' => $content]);
-			} elseif (is_numeric($content)) {
-				$query->andWhere(['id' => $content]);
-			} else {
-				$query->andWhere(['like', 'bookName', $content]);
-			}
-		}
-		$query->orderBy('createTime desc');
-		$countQuery = clone $query;
-		$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
-		$models = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
-		$reachPeriodName = configDict::getConfig('reachPeriodName');
-		$payStatusName = configDict::getConfig('payStatusName');
-		return $this->render('unSend', ['models' => $models, 'payStatusName' => $payStatusName, 'reachPeriodName' => $reachPeriodName, 'pages' => $pages, 'content' => $content, 'merchant' => $this->merchant]);
-	}
-	
-	public function actionUnPay()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhOrder::find();
-		$merchantId = $this->merchantId;
-		$query->where(['merchantId' => $merchantId]);
-		$currentShopId = $this->admin['currentShopId'];
-		$query->andWhere(['shopId' => $currentShopId]);
-		if (isset($get['payStatus']) && $get['payStatus'] >= 0) {
-			$query->andWhere(['payStatus' => $get['payStatus']]);
-		}
-		$content = '';
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['bookMobile' => $content]);
-			} elseif (is_numeric($content)) {
-				$query->andWhere(['id' => $content]);
-			} else {
-				$query->andWhere(['like', 'bookName', $content]);
-			}
-		}
-		$query->orderBy('createTime desc');
-		$countQuery = clone $query;
-		$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
-		$models = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
-		$reachPeriodName = configDict::getConfig('reachPeriodName');
-		$payStatusName = configDict::getConfig('payStatusName');
-		return $this->render('unPay', ['models' => $models, 'payStatusName' => $payStatusName, 'reachPeriodName' => $reachPeriodName, 'pages' => $pages, 'content' => $content, 'merchant' => $this->merchant]);
-	}
+	public $enableCsrfValidation = false;
 	
 	public function actionList()
 	{
 		$get = Yii::$app->request->get();
-		$query = xhOrder::find();
-		$merchantId = $this->merchantId;
-		$query->where(['merchantId' => $merchantId]);
-		$currentShopId = $this->admin['currentShopId'];
-		$query->andWhere(['shopId' => $currentShopId]);
-		if (isset($get['payStatus']) && $get['payStatus'] >= 0) {
-			$query->andWhere(['payStatus' => $get['payStatus']]);
-		}
-		$content = '';
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['bookMobile' => $content]);
-			} elseif (is_numeric($content)) {
-				$query->andWhere(['id' => $content]);
-			} else {
-				$query->andWhere(['like', 'bookName', $content]);
-			}
-		}
-		$query->orderBy('createTime desc');
-		$countQuery = clone $query;
-		$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
-		$models = $query->offset($pages->offset)->orderBy('addTime desc')->limit($pages->limit)->asArray()->all();
-		$reachPeriodName = configDict::getConfig('reachPeriodName');
-		$payStatusName = configDict::getConfig('payStatusName');
 		
-		$usageList = $this->usageList;
-		$categoryList = $this->categoryList;
-
-		return $this->render('list', ['models' => $models, 'payStatusName' => $payStatusName, 'reachPeriodName' => $reachPeriodName,
-			'pages' => $pages, 'content' => $content, 'merchant' => $this->merchant, 'usageList' => $usageList, 'categoryList' => $categoryList]);
-	}
-	
-	
-	/**
-	 * 网上订单明细
-	 */
-	public function actionDetail()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$order = xhOrderService::getById($id);
-		if (empty($order) || $order['merchantId'] != $this->merchantId) {
-			util::stop('访问出错,请联系网站管理员');
-		}
-		$goodsList = xhOrderGoods::getAllByCondition(['orderId' => $id]);
-		foreach ($goodsList as $key => $good) {
-			$goodsId = $good['goodsId'];
-			$goodsData = xhGoodsService::getById($goodsId);
-			if ($goodsData['goodsName'] != $good['title']) {
-				$subTitle = $good['title'];
-				$goodsList[$key]['title'] = $goodsData['goodsName'];
-				$goodsList[$key]['subTitle'] = $subTitle;
-			}
-		}
-		$reachPeriodName = configDict::getConfig('reachPeriodName');//送达时间点 上午 下午 晚上
-		$userId = 0;
-		$userInfo = [];
-		if (!empty($order['userId'])) {
-			$userId = $order['userId'];
-			$userInfo = xhUserService::getById($userId);
-		}
-		$payWayNameList = configDict::getConfig('payWayName');
-		$alipayWay = configDict::getConfig('payWay', 'alipay');
-		$alipayInfo = [];
-		if ($order['payWay'] == $alipayWay) {
-			$alipayId = $order['alipayId'];
-			$merchantId = $order['merchantId'];
-			$alipayInfo = xhUserAlipayService::getByIds($alipayId, $merchantId);
-		}
-		$sendStatusName = configDict::getConfig('sendStatusName');
-		return $this->render('detail', ['sendStatusName' => $sendStatusName, 'userInfo' => $userInfo, 'alipayWay' => $alipayWay, 'alipayInfo' => $alipayInfo, 'payWayNameList' => $payWayNameList, 'order' => $order, 'reachPeriodName' => $reachPeriodName, 'goodsList' => $goodsList, 'merchant' => $this->merchant]);
-	}
-	
-	public function actionUpdatePayStatus()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$order = xhOrderService::getById($id);
-		if (empty($order) || $order['merchantId'] != $this->merchantId) {
-			util::failInfo('非法访问');
-		}
+		//组建where
 		$status = isset($get['status']) ? $get['status'] : 0;
-		if ($order['payStatus'] == 0) {
-			//util::failInfo('客户还没有付款');
-			$userId = $order['userId'];
-			$user = xhUserService::getById($userId);
-			if (empty($user)) {
-				util::failInfo('客户信息出错-用户ID未保存');
-			}
-		}
-		xhOrderService::updateById($id, ['sendStatus' => $status]);
-		if ($status == 2) {//已经送达,通知订花人
-			$userId = $order['userId'];
-			$user = xhUserService::getById($userId);
-			$openId = $user['openId'];
-			$merchantId = $user['merchantId'];
-			if (xhUserService::isSubscribe($userId)) {
-				$allTM = xhTMessageService::getList($merchantId);
-				$shortTempId = 'OPENTM201205968';//订单送达通知
-				if (isset($allTM[$shortTempId])) {
-					$tempId =  $allTM[$shortTempId];
-					$data = ["touser" => $openId, "template_id" => $tempId,
-						"url" => Yii::$app->params['frontUrl'] . "/center/order-detail?id={$order['id']}&account={$this->merchantId}",
-						"data" => [
-							"first" => ["value" => '您的订单已送达', "color" => "#173177"],
-							"keyword1" => ["value" => (string)$order['id'], "color" => "#173177"],
-							"keyword2" => ["value" => $order['receiveUserName'], "color" => "#173177"],
-							"keyword3" => ["value" => '已送达', "color" => "#173177"],
-							"remark" => ["value" => '感谢您惠顾,祝你生活愉快!', "color" => "#173177"]]];
-					weixinUtil::sendTaskInform($data, $this->merchant);
-				}
+		$search = isset($get['search']) ? $get['search'] : '';
+		$where = ['merchantId' => $this->merchantId, 'status' => $status];
+		if (!empty($search)) {
+			if (stringUtil::isMobieNumber($search)) {
+				$where['receiveMobile'] = $search;
+			} else {
+				$where['id'] = $search;
 			}
 		}
-		echo Json::encode(['code' => 'A0001', 'msg' => '操作成功', 'data' => []]);
-	}
-	
-	/**
-	 * 订单修改
-	 * @param $id
-	 */
-	public function actionEditOrder($id)
-	{
-		$orderData = xhOrderService::getById($id);
-		if (empty($orderData)) {
-			util::failInfo('此订单不存在');
-		}
-		$orderData['reachTime'] = substr($orderData['reachTime'], 0, 10);
 		
-		util::successInfo('获取成功', 'A0001', $orderData);
-	}
-	
-	/**
-	 * 保存订单修改
-	 * @param $id
-	 */
-	public function actionSaveEditOrder()
-	{
-		$updateData = [];
-		$post = Yii::$app->request->post();
-		$orderData = xhOrderService::getById($post['id']);
-		if (empty($orderData)) {
-			util::failInfo('此订单不存在');
-		}
-		//已付款 或 微信中打开支付链接的,不可修改价格
-		$status = $orderData['actPrice'] != $post['consumeAmount'] ? true : false;
-		if ($orderData['modPriceStatus'] == 1 && $status) {
-			util::failInfo('订单已锁定,不能修改价格');
-		} else if ($orderData['payStatus'] == 1 && $status) {
-			util::failInfo('订单已付款,不能修改价格');
-		}
-		
-		xhOrderService::formatPost($updateData, $post);
-		$re = xhOrderService::updateById($post['id'], $updateData);
-		if ($re['status']) {
-			$msg = '保存成功';
-		} else {
-			$msg = '表单数据未变更';
-		}
-		util::successInfo($msg, 'A0001', $orderData);
-	}
-	
-	/**
-	 * 打印订单
-	 */
-	public function actionPrint()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$order = xhOrderService::getById($id);
-		if (empty($order) || $order['merchantId'] != $this->merchantId) {
-			echo '访问出错了,请联系网站管理员';
-			Yii::$app->end();
-		}
-		$goodsList = xhOrderGoods::getAllByCondition(['orderId' => $id]);
-		$list = [];
-		foreach ($goodsList as $val) {
-			$list[] = ['name' => $val['title'], 'num' => $val['num']];
-		}
-		return $this->renderPartial('print', ['order' => $order, 'merchant' => $this->merchant, 'goodsList' => $list]);
-	}
-	
-	/**
-	 * 更新打印状态
-	 */
-	public function actionUpdatePrintStatus()
-	{
-		$get = Yii::$app->request->get();
-		$status = isset($get['status']) ? $get['status'] : 1;
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$order = xhOrderService::getById($id);
-		if (empty($order) || $order['merchantId'] != $this->merchantId) {
-			echo Json::encode(['code' => 'A0002', 'data' => '', 'msg' => '出错了,请联系网站管理员']);
-			Yii::$app->end();
-		}
-		xhOrderService::updateById($id, ['printStatus' => $status]);
-		echo Json::encode(['code' => 'A0001', 'data' => '', 'msg' => 'success']);
-	}
-	
-	/**
-	 * 修改价格
-	 */
-	public function actionModifyPrice()
-	{
-		$get = Yii::$app->request->get();
-		$actPrice = isset($get['actPrice']) ? $get['actPrice'] : 10000;
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$order = xhOrderService::getById($id, $this->merchantId);
-		/*if($order['merchantId'] != $this->merchantId){
-			util::failInfo('非法访问');
-		}*/
-		if ($order['modPriceStatus'] == 1) {
-			util::failInfo('订单已锁定,不能修改价格');
-		}
-		$prePrice = $order['actPrice'];
-		xhOrderService::updateById($id, ['actPrice' => $actPrice]);
-		$userId = $order['userId'];
-		$user = xhUserService::getById($userId);
-		if (empty($user)) {
-			echo Json::encode(['code' => 'A0001', 'data' => '', 'msg' => "修改成功"]);
-			exit();
-		}
-		$openId = $user['openId'];
-		$merchantId = $user['merchantId'];
-		
-		//价格修改通知
-		$allTM = xhTMessageService::getList($merchantId);
-		$shortTempId = 'OPENTM401761342';
-		if (isset($allTM[$shortTempId])) {
-			$tempId =  $allTM[$shortTempId];
-			$data = [
-				"touser" => $openId,
-				"template_id" => $tempId,//模板id,从公众平台后台取得
-				"url" => $this->frontUrl . "/center/order-detail?id={$order['id']}&account={$this->merchantId}",
-				"data" => [
-					"first" => ["value" => '您好,你购买的商品价格已修改。', "color" => "#173177"],
-					"keyword1" => ["value" => (string)$order['id'], "color" => "#173177"],
-					"keyword2" => ["value" => $prePrice, "color" => "#173177"],
-					"keyword3" => ["value" => number_format($actPrice, 2), "color" => "#173177"],
-					"remark" => ["value" => '点此进行支付。', "color" => "#173177"]]];
-			weixinUtil::sendTaskInform($data, $this->merchant);
-		}
-		echo Json::encode(['code' => 'A0001', 'data' => '', 'msg' => "修改成功,已通知客户"]);
-	}
-	
-	/**
-	 * 修改商品的配送编号
-	 */
-	public function actionModifySendNum()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$num = isset($get['num']) ? $get['num'] : '';
-		$order = xhOrderService::getById($id);
-		if ($order['merchantId'] != $this->merchantId) {
-			util::failInfo('修改失败');
-		}
-		xhOrderService::updateById($id, ['sendNum' => $num]);
-		util::successInfo('修改成功');
-	}
-	
-	public function actionUserOrderList()
-	{
-		$get = Yii::$app->request->get();
-		$userId = isset($get['id']) ? $get['id'] : 0;
-		$query = xhOrder::find();
-		$query->where(['userId' => $userId]);
-		$countQuery = clone $query;
-		$count = $countQuery->count();
+		//传递page pageSize参数
 		$page = isset($get['page']) ? $get['page'] : 1;
-		$pageSize = 20;
-		$offset = ($page - 1) * $pageSize;
-		$models = $query->offset($offset)->orderBy('createTime desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		$reachPeriodName = configDict::getConfig('reachPeriodName');
-		$payStatusName = configDict::getConfig('payStatusName');
-		return $this->render('userOrderList', ['models' => $models, 'paging' => $paging, 'payStatusName' => $payStatusName, 'reachPeriodName' => $reachPeriodName]);
-	}
-	
-	//设置订单的分类和用途 shish 2019.8.18
-	public function actionSetStyle()
-	{
-		$this->errorExportJson();
-		$get = Yii::$app->request->get();
-		$ret = OrderService::setOrderStyle($get);
-		if ($ret == false) {
-			util::sendFail($this->error->getError());
-		}
-		util::sendSuccess();
+		Yii::$app->params['page'] = $page;
+		
+		$list = OrderService::getList('*', $where, 'addTime DESC');
+		util::success($list);
 	}
 	
 }

+ 1 - 0
app/mobile/config/params.php

@@ -1,3 +1,4 @@
 <?php
 return [
+	'pageSize'=>10,
 ];

+ 3 - 21
biz/base/classes/BaseClass.php

@@ -9,23 +9,15 @@ class BaseClass
 	
 	public static $baseFile;
 	
-	//没有分页
+	//查询全部 shish 2019.11.27
 	public static function getAllList($select, $where, $order = '', $with = '')
 	{
 		$model = Yii::createObject(['class' => static::$baseFile]);
 		$return = $model->getAllList($select, $where, $order, $with);
 		return $return;
 	}
-	
-	//分页查询返回数据 shish 2019.9.21
-	public static function getListData($select, $where, $page, $pageSize, $order = '', $with = '')
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$return = $model->getListData($select, $where, $page, $pageSize, $order, $with);
-		return $return;
-	}
-	
-	//分页查询返回json形式 shish 2019.9.21
+
+	//分页查询 shish 2019.9.21
 	public static function getList($select, $where, $page, $pageSize, $order = '', $with = '')
 	{
 		$model = Yii::createObject(['class' => static::$baseFile]);
@@ -33,16 +25,6 @@ class BaseClass
 		return $return;
 	}
 	
-	/**
-	 * 后台专用的获取列表 shish 2019.8.18
-	 */
-	public static function getBackendList($select, $where, $page, $pageSize, $order = '', $with = '')
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$return = $model->getBackendList($select, $where, $page, $pageSize, $order, $with);
-		return $return;
-	}
-	
 	public static function add($data, $returnObject = false)
 	{
 		$model = Yii::createObject(['class' => static::$baseFile]);

+ 4 - 47
biz/base/models/Base.php

@@ -98,7 +98,7 @@ class Base extends ActiveRecord
 		$fields = array_keys($attributes);
 		foreach ($data as $key => $val) {
 			if (in_array($key, $fields) == false) {
-				//删除表里不存在字段不进行保存
+				//删除表里不存在字段
 				unset($data[$key]);
 			}
 		}
@@ -120,15 +120,9 @@ class Base extends ActiveRecord
 	 */
 	public function updateByCondition($condition, $data)
 	{
-		if (empty($condition) || !is_array($condition)) {
-			throw new \Exception("condition error");
-		}
 		$where = array();
 		$variable = array();
 		foreach ($condition as $key => $val) {
-			if (is_array($val)) {
-				util::fail('更新操作暂不支持此查询方式:' . json_encode($val));
-			}
 			$where[] = $key . '=:' . $key;
 			$variable[':' . $key] = $val;
 		}
@@ -160,7 +154,7 @@ class Base extends ActiveRecord
 		}
 		return $returnObject == true ? $query->one() : $query->asArray()->one();
 	}
-
+	
 	/**
 	 * 支持查询条件包括
 	 * ['name'=>'john','id>'=>3,'id<'=>10,'id'=>['in',[10,11,12]],'age'=>['between',[20,30]],'name'=>['like','Jack']];
@@ -258,7 +252,7 @@ class Base extends ActiveRecord
 		return $this->conditionQuery($condition)->count();
 	}
 	
-	//分页查询返回json形式 shish 2019.9.21
+	//分页查询 shish 2019.9.21
 	public function getList($field, $where, $page, $pageSize, $order = '', $with = '')
 	{
 		$offset = ($page - 1) * $pageSize;
@@ -282,24 +276,7 @@ class Base extends ActiveRecord
 		return $data;
 	}
 	
-	//分页查询返回数据 shish 2019.9.21
-	public function getListData($field, $where, $page, $pageSize, $order = '', $with = '')
-	{
-		$offset = ($page - 1) * $pageSize;
-		$query = $this->conditionQuery($where)->select($field);
-		$cloneQuery = clone $query;
-		$count = $cloneQuery->count();
-		if (!empty($order)) {
-			$query->orderBy($order);
-		}
-		if (!empty($with)) {
-			$query->with($with);
-		}
-		$list = $query->offset($offset)->limit($pageSize)->asArray()->all();
-		return ['count' => $count, 'list' => $list];
-	}
-	
-	//没有分页
+	//查询全部 shish 2019.11.27
 	public function getAllList($field, $where, $order = '', $with = '')
 	{
 		$query = $this->conditionQuery($where)->select($field);
@@ -313,24 +290,4 @@ class Base extends ActiveRecord
 		return $list;
 	}
 	
-	//取后台的列表与分页 shish 2019.8.18
-	public function getBackendList($field, $where, $page, $pageSize, $order = '', $with = '')
-	{
-		$offset = ($page - 1) * $pageSize;
-		$query = $this->conditionQuery($where)->select($field);
-		
-		$cloneQuery = clone $query;
-		$count = $cloneQuery->count();
-		
-		if (!empty($order)) {
-			$query->orderBy($order);
-		}
-		if (!empty($with)) {
-			$query->with($with);
-		}
-		$pages = new Pagination(['totalCount' => $count, 'pageSize' => $pageSize]);
-		$list = $query->offset($offset)->limit($pageSize)->asArray()->all();
-		return ['list' => $list, 'pages' => $pages];
-	}
-	
 }

+ 5 - 26
biz/base/services/BaseService.php

@@ -9,28 +9,16 @@ class BaseService
 {
 	public static $baseFile;
 	public static $requireParams;
-	
-	//没有分页
+
+	//查询全部 shish 2019.11.27
 	public static function getAllList($select, $where, $order = '', $with = '')
 	{
 		$class = static::$baseFile;
 		$result = $class::getAllList($select, $where, $order, $with);
 		return $result;
 	}
-	
-	//分页查询返回数据 shish 2019.9.21
-	public static function getListData($select, $where, $page, $pageSize, $order = '', $with = '')
-	{
-		$class = static::$baseFile;
-		$result = $class::getListData($select, $where, $page, $pageSize, $order, $with);
-		$count = $result['count'];
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		$result['paging'] = $paging;
-		return $result;
-	}
-	
-	//分页查询返回json形式 shish 2019.9.21
+
+	//分页查询 shish 2019.9.21
 	public static function getList($select, $where, $order = '', $with = '', $pageSize = 0)
 	{
 		$class = static::$baseFile;
@@ -38,16 +26,7 @@ class BaseService
 		$pageSize = empty($pageSize) ? Yii::$app->params['pageSize'] : $pageSize;
 		return $class::getList($select, $where, $page, $pageSize, $order, $with);
 	}
-	
-	//后台专用的获取列表 shish 2019.8.18
-	public static function getBackendList($select, $where, $order = '', $with = '', $pageSize = 0)
-	{
-		$class = static::$baseFile;
-		$page = Yii::$app->params['page'];
-		$pageSize = empty($pageSize) ? Yii::$app->params['pageSize'] : $pageSize;
-		return $class::getBackendList($select, $where, $page, $pageSize, $order, $with);
-	}
-	
+
 	public static function add($data, $returnObject = false)
 	{
 		$class = static::$baseFile;

+ 0 - 156
biz/order/services/OrderService.php

@@ -17,161 +17,5 @@ class OrderService extends BaseService
 {
 	
 	public static $baseFile = '\biz\order\classes\OrderClass';
-	
-	//获取用户的全部订单和商品详情
-	public static function getAllListInfo($userId)
-	{
-		$orderList = self::getAllByCondition(['userId' => $userId], 'addTime desc', '*');
-		if (!empty($orderList)) {
-			$orderIds = array_column($orderList, 'id');
-			$goodsInfo = OrderGoodsService::getGoodsListByOrderIds($orderIds);
-			foreach ($orderList as $key => $order) {
-				$id = $order['id'];
-				$orderList[$key]['shortId'] = substr($id, -12);
-				if (isset($goodsInfo[$id])) {
-					$currentGoodsList = $goodsInfo[$id];
-					foreach ($currentGoodsList as $cKey => $cVal) {
-						
-						//取出较小的图片页 shish 2019.8.3
-						$url = $cVal['cover'];
-						$pos = strrpos($url, '.');
-						$pre = substr($url, 0, $pos);
-						$ext = substr($url, ($pos + 1));
-						
-						$middleCover = $pre . '_200.' . $ext;
-						$currentGoodsList[$cKey]['middleCover'] = $middleCover;
-					}
-					$orderList[$key]['goodsList'] = $currentGoodsList;
-				}
-				$statusName = '已取消';
-				if ($order['payStatus'] == 0) {
-					$statusName = '待付款';
-				}
-				if ($order['payStatus'] == 1) {
-					$statusName = '已付款';
-				}
-				$orderList[$key]['statusName'] = $statusName;
-				
-			}
-		}
-		return $orderList;
-	}
-	
-	//取一个订单和商品详情
-	public static function getDetail($id)
-	{
-		$info = self::getByCondition(['id' => $id]);
-		if (!empty($info)) {
-			$goodsList = OrderGoodsService::getGoodsListById($id);
-			$info['goodsList'] = $goodsList;
-			$info['reachTimeInfo'] = date("Y-m-d", strtotime($info['reachTime']));
-			$reachPeriod = $info['reachPeriod'];
-			$reachConfig = Order::$reachPeriod;
-			$info['reachPeriodInfo'] = isset($reachConfig[$reachPeriod]) ? $reachConfig[$reachPeriod] : '';
-			
-		}
-		return $info;
-	}
-	
-	//取订单详情 shish 2019.8.18
-	public static function getOrderDetail($id)
-	{
-		$merchantId = Yii::$app->params['merchantId'];
-		$order = self::getByCondition(['id' => $id], true);
-		if (empty($order)) {
-			util::fail('订单无效');
-		}
-		if ($order->merchantId != $merchantId) {
-			util::fail('不是你的订单');
-		}
-		return $order;
-	}
-	
-	//设置分类和用途 shish 2019.8.18
-	//$hasCategoryUsage true表示已经有分类和用途,只要发卷。快速付款可能选了分类和用途
-	public static function setOrderStyle($data, $hasCategoryUsage = false)
-	{
-		$valid = [
-			['categoryId', 'required|int|min:1', '类型没选择'],
-			['usageId', 'required|int|min:1', '用途没有选择'],
-			['id', 'required|numeric|min:2', '请确认订单号'],
-		];
-		$connection = Yii::$app->db;//事务处理
-		$transaction = $connection->beginTransaction();
-		try {
-			validate::check($valid, $data);
-			$id = $data['id'];
-			$order = self::getOrderDetail($id);
-			if ($order->payStatus != 1) {
-				util::fail('订单还未付款');
-			}
-			if ($hasCategoryUsage == false) {
-				if (!empty($order->categoryId) && !empty($order->usageId)) {
-					util::fail('你已经设置了分类和用途');
-				}
-				$categoryId = $data['categoryId'];
-				$usageId = $data['usageId'];
-				$order->categoryId = $categoryId;
-				$order->usageId = $usageId;
-				$order->save();
-			}
-			/**设置流水的分类和用途并分配资金**/
-			$setData = ['merchantId' => $order->merchantId, 'capitalId' => $order->capitalId, 'time' => $order->payTime,
-				'usageId' => $order->usageId, 'categoryId' => $order->categoryId, 'amount' => $order->actPrice, 'payWay' => $order->payWay];
-			MerchantCapitalService::setCategoryUsage($setData);
-			/**给予老带新优惠卷发放权**/
-			CouponRightService::grantRight($order->attributes);
-			$transaction->commit();
-		} catch (Exception $e) {
-			$transaction->rollBack();
-			util::fail('没有设置成功');
-		}
-		return true;
-	}
-	
-	//取最近若干订单订单 shish 2019.8.19
-	public static function getLatestOrder()
-	{
-		$merchantId = Yii::$app->params['merchantId'];
-		$order = self::getListData('*', ['merchantId' => $merchantId], 1, 10, 'addTime desc');
-		if (isset($order['list']) && !empty($order['list'])) {
-			$ids = array_column($order['list'], 'userId');
-			$ids = array_unique(array_filter($ids));
-			$userInfo = UserService::getByIds($ids, null, 'id');
-			$list = $order['list'];
-			foreach ($list as $key => $val) {
-				$userId = $val['userId'];
-				$list[$key]['userInfo'] = isset($userInfo[$userId]) ? $userInfo[$userId] : [];
-			}
-			return $list;
-		}
-		return [];
-	}
-	
-	//返回随机优惠金额 shish 2019.9.12
-	public static function getRandDiscount($amount)
-	{
-		if ($amount <= 0) {
-			return 0;
-		}
-		if ($amount >= 20000) {
-			$rand = rand(90, 100);
-		} elseif ($amount > 1000) {
-			$rand = rand(10, 30);
-		} elseif ($amount > 500) {
-			$rand = rand(10, 20);
-		} elseif ($amount > 260) {
-			$rand = rand(10, 15);
-		} elseif ($amount > 100) {
-			$rand = rand(5, 9);
-		} elseif ($amount > 50) {
-			$rand = rand(1, 3);
-		} elseif ($amount > 10) {
-			$rand = 1;
-		} else {
-			$rand = 0;
-		}
-		return $rand / 10;
-	}
 
 }

+ 2 - 2
common/components/util.php

@@ -182,9 +182,9 @@ class util
 	public static function encode($data)
 	{
 		echo Json::encode($data);
-		Yii::$app->end();
+		exit();
 	}
-	
+
 	/**
 	 * 组合需要的格式,输出json数据并结束运行
 	 * code A0001 正确 其它如:A0002表示错误