-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tony
committed
Nov 21, 2020
1 parent
add5e14
commit 10a2641
Showing
50 changed files
with
1,995 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM yiisoftware/yii2-php:7.2-apache | ||
|
||
# Change document root for Apache | ||
RUN sed -i -e 's|/app/web|/app/appwap/web|g' /etc/apache2/sites-available/000-default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace appwap\assets; | ||
|
||
use yii\web\AssetBundle; | ||
|
||
/** | ||
* Main appwap application asset bundle. | ||
*/ | ||
class AppAsset extends AssetBundle | ||
{ | ||
public $basePath = '@webroot'; | ||
public $baseUrl = '@web'; | ||
public $css = [ | ||
'css/site.css', | ||
]; | ||
public $js = [ | ||
]; | ||
public $depends = [ | ||
'yii\web\YiiAsset', | ||
'yii\bootstrap\BootstrapAsset', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace: appwap\tests | ||
actor_suffix: Tester | ||
paths: | ||
tests: tests | ||
output: tests/_output | ||
data: tests/_data | ||
support: tests/_support | ||
bootstrap: _bootstrap.php | ||
settings: | ||
colors: true | ||
memory_limit: 1024M | ||
modules: | ||
config: | ||
Yii2: | ||
configFile: 'config/codeception-local.php' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
codeception-local.php | ||
main-local.php | ||
params-local.php | ||
test-local.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
$params = array_merge( | ||
require __DIR__ . '/../../common/config/params.php', | ||
require __DIR__ . '/../../common/config/params-local.php', | ||
require __DIR__ . '/params.php', | ||
require __DIR__ . '/params-local.php' | ||
); | ||
|
||
return [ | ||
'id' => 'app-appwap', | ||
'basePath' => dirname(__DIR__), | ||
'controllerNamespace' => 'appwap\controllers', | ||
'bootstrap' => ['log'], | ||
'modules' => [], | ||
'components' => [ | ||
'request' => [ | ||
'csrfParam' => '_csrf-appwap', | ||
], | ||
'user' => [ | ||
'identityClass' => 'common\models\User', | ||
'enableSession' => false, | ||
'enableAutoLogin' => false, | ||
// 'identityCookie' => ['name' => '_identity-appwap', 'httpOnly' => true], | ||
], | ||
// 'session' => [ | ||
// // this is the name of the session cookie used for login on the appwap | ||
// 'name' => 'advanced-appwap', | ||
// ], | ||
'log' => [ | ||
'traceLevel' => YII_DEBUG ? 3 : 0, | ||
'targets' => [ | ||
[ | ||
'class' => 'yii\log\FileTarget', | ||
'levels' => ['error', 'warning'], | ||
], | ||
], | ||
], | ||
'errorHandler' => [ | ||
'errorAction' => 'site/error', | ||
], | ||
'urlManager' => [ | ||
'enablePrettyUrl' => true, | ||
'showScriptName' => false, | ||
'rules' => [ | ||
], | ||
], | ||
], | ||
'params' => $params, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
return [ | ||
'adminEmail' => '[email protected]', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
return [ | ||
'id' => 'app-appwap-tests', | ||
'components' => [ | ||
'assetManager' => [ | ||
'basePath' => __DIR__ . '/../web/assets', | ||
], | ||
'urlManager' => [ | ||
'showScriptName' => true, | ||
], | ||
'request' => [ | ||
'cookieValidationKey' => 'test', | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
namespace appwap\controllers; | ||
|
||
use appwap\helpers\AccessControl; | ||
use common\consts\YesNo; | ||
use common\models\Fuser; | ||
use Yii; | ||
use yii\web\Controller; | ||
|
||
/** | ||
* Base controller | ||
*/ | ||
class BaseController extends Controller | ||
{ | ||
public function behaviors() | ||
{ | ||
return [ | ||
// 允许vue前端的域名或ip跨域请求, 在http头加入如:Access-Control-Allow-Origin http://localhost:8081 | ||
'corsFilter' => [ | ||
'class' => \yii\filters\Cors::class, | ||
'cors' => [ | ||
'Origin' => Yii::$app->params['cors_origin'], | ||
'Access-Control-Request-Method' => ['GET', 'POST'], | ||
'Access-Control-Request-Headers' => ['*'], | ||
], | ||
], | ||
// 访问控制 | ||
// 'access' => [ | ||
// 'class' => AccessControl::class, | ||
// 'allowActions' => ['site/login', 'site/error',] //不需要控制的action | ||
// ] | ||
]; | ||
} | ||
|
||
/** | ||
* 获取当前商城用户id, Fuser.id | ||
* @return string | ||
*/ | ||
protected function getFuserId() | ||
{ | ||
return Yii::$app->user->id; | ||
} | ||
|
||
/** | ||
* 获取当前商城用户id, Fuser | ||
* @return string | ||
*/ | ||
protected function getFuser() | ||
{ | ||
$fuser = Fuser::findOne($this->getFuserId()); | ||
if ($fuser && $fuser->status == YesNo::YES) { | ||
return $fuser; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
namespace appwap\controllers; | ||
|
||
use appwap\models\searchs\FuserSearch; | ||
use common\helpers\DateHelper; | ||
use common\helpers\ResponseHelper; | ||
use common\models\Fuser; | ||
use Yii; | ||
|
||
class FuserController extends BaseController | ||
{ | ||
public function actionIndex() | ||
{ | ||
$searchModel = new FuserSearch(); | ||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
$fusers = $dataProvider->getModels(); | ||
$items = []; | ||
/* @var Fuser $fusers */ | ||
foreach ($fusers as $fuser) { | ||
$item = $fuser->toArray(['username', 'nickname', 'mobile', 'email', 'status']); | ||
$item['created_at'] = DateHelper::format($fuser->created_at); | ||
$item['updated_at'] = DateHelper::format($fuser->updated_at); | ||
$items[] = $item; | ||
} | ||
$data = [ | ||
'items' => $items, | ||
'total' => strval($dataProvider->getTotalCount()) | ||
]; | ||
return ResponseHelper::success($data); | ||
} | ||
|
||
public function actionView($id) | ||
{ | ||
$model = Fuser::findOne($id); | ||
if (!$model) { | ||
return ResponseHelper::fail([], '用户不存在'); | ||
} | ||
|
||
$item = $model->toArray(['username', 'nickname', 'mobile', 'email', 'status']); | ||
$item['created_at'] = DateHelper::format($model->created_at); | ||
$item['updated_at'] = DateHelper::format($model->updated_at); | ||
ResponseHelper::success(['fuser' => $item]); | ||
} | ||
|
||
/** | ||
* 获取用户信息,包括:用户数据,用户的菜单 | ||
*/ | ||
public function actionGetInfo() | ||
{ | ||
$mch = $this->getFuser(); | ||
|
||
$data = [ | ||
'mch' => [ | ||
'mch_no' => $mch->mch_no, | ||
'nickname' => $mch->nickname, | ||
'username' => $mch->username | ||
], | ||
'menus' => [ | ||
[ | ||
'name' => '首页', | ||
'route' => '/site/index', | ||
'icon' => 'fa fa-dashboard', | ||
], | ||
[ | ||
'name' => '订单列表', | ||
'route' => '/order/index', | ||
'icon' => 'fa fa-list', | ||
], | ||
[ | ||
'name' => '流水列表', | ||
'route' => '/balance-flow/index', | ||
'icon' => 'fa fa-list-ul', | ||
], | ||
[ | ||
'name' => '修改密码', | ||
'route' => '/mch/update-password', | ||
'icon' => 'fa fa-lock', | ||
], | ||
], | ||
]; | ||
return ResponseHelper::success($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace appwap\controllers; | ||
|
||
use common\consts\NotifyStatus; | ||
use common\consts\OrderStatus; | ||
use common\consts\ProductType; | ||
use common\helpers\PriceHelper; | ||
use common\helpers\DateHelper; | ||
use common\helpers\NotifyHelper; | ||
use common\helpers\ResponseHelper; | ||
use common\models\Fuser; | ||
use common\models\Payer; | ||
use Yii; | ||
use common\models\Order; | ||
use appwap\models\searchs\OrderSearch; | ||
use yii\base\Exception; | ||
use yii\data\Pagination; | ||
|
||
/** | ||
* OrderController implements the CRUD actions for Order model. | ||
*/ | ||
class OrderController extends BaseController | ||
{ | ||
public function actionIndex() | ||
{ | ||
$request = Yii::$app->request; | ||
$page = $request->get('page', 1) - 1; | ||
$page_size = $request->get('page_size', 10); | ||
$pagination = new Pagination(); | ||
$pagination->pageSize = $page_size; | ||
$pagination->page = $page; | ||
|
||
$searchModel = new OrderSearch(); | ||
$dataProvider = $searchModel->search($request->queryParams); | ||
$dataProvider->setPagination($pagination); | ||
$orders = $dataProvider->getModels(); | ||
$totalCount = $dataProvider->getTotalCount(); | ||
|
||
$items = []; | ||
/* @var Order $order */ | ||
foreach ($orders as $order) { | ||
$item = $order->toArray(); | ||
$item['total_price'] = PriceHelper::format2DecimalYuan($order->total_price); | ||
$item['origin_total_price'] = PriceHelper::format2DecimalYuan($order->origin_total_price); | ||
$item['order_status_label'] = OrderStatus::label($order->order_status); | ||
$item['created_at'] = DateHelper::format($order->created_at); | ||
$items[] = $item; | ||
} | ||
|
||
$data = [ | ||
'items' => $items, | ||
'total' => $totalCount | ||
]; | ||
return ResponseHelper::success($data); | ||
} | ||
|
||
// 订单首页统计 | ||
public function actionStat() | ||
{ | ||
$request = Yii::$app->request; | ||
$searchModel = new OrderSearch(); | ||
|
||
// 总数 | ||
$selectColumns = 'COUNT(1) total_count'; | ||
$dataProvider = $searchModel->search($request->queryParams); | ||
$total = $dataProvider->query->select($selectColumns)->asArray(true)->one(); | ||
|
||
// 成功的总数 | ||
$selectColumns = 'SUM(total_price) total_price, COUNT(1) total_count'; | ||
$dataProvider = $searchModel->search($request->queryParams); | ||
$success = $dataProvider->query->select($selectColumns)->andFilterWhere(['order_status' => OrderStatus::SUCCESS])->asArray(true)->one(); | ||
|
||
$data = [ | ||
'total_price_success' => $success['total_price'] ? PriceHelper::format2DecimalYuan($success['total_price']) : '0', | ||
'total_count_success' => $success['total_count'], | ||
'total_count' => $total['total_count'], | ||
]; | ||
return ResponseHelper::success($data); | ||
} | ||
} |
Oops, something went wrong.