Commit c35a04e3 authored by wwccw0591's avatar wwccw0591

pc

parent a8b38774
<?php
namespace Our;
use Business\User\MemberServiceModel;
use Error\CodeConfigModel;
use Error\ErrorModel;
/**
* api模块控制器抽象类
*
* @package Our
* @author iceup <sjlinyu@qq.com>
*/
abstract class Controller_AbstractClient extends \Our\Controller_Abstract {
public $config;
public $redis;
public $key;
public $req;
public $memberId;
/**
* api控制器直接输出json格式数据,不需要渲染视图
*/
public function init() {
$this->req=$this->getRequest()->getPost();
$this->checkEncrypt();
if(empty($this->req['data']['key'])){
ErrorModel::throwException(CodeConfigModel::illegalAccess);
}
session_id($this->req['data']['key']);
// ini_set('session.gc_maxlifetime', ApiConst::tenDaySecond);
$sess=\Yaf\Session::getInstance();
$sess->start();
$this->memberId=$sess->get('member_id');
$this->storeId=$sess->get('store_id');
if(empty($this->memberId)){
ErrorModel::throwException(CodeConfigModel::noLogin);
}
if(isset($sess['other_login']) && $sess['other_login']==ApiConst::one){
$memberService=MemberServiceModel::getInstance();
$memberService->clearKey($this->req['data']['key']);
ErrorModel::throwException(CodeConfigModel::otherDriverLogin);
}
\Yaf\Dispatcher::getInstance()->disableView();
}
public function getAuthKey(){
$this->key=Common::bulidToken();
$this->redis->hset($this->key,NameConst::sessionKey,$this->key,ApiConst::tenMin);
}
public function loginCheck(){
}
}
<?php <?php
use Error\ErrorModel; use Error\ErrorModel;
use Error\CodeConfigModel; use Error\CodeConfigModel;
use Our\NameConst; use Our\NameConst;
use Our\Common; use Our\Common;
use Business\User\MemberServiceModel; use Business\User\MemberServiceModel;
use Business\Store\ShopkeeperServiceModel; use Business\Store\ShopkeeperServiceModel;
/** /**
* 我是店主 * 我是店主
* *
* @date 2018-5-10 * @date 2018-5-10
* @author csw <993768343@qq.com> * @author csw <993768343@qq.com>
*/ */
class ShopkeeperController extends \Our\Controller_AbstractApi { class ShopkeeperController extends \Our\Controller_AbstractClient {
public $memberService; public $memberService;
public $shopkeeperService; public $shopkeeperService;
public function init(){ public function init(){
parent::init(); parent::init();
$this->memberService = MemberServiceModel::getInstance(); $this->memberService = MemberServiceModel::getInstance();
$this->shopkeeperService = ShopkeeperServiceModel::getInstance(); $this->shopkeeperService = ShopkeeperServiceModel::getInstance();
$this->shopkeeperService->clientType=NameConst::pcClient; $this->shopkeeperService->clientType=NameConst::pcClient;
} }
/** /**
* 店主首页 * 店主首页
*/ */
public function indexAction() { public function indexAction() {
$result = $this->shopkeeperService->getShopkeeper($this->memberId); $result = $this->shopkeeperService->getShopkeeper($this->memberId);
$this->success($result); $this->success($result);
} }
/** /**
* 获得店铺统计数据ccw:18305954587 * 获得店铺统计数据ccw:18305954587
*/ */
public function statisticsAction(){ public function statisticsAction(){
$result = $this->shopkeeperService->getStatistics($this->memberId); $result = $this->shopkeeperService->getStatistics($this->memberId);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 分类店铺销量排行(及列表第一页) * 分类店铺销量排行(及列表第一页)
*/ */
public function myStoreClassRankAction() { public function myStoreClassRankAction() {
$gcId = isset($this->req['data']['gcId'])?$this->req['data']['gcId']:\Our\ApiConst::zero; $gcId = isset($this->req['data']['gcId'])?$this->req['data']['gcId']:\Our\ApiConst::zero;
if(empty($gcId)){ if(empty($gcId)){
ErrorModel::throwException(CodeConfigModel::emptyGcId); ErrorModel::throwException(CodeConfigModel::emptyGcId);
} }
$pageIndex = $this->getPageIndex(); $pageIndex = $this->getPageIndex();
$pageSize=$this->getPageSize(\Our\ApiConst::salePageSize); $pageSize=$this->getPageSize(\Our\ApiConst::salePageSize);
$result = $this->shopkeeperService->getMyStoreClassRank($this->memberId,$gcId,$pageIndex,$pageSize); $result = $this->shopkeeperService->getMyStoreClassRank($this->memberId,$gcId,$pageIndex,$pageSize);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 分类店铺销量排行分页 * 分类店铺销量排行分页
*/ */
public function storeClassRankAction() { public function storeClassRankAction() {
$gcId = $this->req['data']['gcId']; $gcId = $this->req['data']['gcId'];
$pageIndex = (int)$this->req['data']['pageIndex']; $pageIndex = (int)$this->req['data']['pageIndex'];
$pageSize=isset($this->req['data']['pageSize'])?$this->req['data']['pageSize']:10; $pageSize=isset($this->req['data']['pageSize'])?$this->req['data']['pageSize']:10;
if(empty($gcId)){ if(empty($gcId)){
ErrorModel::throwException(CodeConfigModel::illegalAccess); ErrorModel::throwException(CodeConfigModel::illegalAccess);
} }
$result = $this->shopkeeperService->getStoreClassRankList($gcId,$pageIndex,$pageSize); $result = $this->shopkeeperService->getStoreClassRankList($gcId,$pageIndex,$pageSize);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 店铺关注会员统计(及列表第一页) * 店铺关注会员统计(及列表第一页)
*/ */
public function storeMemberStatsAction(){ public function storeMemberStatsAction(){
$pageIndex = $this->getPageIndex(); $pageIndex = $this->getPageIndex();
$pageSize=$this->getPageSize(\Our\ApiConst::pageSizeTen); $pageSize=$this->getPageSize(\Our\ApiConst::pageSizeTen);
$keyword = (isset($this->req['data']['keyword'])&&!empty($this->req['data']['keyword']))?$this->req['data']['keyword']:''; $keyword = (isset($this->req['data']['keyword'])&&!empty($this->req['data']['keyword']))?$this->req['data']['keyword']:'';
$sort = isset($this->req['data']['sort'])?$this->req['data']['sort']:\Our\ApiConst::one; $sort = isset($this->req['data']['sort'])?$this->req['data']['sort']:\Our\ApiConst::one;
$result = $this->shopkeeperService->getStoreMemberStats($this->memberId,$pageIndex,$pageSize,$sort,$keyword); $result = $this->shopkeeperService->getStoreMemberStats($this->memberId,$pageIndex,$pageSize,$sort,$keyword);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 店铺关注会员统计列表 * 店铺关注会员统计列表
*/ */
public function membersStatsAction(){ public function membersStatsAction(){
$pageIndex = (int)$this->getPageIndex(); $pageIndex = (int)$this->getPageIndex();
$pageSize=$this->getPageSize(\Our\ApiConst::pageSizeTen); $pageSize=$this->getPageSize(\Our\ApiConst::pageSizeTen);
$keyword = trim($this->req['data']['keyword']); $keyword = trim($this->req['data']['keyword']);
$sort = isset($this->req['data']['sort'])?$this->req['data']['sort']:\Our\ApiConst::one; $sort = isset($this->req['data']['sort'])?$this->req['data']['sort']:\Our\ApiConst::one;
$result = $this->shopkeeperService->getMemberStats($this->memberId,$pageIndex,$pageSize,$sort,$keyword); $result = $this->shopkeeperService->getMemberStats($this->memberId,$pageIndex,$pageSize,$sort,$keyword);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 接单 * 接单
*/ */
public function orderReceiveAction(){ public function orderReceiveAction(){
$orderId = $this->req['data']['orderId']; $orderId = $this->req['data']['orderId'];
$result = $this->shopkeeperService->orderReceive($this->memberId, $orderId); $result = $this->shopkeeperService->orderReceive($this->memberId, $orderId);
if ($result) { if ($result) {
$this->success(array(), \Our\DescribeConst::successMessage, \Our\DescribeConst::successMessage); $this->success(array(), \Our\DescribeConst::successMessage, \Our\DescribeConst::successMessage);
}else{ }else{
ErrorModel::throwException(CodeConfigModel::receiveError); ErrorModel::throwException(CodeConfigModel::receiveError);
} }
} }
/** /**
* 店铺订单列表(第一页数据) * 店铺订单列表(第一页数据)
*/ */
public function storeOrdersAction(){ public function storeOrdersAction(){
$pageIndex = (int)$this->req['data']['pageIndex']; $pageIndex = (int)$this->req['data']['pageIndex'];
$pageIndex = $pageIndex?$pageIndex:0; $pageIndex = $pageIndex?$pageIndex:0;
$pageSize=isset($this->req['data']['pageSize'])?$this->req['data']['pageSize']:10; $pageSize=isset($this->req['data']['pageSize'])?$this->req['data']['pageSize']:10;
$orderState = isset($this->req['data']['orderState'])?$this->req['data']['orderState']:''; $orderState = isset($this->req['data']['orderState'])?$this->req['data']['orderState']:'';
$keyword = isset($this->req['data']['keyword'])?$this->req['data']['keyword']:''; $keyword = isset($this->req['data']['keyword'])?$this->req['data']['keyword']:'';
$result = $this->shopkeeperService->getStoreOrders($this->memberId,$pageIndex,$pageSize,$orderState,$keyword); $result = $this->shopkeeperService->getStoreOrders($this->memberId,$pageIndex,$pageSize,$orderState,$keyword);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 店铺订单列表(分页) * 店铺订单列表(分页)
*/ */
public function ordersAction(){ public function ordersAction(){
$pageIndex = $this->getPageIndex(); $pageIndex = $this->getPageIndex();
$pageSize=$this->getPageSize(); $pageSize=$this->getPageSize();
$orderState = isset($this->req['data']['orderState'])?$this->req['data']['orderState']:''; $orderState = isset($this->req['data']['orderState'])?$this->req['data']['orderState']:'';
$keyword = isset($this->req['data']['keyword'])?$this->req['data']['keyword']:''; $keyword = isset($this->req['data']['keyword'])?$this->req['data']['keyword']:'';
$result = $this->shopkeeperService->getOrders($this->memberId,$pageIndex,$pageSize,$orderState,$keyword); $result = $this->shopkeeperService->getOrders($this->memberId,$pageIndex,$pageSize,$orderState,$keyword);
$this->success($result); $this->success($result);
// if($result){ // if($result){
// $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); // $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
// } // }
} }
/** /**
* 获得配送员列表 * 获得配送员列表
*/ */
public function getDeliveriersAction(){ public function getDeliveriersAction(){
$result = $this->shopkeeperService->getDiliveryManByStoreId($this->memberId); $result = $this->shopkeeperService->getDiliveryManByStoreId($this->memberId);
if($result!==false){ if($result!==false){
$this->success($result,\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success($result,\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
ErrorModel::throwException(CodeConfigModel::commonError); ErrorModel::throwException(CodeConfigModel::commonError);
} }
/** /**
* 订单详情 * 订单详情
*/ */
public function orderDetailAction(){ public function orderDetailAction(){
$orderId = $this->req['data']['orderId']; $orderId = $this->req['data']['orderId'];
if(empty($orderId)){ if(empty($orderId)){
ErrorModel::throwException(CodeConfigModel::emptyOrderIdForPay); ErrorModel::throwException(CodeConfigModel::emptyOrderIdForPay);
} }
$result = $this->shopkeeperService->getOrderDetail($this->memberId,$orderId); $result = $this->shopkeeperService->getOrderDetail($this->memberId,$orderId);
$this->success($result); $this->success($result);
if($result){ if($result){
$this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage,\Our\DescribeConst::successMessage);
} }
} }
/** /**
* 获得售后列表 * 获得售后列表
*/ */
public function getRefunds(){ public function getRefunds(){
$refundService=\Business\Order\RefundServiceModel::getInstance(); $refundService=\Business\Order\RefundServiceModel::getInstance();
$pageIndex=$this->getPageIndex(); $pageIndex=$this->getPageIndex();
$pageSize=$this->getPageSize(); $pageSize=$this->getPageSize();
$res=$refundService->getList($this->memberId,$pageIndex,$pageSize); $res=$refundService->getList($this->memberId,$pageIndex,$pageSize);
$this->success($res); $this->success($res);
} }
/** /**
* 获得订单数量 * 获得订单数量
*/ */
public function countAction(){ public function countAction(){
$result = $this->shopkeeperService->getCount($this->memberId); $result = $this->shopkeeperService->getCount($this->memberId);
if(!empty($result)){ if(!empty($result)){
$this->success($result); $this->success($result);
} }
ErrorModel::throwException(CodeConfigModel::commonError); ErrorModel::throwException(CodeConfigModel::commonError);
} }
public function receivePaymentAction(){ public function receivePaymentAction(){
$shopkeeperService=\Business\Store\ShopkeeperServiceModel::getInstance(); $shopkeeperService=\Business\Store\ShopkeeperServiceModel::getInstance();
$res=$shopkeeperService->confirmReceivePayment($this->memberId,$this->req['data']['orderId']); $res=$shopkeeperService->confirmReceivePayment($this->memberId,$this->req['data']['orderId']);
if($res){ if($res){
$this->success(array(),\Our\DescribeConst::successMessage); $this->success(array(),\Our\DescribeConst::successMessage);
}else{ }else{
ErrorModel::throwException(CodeConfigModel::confirmReceiveError); ErrorModel::throwException(CodeConfigModel::confirmReceiveError);
} }
} }
/** /**
* 查询配送员 * 查询配送员
* *
*/ */
public function searchDeliveryAction(){ public function searchDeliveryAction(){
$shopkeeperService=\Business\Store\ShopkeeperServiceModel::getInstance(); $shopkeeperService=\Business\Store\ShopkeeperServiceModel::getInstance();
$res=$shopkeeperService->getDiliveryMan($this->req['data']['mobile']); $res=$shopkeeperService->getDiliveryMan($this->req['data']['mobile']);
$res=$res?$res:new \stdClass(); $res=$res?$res:new \stdClass();
$this->success($res,\Our\DescribeConst::successMessage); $this->success($res,\Our\DescribeConst::successMessage);
} }
} }
...@@ -63,6 +63,7 @@ class UserController extends \Our\Controller_AbstractIndex { ...@@ -63,6 +63,7 @@ class UserController extends \Our\Controller_AbstractIndex {
$this->key=Common::bulidToken($mobile,$password); $this->key=Common::bulidToken($mobile,$password);
session_id($this->key); session_id($this->key);
$this->sess['member_id']=(int)$member['member_id']; $this->sess['member_id']=(int)$member['member_id'];
$this->sess['store_id']=(int)$seller['storeId'];
$this->sess[NameConst::sessionKey]=$this->key; $this->sess[NameConst::sessionKey]=$this->key;
$member[NameConst::sessionKey]=$this->key; $member[NameConst::sessionKey]=$this->key;
$member['store_id']=$seller['storeId']; $member['store_id']=$seller['storeId'];
......
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