1
This commit is contained in:
parent
be5141265c
commit
169b3a0129
@ -1,2 +1,2 @@
|
||||
1697014615
|
||||
s:136:"73_SQUJWFYexz5vguFUJmygUSJUbaeo4x1uA_aXBppE_D1hY5uRnkjvCNJ7RwVJ7HVPVysyP-JFBqsJ-6ryecwZOsLZbvmcDsF6p4ah9hO84B78Ge4Yq64_EPKRi8YYFJfAAARYC";
|
||||
1698137550
|
||||
s:136:"73_LcxbY8bhLRw82K5e2WkrOetlaYOKTU_ihRghos-wNPtnbcvn4mIdRnsWGGl_cdquHzzh0hb5yRUrbo-qe87SzOIeO73cRz1fsnn3MxjTjx5LbFFx0eVBR4-Q2-QKSNdABATBW";
|
||||
60
models/Report.php
Normal file
60
models/Report.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "cx_report".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id 用户ID
|
||||
* @property int $store_id 门店ID
|
||||
* @property string $model_number 模型编号
|
||||
* @property string|null $initial_path 初始模型路径
|
||||
* @property string|null $final_path 最终模型路径
|
||||
* @property string|null $pdf_path pdf路径
|
||||
* @property int $step 流程0-用户初始化 1-上传初始模型 2-医师上传模型
|
||||
* @property int $created_at 添加时间
|
||||
*/
|
||||
class Report extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'cx_report';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['user_id', 'store_id', 'model_number', 'created_at'], 'required'],
|
||||
[['user_id', 'store_id', 'step', 'created_at'], 'integer'],
|
||||
[['initial_path', 'final_path', 'pdf_path'], 'string'],
|
||||
[['model_number'], 'string', 'max' => 50],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'user_id' => 'User ID',
|
||||
'store_id' => 'Store ID',
|
||||
'model_number' => 'Model Number',
|
||||
'initial_path' => 'Initial Path',
|
||||
'final_path' => 'Final Path',
|
||||
'pdf_path' => 'Pdf Path',
|
||||
'step' => 'Step',
|
||||
'created_at' => 'Created At',
|
||||
];
|
||||
}
|
||||
}
|
||||
60
modules/admin/controllers/ReportController.php
Normal file
60
modules/admin/controllers/ReportController.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\admin\controllers;
|
||||
|
||||
use app\components\Serializer;
|
||||
use app\models\auth\Role;
|
||||
use app\models\auth\RoleUser;
|
||||
use app\models\CardUnion;
|
||||
use app\models\District;
|
||||
use app\models\Store;
|
||||
use app\models\StoreEarnings;
|
||||
use app\models\StoreUser;
|
||||
use app\models\User;
|
||||
use app\modules\admin\behaviors\LoginBehavior;
|
||||
use app\components\EncryptHelper;
|
||||
use app\modules\admin\models\BindLogListForm;
|
||||
use app\modules\admin\models\report\ReportListForm;
|
||||
use app\modules\admin\models\store\StoreActionForm;
|
||||
use app\modules\admin\models\store\StoreEaringsListForm;
|
||||
use app\modules\admin\models\store\StoreEditForm;
|
||||
use app\modules\admin\models\store\StoreListForm;
|
||||
use app\modules\admin\models\storeUser\StoreUserActionForm;
|
||||
use app\modules\admin\models\storeUser\StoreUserEditForm;
|
||||
use app\modules\admin\models\storeUser\StoreUserListForm;
|
||||
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return array_merge(parent::behaviors(), [
|
||||
'login' => [
|
||||
'class' => LoginBehavior::className(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
//报告列表
|
||||
public function actionIndex()
|
||||
{
|
||||
if (\Yii::$app->request->isAjax) {
|
||||
$form = new ReportListForm();
|
||||
$form->attributes = \Yii::$app->request->get();
|
||||
$data = $form->search();
|
||||
return $this->responseHandler($data);
|
||||
}
|
||||
return $this->render('index',[]);
|
||||
|
||||
}
|
||||
}
|
||||
@ -297,42 +297,42 @@ class Menu
|
||||
//
|
||||
// ],
|
||||
// ],
|
||||
[
|
||||
'name' => '模型管理',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => null,
|
||||
'icon' => 'layui-icon-chart',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'name' => '数据图表',
|
||||
// 'name' => '模型管理',
|
||||
// 'is_menu' => true,
|
||||
// 'is_show' => true,
|
||||
// 'route' => 'admin/bind-log/index',
|
||||
// 'action' => [
|
||||
// [
|
||||
// 'name' => '获取设备绑定数据',
|
||||
// 'route' => 'admin/bind-log/get-bind-data'
|
||||
// 'route' => null,
|
||||
// 'icon' => 'layui-icon-chart',
|
||||
//// 'children' => [
|
||||
//// [
|
||||
//// 'name' => '数据图表',
|
||||
//// 'is_menu' => true,
|
||||
//// 'is_show' => true,
|
||||
//// 'route' => 'admin/bind-log/index',
|
||||
//// 'action' => [
|
||||
//// [
|
||||
//// 'name' => '获取设备绑定数据',
|
||||
//// 'route' => 'admin/bind-log/get-bind-data'
|
||||
//// ],
|
||||
//// ]
|
||||
//// ],
|
||||
////
|
||||
//// ],
|
||||
// ],
|
||||
// ]
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
],
|
||||
[
|
||||
'name' => '报告管理',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => null,
|
||||
'icon' => 'layui-icon-list',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'name' => '订单列表',
|
||||
// 'is_menu' => true,
|
||||
// 'is_show' => true,
|
||||
// 'route' => 'admin/mall/order/index',
|
||||
// ],
|
||||
// ],
|
||||
'children' => [
|
||||
[
|
||||
'name' => '报告列表',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => 'admin/report/index',
|
||||
],
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => '财务管理',
|
||||
|
||||
124
modules/admin/models/report/ReportListForm.php
Normal file
124
modules/admin/models/report/ReportListForm.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\admin\models\report;
|
||||
|
||||
use app\components\EncryptHelper;
|
||||
use app\components\Utils;
|
||||
use app\models\District;
|
||||
use app\models\Model;
|
||||
use app\models\Report;
|
||||
use app\models\Store;
|
||||
use app\models\StoreUser;
|
||||
use app\models\User;
|
||||
use app\modules\admin\models\AdminModel;
|
||||
use app\models\common\CommonUserEditForm;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class ReportListForm extends AdminModel
|
||||
{
|
||||
public $page;
|
||||
public $limit;
|
||||
|
||||
public $keywords;
|
||||
public $status;
|
||||
public $store_id;
|
||||
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['keywords',], 'trim'],
|
||||
[['keywords',], 'string'],
|
||||
[['page', 'limit'], 'integer'],
|
||||
[['page'], 'default', 'value' => 1],
|
||||
[['limit'], 'default', 'value' => 20],
|
||||
];
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
if (!$this->validate()) {
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
$where = [];
|
||||
if (!empty($this->times)) {
|
||||
$explode = explode(' - ', $this->times);
|
||||
$where = [
|
||||
'and',
|
||||
['>=', 'o.created_at', strtotime($explode[0])],
|
||||
['<=', 'o.created_at', strtotime($explode[1])],
|
||||
];
|
||||
}
|
||||
|
||||
$query = Report::find()->alias('o')
|
||||
->select('o.id,o.model_number,o.initial_path,o.final_path,o.pdf_path,o.step,u.real_name,u.mobile_phone,s.name as store_name,o.created_at')
|
||||
->leftJoin(['u' => User::tableName()], 'o.user_id=u.id')
|
||||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||||
->where([
|
||||
|
||||
])->andWhere($where)
|
||||
->andFilterWhere(['o.store_id' => $this->store_id])
|
||||
->andFilterWhere([
|
||||
'OR',
|
||||
['like', 'u.mobile_phone', $this->keywords],
|
||||
['like', 'u.nickname', $this->keywords],
|
||||
['like', 'u.real_name', $this->keywords],
|
||||
]);
|
||||
|
||||
|
||||
$count = $query->count();
|
||||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
|
||||
foreach ($list as $index => $item) {
|
||||
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
||||
|
||||
$item['initial_path_ext'] = "";
|
||||
$item['initial_name'] = '';
|
||||
if (!empty($item['initial_path'])) {
|
||||
$item['initial_name'] = $item['model_number'] . '初始报告';
|
||||
$explode = explode('.', $item['initial_path']);
|
||||
$item['initial_path_ext'] = end($explode);
|
||||
}
|
||||
|
||||
$item['final_path_ext'] = '';
|
||||
$item['final_name'] = '';
|
||||
if (!empty($item['final_path'])) {
|
||||
$item['final_name'] = $item['model_number'] . '最终报告';
|
||||
$explode = explode('.', $item['final_path']);
|
||||
$item['final_path_ext'] = end($explode);
|
||||
}
|
||||
|
||||
|
||||
$item['pdf_path_ext'] = "";
|
||||
$item['pdf_name'] = '';
|
||||
if (!empty($item['pdf_path'])) {
|
||||
$item['pdf_name'] = $item['model_number'] . 'PDF报告';
|
||||
$explode = explode('.', $item['pdf_path']);
|
||||
$item['pdf_path_ext'] = end($explode);
|
||||
}
|
||||
|
||||
|
||||
$list[$index] = $item;
|
||||
}
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = 'ok';
|
||||
$data['data'] = $list;
|
||||
$data['count'] = $count;
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
247
modules/admin/models/report/StoreActionForm.php
Normal file
247
modules/admin/models/report/StoreActionForm.php
Normal file
@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
namespace app\modules\admin\models\store;
|
||||
use app\components\FlashStorage;
|
||||
use app\components\SiteHelper;
|
||||
use app\components\ZipFile;
|
||||
use app\models\auth\RoleUser;
|
||||
use app\models\Coach;
|
||||
use app\models\District;
|
||||
use app\models\Model;
|
||||
use app\models\Store;
|
||||
use app\models\StoreUser;
|
||||
use app\models\User;
|
||||
use app\models\Admin;
|
||||
use app\modules\admin\models\AdminModel;
|
||||
use app\models\common\CommonUserEditForm;
|
||||
use app\modules\api\models\StoreCityForm;
|
||||
|
||||
class StoreActionForm extends AdminModel
|
||||
{
|
||||
public $ids;
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['ids'], 'required'],
|
||||
[['ids'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'ids' => '选择项',
|
||||
];
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
$t = \Yii::$app->db->beginTransaction();
|
||||
|
||||
foreach ($this->ids as $item){
|
||||
$model = Store::findOne([
|
||||
'id' => $item,
|
||||
'is_delete' => 0
|
||||
]);
|
||||
if($model == null){
|
||||
return Model::asReturnError('该门店不存在或已被清理');
|
||||
}
|
||||
|
||||
if($model->is_delete == 1){
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->is_delete = 1;
|
||||
$model->deleted_at = time();
|
||||
if(!$model->save()){
|
||||
$t->rollBack();
|
||||
return Model::getModelErrorInfo($model);
|
||||
}
|
||||
Admin::updateAll(['is_delete' => 1],['is_delete' => 0, 'user_id' => $item]);
|
||||
// 删除数据表
|
||||
$redis_name = \Yii::$app->params['cacheKeyPrefix'].":api:store:zset";
|
||||
try{
|
||||
$res = \Yii::$app->redis->ZREM($redis_name,$model->id);
|
||||
}catch (\Exception $e){
|
||||
|
||||
}
|
||||
$exists = StoreUser::find()->where(['store_id' => $model->id, 'is_delete' => 0,])->exists();
|
||||
if($exists){
|
||||
$is_update = StoreUser::updateAll(['is_delete' => 1],['store_id' => $model->id, 'is_delete' => 0,]);
|
||||
if(!$is_update){
|
||||
$t->rollBack();
|
||||
return Model::asReturnError('清理门店操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$t->commit();
|
||||
// 删除城市缓存
|
||||
$obj = new StoreCityForm();
|
||||
$cache_name = $obj->getCacheName();
|
||||
FlashStorage::deleteCache($cache_name);
|
||||
return Model::asReturnSuccess('操作成功');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function status_yes()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
foreach ($this->ids as $item){
|
||||
$model = Store::findOne([
|
||||
'id' => $item,
|
||||
'is_delete' => 0,
|
||||
'status' => 0
|
||||
]);
|
||||
|
||||
if($model == null){
|
||||
return Model::asReturnError('该门店不存在或已被清理');
|
||||
}
|
||||
if($model->status == 1){
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->status = 1;
|
||||
$model->updated_at = time();
|
||||
if(!$model->save()){
|
||||
return Model::getModelErrorInfo($model);
|
||||
}
|
||||
}
|
||||
|
||||
return Model::asReturnSuccess('操作成功');
|
||||
}
|
||||
|
||||
public function status_no()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
foreach ($this->ids as $item){
|
||||
$model = Store::findOne([
|
||||
'id' => $item,
|
||||
'is_delete' => 0,
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
if($model == null){
|
||||
return Model::asReturnError('该门店不存在或已被清理');
|
||||
}
|
||||
|
||||
if($model->status == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->status = 0;
|
||||
$model->updated_at = time();
|
||||
if(!$model->save()){
|
||||
return Model::getModelErrorInfo($model);
|
||||
}
|
||||
}
|
||||
|
||||
return Model::asReturnSuccess('操作成功');
|
||||
}
|
||||
|
||||
public function getStoreQrcode()
|
||||
{
|
||||
$store = Store::findOne($this->ids);
|
||||
if($store == null){
|
||||
return ['code' => 1,'msg' => '门店不存在'];
|
||||
}
|
||||
return $this->getQrcode($store);
|
||||
}
|
||||
|
||||
public function getQrcode($store)
|
||||
{
|
||||
$path = 'wxqrcode/store_qrcode';
|
||||
if(!is_dir($path)){
|
||||
mkdir($path,0777,true);
|
||||
}
|
||||
$body['page'] = 'pages/index/indexTwo';
|
||||
$body['scene'] = "store_id={$store->id}";
|
||||
$json_body = md5(json_encode($body));
|
||||
$path.='/'.$json_body.'.png';
|
||||
if(!file_exists($path)){
|
||||
$res = self::wxmpQrcode($body);
|
||||
if (json_encode($res) !== false) {
|
||||
$res = json_decode($res,true);
|
||||
return ['code' => 1,'msg' => $res['errmsg']];
|
||||
} else {
|
||||
$file = fopen($path, "w");//打开文件准备写入
|
||||
fwrite($file, $res);//写入,$res为图片二进制内容
|
||||
fclose($file);//关闭
|
||||
//图片是否存在
|
||||
if (!file_exists($path)) {
|
||||
return ['code' => 1,'msg' => '生成二维码失败'];
|
||||
} else {
|
||||
|
||||
return ['code' => 0,'msg' => 'ok','data' => SiteHelper::getFullUrl($path)];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return ['code' => 0,'msg' => 'ok','data' => SiteHelper::getFullUrl($path)];
|
||||
}
|
||||
}
|
||||
|
||||
//获取小程序二维码
|
||||
public function wxmpQrcode($body)
|
||||
{
|
||||
$plugin = new \app\models\common\PluginService();
|
||||
$wxmpService = $plugin->getWxmpService(0);
|
||||
$accessToken = $wxmpService->getAccessToken();
|
||||
if(empty($accessToken)){
|
||||
$accessToken = $wxmpService->getAccessToken(true);
|
||||
}
|
||||
$body = json_encode($body);
|
||||
return $wxmpService->Qrcode->getWxappQrcode($accessToken,$body);
|
||||
}
|
||||
|
||||
public function BatchQrcode()
|
||||
{
|
||||
$store = Store::find()->select('id,name')->where(['is_delete' => 0])->all();
|
||||
if($store == null){
|
||||
return ['code' => 1,'msg' => '门店不存在'];
|
||||
}
|
||||
|
||||
$path = 'wxqrcode/store_qrcode_zip';
|
||||
if(!is_dir($path)){
|
||||
mkdir($path,0777,true);
|
||||
}
|
||||
|
||||
$paths = [];
|
||||
foreach ($store as $value){
|
||||
$r = $this->getQrcode($value);
|
||||
if($r['code'] != 0){
|
||||
return $r['msg'];
|
||||
}
|
||||
array_push($paths,['name'=>$value->name.'.png','path' => $r['data']]);
|
||||
}
|
||||
|
||||
if(empty($paths)){
|
||||
return '无下载数据';
|
||||
}
|
||||
$zipName = '门店二维码_'.date('Y年m月d日').'下载' . '.zip'; // 压缩包文件名
|
||||
return (new ZipFile())->downloadZipImg($zipName,$path,$paths);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
159
modules/admin/models/report/StoreEaringsListForm.php
Normal file
159
modules/admin/models/report/StoreEaringsListForm.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\admin\models\store;
|
||||
|
||||
use app\components\SysConst;
|
||||
use app\models\Order;
|
||||
use app\models\Store;
|
||||
use app\models\StoreEarnings;
|
||||
use app\models\User;
|
||||
use app\modules\admin\models\AdminModel;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class StoreEaringsListForm extends AdminModel
|
||||
{
|
||||
public $page;
|
||||
public $limit;
|
||||
|
||||
public $keywords;
|
||||
public $status;
|
||||
public $store_id;
|
||||
|
||||
|
||||
public $start_time;
|
||||
public $end_time;
|
||||
|
||||
public $date;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['keywords',], 'trim'],
|
||||
[['keywords',], 'string'],
|
||||
[['start_time',], 'string'],
|
||||
[['end_time',], 'string'],
|
||||
[['date',], 'string'],
|
||||
[['page', 'limit', 'status', 'store_id'], 'integer'],
|
||||
[['page'], 'default', 'value' => 1],
|
||||
[['limit'], 'default', 'value' => 20],
|
||||
];
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
if (!$this->validate()) {
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
|
||||
$start_time = !empty($this->start_time) ? strtotime($this->start_time) : 0;
|
||||
$end_time = !empty($this->end_time) ? strtotime($this->end_time) : time();
|
||||
|
||||
$query = StoreEarnings::find()->alias('se')
|
||||
->select('se.id,se.money,u.nickname,s.name as store_name,o.order_no,se.created_at,o.total_price,o.plugin_sign')
|
||||
->leftJoin(['u' => User::tableName()], 'se.user_id=u.id')
|
||||
->leftJoin(['s' => Store::tableName()], 'se.store_id=s.id')
|
||||
->leftJoin(['o' => Order::tableName()], 'se.order_id=o.id')
|
||||
->where([
|
||||
'se.is_delete' => 0
|
||||
])
|
||||
->andFilterWhere(['se.status' => $this->status])
|
||||
->andFilterWhere(['se.store_id' => $this->store_id])
|
||||
->andWhere(['BETWEEN', 'se.created_at', $start_time, $end_time])
|
||||
->andFilterWhere([
|
||||
'OR',
|
||||
['like', 's.name', $this->keywords],
|
||||
['like', 'u.nickname', $this->keywords],
|
||||
['like', 'o.order_no', $this->keywords],
|
||||
]);
|
||||
$obj_data = clone $query;
|
||||
$admin_money = $obj_data->sum('total_price-money')??0;
|
||||
$count = $query->count();
|
||||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['se.created_at' => SORT_DESC])->asArray()->all();
|
||||
|
||||
|
||||
// $admin_money = 0;
|
||||
|
||||
foreach ($list as $index => $item) {
|
||||
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
||||
if ($item['money'] > 0) {
|
||||
if ($item['total_price'] != 0) {
|
||||
$num = $item['money'] / $item['total_price'];
|
||||
$num = $num * 100;
|
||||
$item['store_percentage'] = floor($num);
|
||||
} else {
|
||||
$item['store_percentage'] = 0;
|
||||
}
|
||||
$item['admin_money'] = $item['total_price'] - $item['money'];
|
||||
} else {
|
||||
$item['store_percentage'] = 0;
|
||||
$item['admin_money'] = $item['total_price'];
|
||||
}
|
||||
$list[$index] = $item;
|
||||
// $admin_money += $item['admin_money'];
|
||||
}
|
||||
|
||||
|
||||
$sum = StoreEarnings::find()->where(['between', 'created_at', $start_time, $end_time])->andWhere([
|
||||
'is_delete' => 0,
|
||||
])->andFilterWhere(['store_id' => $this->store_id])->sum('money')??0;
|
||||
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = 'ok';
|
||||
$data['data'] = $list;
|
||||
$data['count'] = $count;
|
||||
$data['store_money'] = round($sum,2);
|
||||
$data['admin_money'] = round($admin_money,2);
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getStoreList()
|
||||
{
|
||||
$time = time();
|
||||
$start_date = $time - 60 * 60 * 12;
|
||||
$end_date = $time;
|
||||
if (!empty($this->date)) {
|
||||
$explode = explode(' - ', $this->date);
|
||||
if (!empty($explode)) {
|
||||
$start_date = strtotime($explode[0]);
|
||||
$end_date = strtotime($explode[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = StoreEarnings::find()->alias('se')
|
||||
->select('se.id,sum(se.money) as store_money,s.name as store_name,,se.created_at,o.total_price')
|
||||
->leftJoin(['s' => Store::tableName()], 'se.store_id=s.id')
|
||||
->leftJoin(['o' => Order::tableName()], 'se.order_id=o.id')
|
||||
->where([
|
||||
'se.is_delete' => 0
|
||||
])
|
||||
->andFilterWhere(['se.store_id' => $this->store_id])
|
||||
->andWhere(['BETWEEN', 'se.created_at', 0, $end_date])
|
||||
->groupBy('se.store_id')
|
||||
->asArray()->all();
|
||||
|
||||
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = 'ok';
|
||||
$data['data']['store_name'] = array_column($query, 'store_name');
|
||||
$data['data']['store_money'] = array_column($query, 'store_money');
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
175
modules/admin/models/report/StoreEditForm.php
Normal file
175
modules/admin/models/report/StoreEditForm.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
namespace app\modules\admin\models\store;
|
||||
use app\components\EncryptHelper;
|
||||
use app\components\FlashStorage;
|
||||
use app\models\Admin;
|
||||
use app\models\auth\RoleUser;
|
||||
use app\models\CardUnion;
|
||||
use app\models\District;
|
||||
use app\models\Model;
|
||||
use app\models\StoreUser;
|
||||
use app\models\SysAdmin;
|
||||
use app\models\User;
|
||||
use app\modules\admin\models\AdminModel;
|
||||
use app\models\common\CommonUserEditForm;
|
||||
use app\modules\api\models\StoreCityForm;
|
||||
use Wechat\Wechat;
|
||||
|
||||
class StoreEditForm extends AdminModel
|
||||
{
|
||||
public $model;
|
||||
|
||||
|
||||
public $name;
|
||||
public $status;
|
||||
public $province_id;
|
||||
public $city_id;
|
||||
public $region_id;
|
||||
public $location_detail;
|
||||
public $phone;
|
||||
|
||||
public $begin_time;
|
||||
public $end_time;
|
||||
|
||||
public $user_id;
|
||||
public $created_at;
|
||||
public $updated_at;
|
||||
public $is_delete;
|
||||
public $deleted_at;
|
||||
public $sort;
|
||||
|
||||
public $province;
|
||||
public $city;
|
||||
public $region;
|
||||
public $ratio;
|
||||
|
||||
public $role_ids;
|
||||
public $cx_mch_id;
|
||||
public $creator_user_id;
|
||||
|
||||
|
||||
public $area;
|
||||
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['province_id', 'city_id', 'region_id', 'status', 'created_at', 'updated_at', 'is_delete', 'deleted_at','cx_mch_id','creator_user_id','ratio','user_id'], 'integer'],
|
||||
[['area'], 'string'],
|
||||
[['role_ids', 'model'], 'safe'],
|
||||
[['name', 'sort'], 'string', 'max' => 50],
|
||||
[['phone'], 'string', 'max' => 20],
|
||||
[['ratio'], 'integer', 'min' => 0,'max' => 100],
|
||||
[['province', 'city', 'region','begin_time', 'end_time',], 'string', 'max' => 20],
|
||||
[['location_detail'], 'string', 'max' => 255],
|
||||
[['name', 'province_id', 'city_id', 'region_id', 'location_detail', 'begin_time', 'end_time','area','phone'], 'required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => '门店名称',
|
||||
'province' => '省',
|
||||
'province_id' => '省ID',
|
||||
'city' => '市',
|
||||
'city_id' => '市ID',
|
||||
'region' => '区',
|
||||
'region_id' => '区ID',
|
||||
'location_detail' => '门店具体位置',
|
||||
'begin_time' => '营业开始时间',
|
||||
'end_time' => '营业结束时间',
|
||||
'status' => '1-营业 0-停业',
|
||||
'sort' => '排序',
|
||||
'created_at' => '添加时间',
|
||||
'updated_at' => '修改时间',
|
||||
'is_delete' => '是否删除,0=否,1=是',
|
||||
'deleted_at' => '删除时间',
|
||||
'ratio' => '收益比例',
|
||||
'area' => '区域坐标',
|
||||
'phone' => '客服电话',
|
||||
];
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
|
||||
if($this->model->isNewRecord){
|
||||
$this->model->is_delete = 0;
|
||||
$this->model->deleted_at = 0;
|
||||
$this->model->sort = '100';
|
||||
$this->model->created_at = time();
|
||||
|
||||
}
|
||||
|
||||
$this->model->name = $this->name;
|
||||
$this->model->location_detail = $this->location_detail;
|
||||
$this->model->begin_time = $this->begin_time;
|
||||
$this->model->end_time = $this->end_time;
|
||||
$this->model->updated_at = time();
|
||||
$province = District::findOne($this->province_id);
|
||||
if(empty($province)){
|
||||
return Model::asReturnError('用户所在省级行政区未找到');
|
||||
}
|
||||
$city = District::findOne($this->city_id);
|
||||
if(empty($city)){
|
||||
return Model::asReturnError('用户所在市级行政区未找到');
|
||||
}
|
||||
$region = District::findOne($this->region_id);
|
||||
if(empty($region)){
|
||||
return Model::asReturnError('用户所在区/县级行政区未找到');
|
||||
}
|
||||
$area_json = [];
|
||||
$area_arr = json_decode($this->area,true);
|
||||
foreach ($area_arr as $index => $item){
|
||||
$area_json[$item['area_type']] = $item;
|
||||
}
|
||||
|
||||
$this->model->province = $province->name;
|
||||
$this->model->city = $city->name;
|
||||
$this->model->region = $region->name;
|
||||
$this->model->province_id = $province->id;
|
||||
$this->model->city_id = $city->id;
|
||||
$this->model->region_id = $region->id;
|
||||
$this->model->ratio = $this->ratio;
|
||||
$this->model->area = json_encode($area_json,JSON_UNESCAPED_UNICODE);
|
||||
$this->model->lat = strval($area_json['store']['paths'][0]['lat']);
|
||||
$this->model->lng = strval($area_json['store']['paths'][0]['lng']);
|
||||
$this->model->phone = $this->phone;
|
||||
if(!$this->model->save()){
|
||||
return $this->getModelError($this->model);
|
||||
}
|
||||
|
||||
// 存入数据表
|
||||
$redis_name = \Yii::$app->params['cacheKeyPrefix'].":api:store:zset";
|
||||
try{
|
||||
\Yii::$app->redis->geoadd($redis_name,$this->model->lat,$this->model->lng,$this->model->id);
|
||||
}catch (\Exception $e){
|
||||
|
||||
}
|
||||
// 删除城市缓存
|
||||
$obj = new StoreCityForm();
|
||||
$cache_name = $obj->getCacheName();
|
||||
FlashStorage::deleteCache($cache_name);
|
||||
return $this->apiReturnSuccess('保存成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
435
modules/admin/views/report/index.php
Normal file
435
modules/admin/views/report/index.php
Normal file
@ -0,0 +1,435 @@
|
||||
<?php
|
||||
|
||||
use app\models\Store;
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2021年6月30日
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
$this->title = '报告列表';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<?= $this->title ?>
|
||||
</div>
|
||||
<div class="layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<!--<a class=" layui-btn" href="<?= \Yii::$app->urlManager->createUrl(["admin/feedback/edit"]) ?>">添加反馈</a>-->
|
||||
</div>
|
||||
<div class="layui-inline layui-float-right layui-form">
|
||||
|
||||
<!-- <div class="layui-inline layui-form-item">-->
|
||||
<!-- <div class="layui-input-inline">-->
|
||||
<!-- <select class="layui-select" name="status">-->
|
||||
<!-- <option value="" -->
|
||||
<? //=$status === null ? 'selected' : ''?><!--全部状态</option>
|
||||
<!-- --><?php //foreach ($status_labels as $key => $val):?>
|
||||
<!-- <option value="--><? //=$key?><!--" -->
|
||||
<? //=$status == $key && $status != null ? 'selected' : ''?><!--><? //=$val?><!--</option>-->
|
||||
<!-- --><?php //endforeach;?>
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<div class="layui-inline layui-form-item">
|
||||
<label class="layui-form-label">关键词</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keywords" placeholder="搜索姓名,手机号" autocomplete="off"
|
||||
class="layui-input"
|
||||
value="<?= \Yii::$app->request->get("keywords") ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">
|
||||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<table id="dtable" lay-filter="dtable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--工具栏模板-->
|
||||
<script type="text/html" id="toolBarTpl">
|
||||
<div class="layui-btn-container">
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="batch_status_yes">批量营业</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_status_no">批量停业</button>-->
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="batch_qrcode">打包二维码</button>
|
||||
</div>
|
||||
</script>
|
||||
<!--行操作列模板-->
|
||||
<script type="text/html" id="rowBarTpl">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="find_qrcode">二维码</button>
|
||||
|
||||
|
||||
{{# if(d.initial_path){ }}
|
||||
<a href="{{d.initial_path}}"
|
||||
download="{{d.initial_name}}.{{d.initial_path_ext}}">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="">下载初始模型</button>
|
||||
</a>
|
||||
{{# } }}
|
||||
|
||||
{{# if(d.final_path){ }}
|
||||
<a href="{{d.final_path}}"
|
||||
download="{{d.final_name}}.{{d.final_path_ext}}">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载最终模型</button>
|
||||
</a>
|
||||
{{# } }}
|
||||
|
||||
|
||||
{{# if(d.pdf_path){ }}
|
||||
<a href="{{d.pdf_path}}"
|
||||
download="{{d.pdf_name}}.{{d.pdf_path_ext}}">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载PDF报告</button>
|
||||
</a>
|
||||
{{# } }}
|
||||
<!-- <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>-->
|
||||
</script>
|
||||
|
||||
|
||||
<!--<script type="text/html" id="statusTpl">-->
|
||||
<!-- {{# if(d.status == '0'){ }}-->
|
||||
<!-- <span class="layui-badge layui-bg-red">停业</span>-->
|
||||
<!-- {{# } else{ }}-->
|
||||
<!-- <span class="layui-badge layui-bg-blue">营业</span>-->
|
||||
<!-- {{# } }}-->
|
||||
<!--</script>-->
|
||||
|
||||
|
||||
<script>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
|
||||
|
||||
layui.config({
|
||||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'user', 'table', 'form'], function () {
|
||||
var $ = layui.$
|
||||
, form = layui.form
|
||||
, table = layui.table
|
||||
, admin = layui.admin;
|
||||
|
||||
|
||||
form.render();
|
||||
|
||||
//search
|
||||
form.on('submit(dtable-search)', function (obj) {
|
||||
var field = obj.field;
|
||||
reload_table_data(field);
|
||||
});
|
||||
|
||||
|
||||
//重新加载表格数据
|
||||
function reload_table_data(conf) {
|
||||
table.reload('dtable', {
|
||||
url: '<?=\Yii::$app->urlManager->createUrl(['admin/report/index'])?>'
|
||||
, page: true
|
||||
, where: conf
|
||||
});
|
||||
};
|
||||
|
||||
//执行渲染
|
||||
table.render({
|
||||
//指定原始表格元素选择器(推荐id选择器)
|
||||
elem: '#dtable'
|
||||
//容器高度
|
||||
//,height: 315
|
||||
//容器宽度
|
||||
//,width: 720
|
||||
//设置表头
|
||||
, cols: [[
|
||||
{checkbox: true}
|
||||
, {field: 'id', title: 'ID', width: 80}
|
||||
, {field: 'real_name', title: '姓名', width: 100}
|
||||
, {field: 'mobile_phone', title: '电话', width: 120}
|
||||
, {field: 'store_name', title: '门店名称'}
|
||||
, {field: 'model_number', title: '报告编号'}
|
||||
, {field: 'initial_name', title: '初始模型'}
|
||||
, {field: 'final_name', title: '最终模型'}
|
||||
, {field: 'pdf_name', title: 'PDF报告'}
|
||||
// , {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
|
||||
, {field: 'created_at_cn', title: '创建时间', width: 150}
|
||||
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 400}
|
||||
]
|
||||
]
|
||||
, url: '<?=\Yii::$app->urlManager->createUrl(['admin/report/index'])?>'
|
||||
, page: true
|
||||
//指向自定义工具栏模板选择器
|
||||
, toolbar: '#toolBarTpl'
|
||||
//头部工具栏右侧的图标按钮
|
||||
, defaultToolbar: []
|
||||
, limit: 20
|
||||
, limits: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
|
||||
, title: '<?=$this->title?>'
|
||||
, data: []
|
||||
, done: function (res, curr, count) {
|
||||
setTimeout(function () {
|
||||
$(".layui-table-main tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
$(".layui-table-header tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//监听工具条
|
||||
table.on('tool(dtable)', function (obj) {
|
||||
var row_data = obj.data;
|
||||
var lay_event = obj.event;
|
||||
var id = row_data.id;
|
||||
var confirm_url = null;
|
||||
var confirm_tip = null;
|
||||
var ids = [];
|
||||
ids.push(id);
|
||||
|
||||
if (lay_event == "delete") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/delete'])?>";
|
||||
confirm_tip = "确定删除此门店吗";
|
||||
}
|
||||
if (lay_event == "status_yes") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/status-yes'])?>";
|
||||
confirm_tip = "确定此门店变更为营业吗?";
|
||||
}
|
||||
if (lay_event == "status_no") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/status-no'])?>";
|
||||
confirm_tip = "确定此门店变更为停业吗?";
|
||||
}
|
||||
if (lay_event == "find_qrcode") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/find-qrcode'])?>";
|
||||
confirm_tip = "确定查看此门店二维码吗?";
|
||||
}
|
||||
if (lay_event == 'edit') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/edit'])?>" + "?id=" + id;
|
||||
location.href = confirm_url;
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm_url != null) {
|
||||
layer.confirm(confirm_tip, {
|
||||
btn: ['确定', '取消']
|
||||
}, function (index) {
|
||||
layer.close(index)
|
||||
$.ajax(confirm_url, {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
ids: ids,
|
||||
_csrf: _csrf
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
if (lay_event == 'find_qrcode') {
|
||||
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
|
||||
//弹出层
|
||||
layer.open({
|
||||
type: 1,
|
||||
shade: 0,
|
||||
offset: 'auto',
|
||||
area: 'auth',
|
||||
shadeClose: true,
|
||||
scrollbar: false,
|
||||
title: "图片预览", //不显示标题
|
||||
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, type, err) {
|
||||
layer.msg(xhr.responseText, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
})
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//监听工具栏
|
||||
table.on('toolbar(dtable)', function (obj) {
|
||||
var lay_event = obj.event;
|
||||
var check_status = table.checkStatus('dtable');
|
||||
var ids = [];
|
||||
$(check_status.data).each(function (index) {
|
||||
ids.push(check_status.data[index]['id']);
|
||||
});
|
||||
if (lay_event == 'batch_qrcode') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/batch-qrcode'])?>";
|
||||
location.href = confirm_url;
|
||||
return;
|
||||
}
|
||||
if (ids.length == 0) {
|
||||
return layer.msg("请选择需要操作项");
|
||||
}
|
||||
|
||||
var confirm_url = null;
|
||||
var confirm_tip = null;
|
||||
if (lay_event == 'batch_delete') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/delete'])?>";
|
||||
confirm_tip = "确定将选中门店删除吗";
|
||||
}
|
||||
|
||||
if (lay_event == 'batch_status_yes') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/status-yes'])?>";
|
||||
confirm_tip = "确定将选中门店变更为营业吗";
|
||||
}
|
||||
if (lay_event == 'batch_status_no') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/status-no'])?>";
|
||||
confirm_tip = "确定将选中门店变更为停业吗";
|
||||
}
|
||||
|
||||
if (confirm_url != null) {
|
||||
layer.confirm(confirm_tip, {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.ajax(confirm_url, {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
ids: ids,
|
||||
_csrf: _csrf
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, type, err) {
|
||||
layer.msg(xhr.responseText, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
})
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
form.on('select(province)', function (res) {
|
||||
app.province_id = res.value;
|
||||
$(app.province).each(function (i) {
|
||||
if (app.province[i].id == app.province_id) {
|
||||
app.city = app.province_id != 0 ? app.province[i].list : [];
|
||||
//app.city_id = app.province_id != 0 ? app.province[i].list[0]['id'] : 0;
|
||||
app.area = app.province_id != 0 ? app.city[0].list : [];
|
||||
//app.area_id = app.province_id != 0 ? app.city[0].list[0]['id'] : 0;
|
||||
app.province_id = app.province_id == 0 ? '' : app.province_id;
|
||||
app.$forceUpdate();
|
||||
setTimeout(function () {
|
||||
form.render('select');
|
||||
}, 500);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
form.on('select(city)', function (res) {
|
||||
app.city_id = res.value;
|
||||
$(app.city).each(function (i) {
|
||||
if (app.city[i].id == app.city_id) {
|
||||
app.area = app.city[i].list;
|
||||
//app.area_id = app.city[i].list[0]['id'];
|
||||
app.$forceUpdate();
|
||||
setTimeout(function () {
|
||||
form.render('select');
|
||||
}, 500);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
form.on('select(area)', function (res) {
|
||||
app.area_id = res.value;
|
||||
setTimeout(function () {
|
||||
form.render('select');
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
function previewImg(obj) {
|
||||
var img = new Image();
|
||||
img.src = obj.src;
|
||||
var imgw = img.width;
|
||||
var imgh = img.height;
|
||||
var img_th = imgh / imgw * 500;
|
||||
var imgHtml = "<img src='" + obj.src + "' width='500px' height='" + img_th + "px'/>";
|
||||
//弹出层
|
||||
layer.open({
|
||||
type: 1,
|
||||
shade: 0.8,
|
||||
offset: 'auto',
|
||||
area: [500 + 'px', (img_th + 50) + 'px'],
|
||||
shadeClose: true,
|
||||
scrollbar: false,
|
||||
title: "图片预览", //不显示标题
|
||||
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||
cancel: function () {
|
||||
//layer.msg('捕获就是从页面已经存在的元素上,包裹layer的结构', { time: 5000, icon: 6 });
|
||||
}
|
||||
});
|
||||
}
|
||||
<?php $this->endBlock(); ?>
|
||||
</script>
|
||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||
|
||||
91
modules/store/controllers/ReportController.php
Normal file
91
modules/store/controllers/ReportController.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\store\controllers;
|
||||
|
||||
|
||||
use app\models\Report;
|
||||
use app\models\StoreUser;
|
||||
use app\models\User;
|
||||
use app\modules\store\behaviors\LoginBehavior;
|
||||
use app\components\EncryptHelper;
|
||||
use app\modules\store\models\report\ReportEditForm;
|
||||
use app\modules\store\models\report\ReportListForm;
|
||||
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return array_merge(parent::behaviors(), [
|
||||
'login' => [
|
||||
'class' => LoginBehavior::className(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
//报告列表
|
||||
public function actionIndex()
|
||||
{
|
||||
if (\Yii::$app->request->isAjax) {
|
||||
$form = new ReportListForm();
|
||||
$form->store_id = \Yii::$app->store->identity->store_id;
|
||||
$form->attributes = \Yii::$app->request->get();
|
||||
$data = $form->search();
|
||||
return $this->responseHandler($data);
|
||||
}
|
||||
return $this->render('index', []);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function actionEdit($id = 0)
|
||||
{
|
||||
$model = Report::findOne([
|
||||
'id' => $id,
|
||||
]);
|
||||
if ($model == null)
|
||||
$model = new Report();
|
||||
|
||||
|
||||
$store_user_id = \Yii::$app->store->identity->user_id;
|
||||
$storeUser = StoreUser::findOne(['user_id' => $store_user_id]);
|
||||
|
||||
if (\Yii::$app->request->isAjax) {
|
||||
$form = new ReportEditForm();
|
||||
$form->store_id = \Yii::$app->store->identity->store_id;
|
||||
$form->model = $model;
|
||||
$form->user_type = $storeUser->user_type;
|
||||
$form->attributes = \Yii::$app->request->post();
|
||||
|
||||
$data = $form->edit();
|
||||
return $this->responseHandler($data);
|
||||
}
|
||||
|
||||
if ($model != null) {
|
||||
$user = User::findOne(['id' => $model->user_id]);
|
||||
}
|
||||
|
||||
|
||||
$report_name = $storeUser->user_type == 1 ? '初始模型' : '最终模型';
|
||||
|
||||
$return_url = \Yii::$app->request->referrer;
|
||||
|
||||
return $this->render("edit", [
|
||||
'model' => $model,
|
||||
'return_url' => $return_url,
|
||||
'user' => $user,
|
||||
'storeUser' => $storeUser,
|
||||
'report_name' => $report_name
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -49,64 +49,70 @@ class Menu
|
||||
],*/
|
||||
|
||||
[
|
||||
'name' => '订单管理',
|
||||
'name' => '报告管理',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => null,
|
||||
'icon' => 'layui-icon-list',
|
||||
'children' => [
|
||||
[
|
||||
'name' => '订单列表',
|
||||
'name' => '报告列表',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => 'store/mall/order/index',
|
||||
],
|
||||
],
|
||||
'route' => 'store/report/index',
|
||||
],
|
||||
[
|
||||
'name' => '财务管理',
|
||||
'name' => '上传报告',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => null,
|
||||
'icon' => 'layui-icon-rmb',
|
||||
'children' => [
|
||||
/**
|
||||
* [
|
||||
* 'name' => '提现管理',
|
||||
* 'is_menu' => true,
|
||||
* 'is_show' => true,
|
||||
* 'route' => null,
|
||||
* 'children' => [
|
||||
* [
|
||||
* 'name' => '提现列表',
|
||||
* 'is_menu' => true,
|
||||
* 'is_show' => true,
|
||||
* 'route' => 'store/cash/index',
|
||||
* ],
|
||||
* [
|
||||
* 'name' => '提现设置',
|
||||
* 'is_menu' => true,
|
||||
* 'is_show' => true,
|
||||
* 'route' => 'store/cash/setting',
|
||||
* ],
|
||||
* ],
|
||||
* ],
|
||||
* */
|
||||
[
|
||||
'name' => '门店收益',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => 'store/store/store-earings',
|
||||
],
|
||||
[
|
||||
'name' => '数据图表',
|
||||
'is_menu' => true,
|
||||
'is_show' => true,
|
||||
'route' => 'store/store/bind',
|
||||
],
|
||||
|
||||
'is_show' => false,
|
||||
'route' => 'store/report/edit',
|
||||
],
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => '财务管理',
|
||||
// 'is_menu' => true,
|
||||
// 'is_show' => true,
|
||||
// 'route' => null,
|
||||
// 'icon' => 'layui-icon-rmb',
|
||||
// 'children' => [
|
||||
// /**
|
||||
// * [
|
||||
// * 'name' => '提现管理',
|
||||
// * 'is_menu' => true,
|
||||
// * 'is_show' => true,
|
||||
// * 'route' => null,
|
||||
// * 'children' => [
|
||||
// * [
|
||||
// * 'name' => '提现列表',
|
||||
// * 'is_menu' => true,
|
||||
// * 'is_show' => true,
|
||||
// * 'route' => 'store/cash/index',
|
||||
// * ],
|
||||
// * [
|
||||
// * 'name' => '提现设置',
|
||||
// * 'is_menu' => true,
|
||||
// * 'is_show' => true,
|
||||
// * 'route' => 'store/cash/setting',
|
||||
// * ],
|
||||
// * ],
|
||||
// * ],
|
||||
// * */
|
||||
// [
|
||||
// 'name' => '门店收益',
|
||||
// 'is_menu' => true,
|
||||
// 'is_show' => true,
|
||||
// 'route' => 'store/store/store-earings',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => '数据图表',
|
||||
// 'is_menu' => true,
|
||||
// 'is_show' => true,
|
||||
// 'route' => 'store/store/bind',
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
// ],
|
||||
[
|
||||
'name' => '设置',
|
||||
'is_menu' => true,
|
||||
|
||||
74
modules/store/models/report/ReportEditForm.php
Normal file
74
modules/store/models/report/ReportEditForm.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\store\models\report;
|
||||
|
||||
use app\components\EncryptHelper;
|
||||
use app\components\FlashStorage;
|
||||
use app\models\Admin;
|
||||
use app\models\auth\RoleUser;
|
||||
use app\models\CardUnion;
|
||||
use app\models\District;
|
||||
use app\models\Model;
|
||||
use app\models\StoreUser;
|
||||
use app\models\SysAdmin;
|
||||
use app\models\User;
|
||||
use app\modules\store\models\AdminModel;
|
||||
use app\models\common\CommonUserEditForm;
|
||||
use app\modules\api\models\StoreCityForm;
|
||||
use Wechat\Wechat;
|
||||
|
||||
class ReportEditForm extends AdminModel
|
||||
{
|
||||
|
||||
public $store_id;
|
||||
|
||||
public $model;
|
||||
public $final_path;
|
||||
public $user_type;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['final_path'], 'string'],
|
||||
[['final_path'], 'required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'final_path' => '上传模型',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function edit()
|
||||
{
|
||||
if (!$this->validate()) {
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
if ($this->user_type == 1) {
|
||||
$this->model->initial_path = $this->final_path;
|
||||
} else {
|
||||
$this->model->final_path = $this->final_path;
|
||||
}
|
||||
|
||||
if (!$this->model->save()) {
|
||||
return $this->getModelError($this->model);
|
||||
}
|
||||
return $this->apiReturnSuccess('上传成功');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
123
modules/store/models/report/ReportListForm.php
Normal file
123
modules/store/models/report/ReportListForm.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\store\models\report;
|
||||
|
||||
use app\components\EncryptHelper;
|
||||
use app\components\Utils;
|
||||
use app\models\District;
|
||||
use app\models\Model;
|
||||
use app\models\Report;
|
||||
use app\models\Store;
|
||||
use app\models\StoreUser;
|
||||
use app\models\User;
|
||||
use app\modules\store\models\AdminModel;
|
||||
use app\models\common\CommonUserEditForm;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class ReportListForm extends AdminModel
|
||||
{
|
||||
public $page;
|
||||
public $limit;
|
||||
|
||||
public $keywords;
|
||||
public $status;
|
||||
public $store_id;
|
||||
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['keywords',], 'trim'],
|
||||
[['keywords',], 'string'],
|
||||
[['page', 'limit'], 'integer'],
|
||||
[['page'], 'default', 'value' => 1],
|
||||
[['limit'], 'default', 'value' => 20],
|
||||
];
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
if (!$this->validate()) {
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
$where = ['o.store_id' => $this->store_id];
|
||||
if (!empty($this->times)) {
|
||||
$explode = explode(' - ', $this->times);
|
||||
$where = [
|
||||
'and',
|
||||
['>=', 'o.created_at', strtotime($explode[0])],
|
||||
['<=', 'o.created_at', strtotime($explode[1])],
|
||||
];
|
||||
}
|
||||
|
||||
$query = Report::find()->alias('o')
|
||||
->select('o.id,o.model_number,o.initial_path,o.final_path,o.pdf_path,o.step,u.real_name,u.mobile_phone,s.name as store_name,o.created_at')
|
||||
->leftJoin(['u' => User::tableName()], 'o.user_id=u.id')
|
||||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||||
->where([
|
||||
|
||||
])->andWhere($where)
|
||||
->andFilterWhere([
|
||||
'OR',
|
||||
['like', 'u.mobile_phone', $this->keywords],
|
||||
['like', 'u.nickname', $this->keywords],
|
||||
['like', 'u.real_name', $this->keywords],
|
||||
]);
|
||||
|
||||
|
||||
$count = $query->count();
|
||||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
|
||||
foreach ($list as $index => $item) {
|
||||
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
||||
|
||||
$item['initial_path_ext'] = "";
|
||||
$item['initial_name'] = '';
|
||||
if (!empty($item['initial_path'])) {
|
||||
$item['initial_name'] = $item['model_number'] . '初始报告';
|
||||
$explode = explode('.', $item['initial_path']);
|
||||
$item['initial_path_ext'] = end($explode);
|
||||
}
|
||||
|
||||
$item['final_path_ext'] = '';
|
||||
$item['final_name'] = '';
|
||||
if (!empty($item['final_path'])) {
|
||||
$item['final_name'] = $item['model_number'] . '最终报告';
|
||||
$explode = explode('.', $item['final_path']);
|
||||
$item['final_path_ext'] = end($explode);
|
||||
}
|
||||
|
||||
|
||||
$item['pdf_path_ext'] = "";
|
||||
$item['pdf_name'] = '';
|
||||
if (!empty($item['pdf_path'])) {
|
||||
$item['pdf_name'] = $item['model_number'] . 'PDF报告';
|
||||
$explode = explode('.', $item['pdf_path']);
|
||||
$item['pdf_path_ext'] = end($explode);
|
||||
}
|
||||
|
||||
|
||||
$list[$index] = $item;
|
||||
}
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = 'ok';
|
||||
$data['data'] = $list;
|
||||
$data['count'] = $count;
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
247
modules/store/models/report/StoreActionForm.php
Normal file
247
modules/store/models/report/StoreActionForm.php
Normal file
@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
namespace app\modules\admin\models\store;
|
||||
use app\components\FlashStorage;
|
||||
use app\components\SiteHelper;
|
||||
use app\components\ZipFile;
|
||||
use app\models\auth\RoleUser;
|
||||
use app\models\Coach;
|
||||
use app\models\District;
|
||||
use app\models\Model;
|
||||
use app\models\Store;
|
||||
use app\models\StoreUser;
|
||||
use app\models\User;
|
||||
use app\models\Admin;
|
||||
use app\modules\admin\models\AdminModel;
|
||||
use app\models\common\CommonUserEditForm;
|
||||
use app\modules\api\models\StoreCityForm;
|
||||
|
||||
class StoreActionForm extends AdminModel
|
||||
{
|
||||
public $ids;
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['ids'], 'required'],
|
||||
[['ids'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'ids' => '选择项',
|
||||
];
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
$t = \Yii::$app->db->beginTransaction();
|
||||
|
||||
foreach ($this->ids as $item){
|
||||
$model = Store::findOne([
|
||||
'id' => $item,
|
||||
'is_delete' => 0
|
||||
]);
|
||||
if($model == null){
|
||||
return Model::asReturnError('该门店不存在或已被清理');
|
||||
}
|
||||
|
||||
if($model->is_delete == 1){
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->is_delete = 1;
|
||||
$model->deleted_at = time();
|
||||
if(!$model->save()){
|
||||
$t->rollBack();
|
||||
return Model::getModelErrorInfo($model);
|
||||
}
|
||||
Admin::updateAll(['is_delete' => 1],['is_delete' => 0, 'user_id' => $item]);
|
||||
// 删除数据表
|
||||
$redis_name = \Yii::$app->params['cacheKeyPrefix'].":api:store:zset";
|
||||
try{
|
||||
$res = \Yii::$app->redis->ZREM($redis_name,$model->id);
|
||||
}catch (\Exception $e){
|
||||
|
||||
}
|
||||
$exists = StoreUser::find()->where(['store_id' => $model->id, 'is_delete' => 0,])->exists();
|
||||
if($exists){
|
||||
$is_update = StoreUser::updateAll(['is_delete' => 1],['store_id' => $model->id, 'is_delete' => 0,]);
|
||||
if(!$is_update){
|
||||
$t->rollBack();
|
||||
return Model::asReturnError('清理门店操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$t->commit();
|
||||
// 删除城市缓存
|
||||
$obj = new StoreCityForm();
|
||||
$cache_name = $obj->getCacheName();
|
||||
FlashStorage::deleteCache($cache_name);
|
||||
return Model::asReturnSuccess('操作成功');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function status_yes()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
foreach ($this->ids as $item){
|
||||
$model = Store::findOne([
|
||||
'id' => $item,
|
||||
'is_delete' => 0,
|
||||
'status' => 0
|
||||
]);
|
||||
|
||||
if($model == null){
|
||||
return Model::asReturnError('该门店不存在或已被清理');
|
||||
}
|
||||
if($model->status == 1){
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->status = 1;
|
||||
$model->updated_at = time();
|
||||
if(!$model->save()){
|
||||
return Model::getModelErrorInfo($model);
|
||||
}
|
||||
}
|
||||
|
||||
return Model::asReturnSuccess('操作成功');
|
||||
}
|
||||
|
||||
public function status_no()
|
||||
{
|
||||
if(!$this->validate()){
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
foreach ($this->ids as $item){
|
||||
$model = Store::findOne([
|
||||
'id' => $item,
|
||||
'is_delete' => 0,
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
if($model == null){
|
||||
return Model::asReturnError('该门店不存在或已被清理');
|
||||
}
|
||||
|
||||
if($model->status == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
$model->status = 0;
|
||||
$model->updated_at = time();
|
||||
if(!$model->save()){
|
||||
return Model::getModelErrorInfo($model);
|
||||
}
|
||||
}
|
||||
|
||||
return Model::asReturnSuccess('操作成功');
|
||||
}
|
||||
|
||||
public function getStoreQrcode()
|
||||
{
|
||||
$store = Store::findOne($this->ids);
|
||||
if($store == null){
|
||||
return ['code' => 1,'msg' => '门店不存在'];
|
||||
}
|
||||
return $this->getQrcode($store);
|
||||
}
|
||||
|
||||
public function getQrcode($store)
|
||||
{
|
||||
$path = 'wxqrcode/store_qrcode';
|
||||
if(!is_dir($path)){
|
||||
mkdir($path,0777,true);
|
||||
}
|
||||
$body['page'] = 'pages/index/indexTwo';
|
||||
$body['scene'] = "store_id={$store->id}";
|
||||
$json_body = md5(json_encode($body));
|
||||
$path.='/'.$json_body.'.png';
|
||||
if(!file_exists($path)){
|
||||
$res = self::wxmpQrcode($body);
|
||||
if (json_encode($res) !== false) {
|
||||
$res = json_decode($res,true);
|
||||
return ['code' => 1,'msg' => $res['errmsg']];
|
||||
} else {
|
||||
$file = fopen($path, "w");//打开文件准备写入
|
||||
fwrite($file, $res);//写入,$res为图片二进制内容
|
||||
fclose($file);//关闭
|
||||
//图片是否存在
|
||||
if (!file_exists($path)) {
|
||||
return ['code' => 1,'msg' => '生成二维码失败'];
|
||||
} else {
|
||||
|
||||
return ['code' => 0,'msg' => 'ok','data' => SiteHelper::getFullUrl($path)];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return ['code' => 0,'msg' => 'ok','data' => SiteHelper::getFullUrl($path)];
|
||||
}
|
||||
}
|
||||
|
||||
//获取小程序二维码
|
||||
public function wxmpQrcode($body)
|
||||
{
|
||||
$plugin = new \app\models\common\PluginService();
|
||||
$wxmpService = $plugin->getWxmpService(0);
|
||||
$accessToken = $wxmpService->getAccessToken();
|
||||
if(empty($accessToken)){
|
||||
$accessToken = $wxmpService->getAccessToken(true);
|
||||
}
|
||||
$body = json_encode($body);
|
||||
return $wxmpService->Qrcode->getWxappQrcode($accessToken,$body);
|
||||
}
|
||||
|
||||
public function BatchQrcode()
|
||||
{
|
||||
$store = Store::find()->select('id,name')->where(['is_delete' => 0])->all();
|
||||
if($store == null){
|
||||
return ['code' => 1,'msg' => '门店不存在'];
|
||||
}
|
||||
|
||||
$path = 'wxqrcode/store_qrcode_zip';
|
||||
if(!is_dir($path)){
|
||||
mkdir($path,0777,true);
|
||||
}
|
||||
|
||||
$paths = [];
|
||||
foreach ($store as $value){
|
||||
$r = $this->getQrcode($value);
|
||||
if($r['code'] != 0){
|
||||
return $r['msg'];
|
||||
}
|
||||
array_push($paths,['name'=>$value->name.'.png','path' => $r['data']]);
|
||||
}
|
||||
|
||||
if(empty($paths)){
|
||||
return '无下载数据';
|
||||
}
|
||||
$zipName = '门店二维码_'.date('Y年m月d日').'下载' . '.zip'; // 压缩包文件名
|
||||
return (new ZipFile())->downloadZipImg($zipName,$path,$paths);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
159
modules/store/models/report/StoreEaringsListForm.php
Normal file
159
modules/store/models/report/StoreEaringsListForm.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\modules\admin\models\store;
|
||||
|
||||
use app\components\SysConst;
|
||||
use app\models\Order;
|
||||
use app\models\Store;
|
||||
use app\models\StoreEarnings;
|
||||
use app\models\User;
|
||||
use app\modules\admin\models\AdminModel;
|
||||
use yii\data\Pagination;
|
||||
|
||||
class StoreEaringsListForm extends AdminModel
|
||||
{
|
||||
public $page;
|
||||
public $limit;
|
||||
|
||||
public $keywords;
|
||||
public $status;
|
||||
public $store_id;
|
||||
|
||||
|
||||
public $start_time;
|
||||
public $end_time;
|
||||
|
||||
public $date;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['keywords',], 'trim'],
|
||||
[['keywords',], 'string'],
|
||||
[['start_time',], 'string'],
|
||||
[['end_time',], 'string'],
|
||||
[['date',], 'string'],
|
||||
[['page', 'limit', 'status', 'store_id'], 'integer'],
|
||||
[['page'], 'default', 'value' => 1],
|
||||
[['limit'], 'default', 'value' => 20],
|
||||
];
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
if (!$this->validate()) {
|
||||
return $this->getModelError();
|
||||
}
|
||||
|
||||
|
||||
$start_time = !empty($this->start_time) ? strtotime($this->start_time) : 0;
|
||||
$end_time = !empty($this->end_time) ? strtotime($this->end_time) : time();
|
||||
|
||||
$query = StoreEarnings::find()->alias('se')
|
||||
->select('se.id,se.money,u.nickname,s.name as store_name,o.order_no,se.created_at,o.total_price,o.plugin_sign')
|
||||
->leftJoin(['u' => User::tableName()], 'se.user_id=u.id')
|
||||
->leftJoin(['s' => Store::tableName()], 'se.store_id=s.id')
|
||||
->leftJoin(['o' => Order::tableName()], 'se.order_id=o.id')
|
||||
->where([
|
||||
'se.is_delete' => 0
|
||||
])
|
||||
->andFilterWhere(['se.status' => $this->status])
|
||||
->andFilterWhere(['se.store_id' => $this->store_id])
|
||||
->andWhere(['BETWEEN', 'se.created_at', $start_time, $end_time])
|
||||
->andFilterWhere([
|
||||
'OR',
|
||||
['like', 's.name', $this->keywords],
|
||||
['like', 'u.nickname', $this->keywords],
|
||||
['like', 'o.order_no', $this->keywords],
|
||||
]);
|
||||
$obj_data = clone $query;
|
||||
$admin_money = $obj_data->sum('total_price-money')??0;
|
||||
$count = $query->count();
|
||||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['se.created_at' => SORT_DESC])->asArray()->all();
|
||||
|
||||
|
||||
// $admin_money = 0;
|
||||
|
||||
foreach ($list as $index => $item) {
|
||||
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
||||
if ($item['money'] > 0) {
|
||||
if ($item['total_price'] != 0) {
|
||||
$num = $item['money'] / $item['total_price'];
|
||||
$num = $num * 100;
|
||||
$item['store_percentage'] = floor($num);
|
||||
} else {
|
||||
$item['store_percentage'] = 0;
|
||||
}
|
||||
$item['admin_money'] = $item['total_price'] - $item['money'];
|
||||
} else {
|
||||
$item['store_percentage'] = 0;
|
||||
$item['admin_money'] = $item['total_price'];
|
||||
}
|
||||
$list[$index] = $item;
|
||||
// $admin_money += $item['admin_money'];
|
||||
}
|
||||
|
||||
|
||||
$sum = StoreEarnings::find()->where(['between', 'created_at', $start_time, $end_time])->andWhere([
|
||||
'is_delete' => 0,
|
||||
])->andFilterWhere(['store_id' => $this->store_id])->sum('money')??0;
|
||||
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = 'ok';
|
||||
$data['data'] = $list;
|
||||
$data['count'] = $count;
|
||||
$data['store_money'] = round($sum,2);
|
||||
$data['admin_money'] = round($admin_money,2);
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getStoreList()
|
||||
{
|
||||
$time = time();
|
||||
$start_date = $time - 60 * 60 * 12;
|
||||
$end_date = $time;
|
||||
if (!empty($this->date)) {
|
||||
$explode = explode(' - ', $this->date);
|
||||
if (!empty($explode)) {
|
||||
$start_date = strtotime($explode[0]);
|
||||
$end_date = strtotime($explode[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = StoreEarnings::find()->alias('se')
|
||||
->select('se.id,sum(se.money) as store_money,s.name as store_name,,se.created_at,o.total_price')
|
||||
->leftJoin(['s' => Store::tableName()], 'se.store_id=s.id')
|
||||
->leftJoin(['o' => Order::tableName()], 'se.order_id=o.id')
|
||||
->where([
|
||||
'se.is_delete' => 0
|
||||
])
|
||||
->andFilterWhere(['se.store_id' => $this->store_id])
|
||||
->andWhere(['BETWEEN', 'se.created_at', 0, $end_date])
|
||||
->groupBy('se.store_id')
|
||||
->asArray()->all();
|
||||
|
||||
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = 'ok';
|
||||
$data['data']['store_name'] = array_column($query, 'store_name');
|
||||
$data['data']['store_money'] = array_column($query, 'store_money');
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
138
modules/store/views/report/edit.php
Normal file
138
modules/store/views/report/edit.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
use app\components\SiteHelper;
|
||||
use app\widgets\PickFile;
|
||||
|
||||
$layui_js_file = "/statics/layuiadmin/layui/layui.all.2.5.5.js?v=1.0.0";
|
||||
$this->registerJsFile($layui_js_file, ['depends' => 'app\modules\admin\assets\AppAsset']);
|
||||
|
||||
$this->title = '报告上传';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header"><?= $this->title ?></div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form">
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">姓名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="phone" placeholder="请输入客服电话" autocomplete="off" class="layui-input"
|
||||
value="<?= $user->real_name ?>" <?= !$model->isNewRecord ? 'disabled' : '' ?>
|
||||
lay-verify="required">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">模型编号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="phone" placeholder="请输入客服电话" autocomplete="off" class="layui-input"
|
||||
value="<?= $model->model_number ?>" <?= !$model->isNewRecord ? 'disabled' : '' ?>
|
||||
lay-verify="required">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'file',
|
||||
'id' => 'final_path_upload',
|
||||
'name' => 'final_path',
|
||||
'label' => $report_name,
|
||||
// 'value' => SiteHelper::getCustomiseOptionByKey("siteLogo","hump"),
|
||||
// 'tip' => '图片大小100px×100px'
|
||||
]) ?>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<div class="">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="admin-theme-customise">立即提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
layui.config({
|
||||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'user', 'upload'], function () {
|
||||
var $ = layui.$
|
||||
, setter = layui.setter
|
||||
, admin = layui.admin
|
||||
, form = layui.form
|
||||
, router = layui.router()
|
||||
, upload = layui.upload
|
||||
, search = router.search;
|
||||
|
||||
form.render();
|
||||
//提交
|
||||
var submitLock = false;
|
||||
form.on('submit(admin-theme-customise)', function (obj) {
|
||||
if (submitLock) {
|
||||
return false;
|
||||
}
|
||||
submitLock = true;
|
||||
//请求登入接口
|
||||
//console.log(obj)
|
||||
var url = '<?= \Yii::$app->urlManager->createUrl(["/store/report/edit", 'id' => $model->id ? $model->id : 0]) ?>';
|
||||
var returnUrl = "<?= \Yii::$app->urlManager->createUrl(["/store/report/index"]) ?>";
|
||||
var data = obj.field;
|
||||
data._csrf = _csrf;
|
||||
$.ajax(url, {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data,
|
||||
timeout: 10000,
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
}, function () {
|
||||
if (returnUrl) {
|
||||
location.href = returnUrl;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, type, err) {
|
||||
|
||||
},
|
||||
complete: function () {
|
||||
submitLock = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
<?php $this->endBlock(); ?>
|
||||
</script>
|
||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||
436
modules/store/views/report/index.php
Normal file
436
modules/store/views/report/index.php
Normal file
@ -0,0 +1,436 @@
|
||||
<?php
|
||||
|
||||
use app\models\Store;
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2021年6月30日
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
$this->title = '报告列表';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
.layui-table-cell {
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<?= $this->title ?>
|
||||
</div>
|
||||
<div class="layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<!--<a class=" layui-btn" href="<?= \Yii::$app->urlManager->createUrl(["store/feedback/edit"]) ?>">添加反馈</a>-->
|
||||
</div>
|
||||
<div class="layui-inline layui-float-right layui-form">
|
||||
|
||||
<!-- <div class="layui-inline layui-form-item">-->
|
||||
<!-- <div class="layui-input-inline">-->
|
||||
<!-- <select class="layui-select" name="status">-->
|
||||
<!-- <option value="" -->
|
||||
<? //=$status === null ? 'selected' : ''?><!--全部状态</option>
|
||||
<!-- --><?php //foreach ($status_labels as $key => $val):?>
|
||||
<!-- <option value="--><? //=$key?><!--" -->
|
||||
<? //=$status == $key && $status != null ? 'selected' : ''?><!--><? //=$val?><!--</option>-->
|
||||
<!-- --><?php //endforeach;?>
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<div class="layui-inline layui-form-item">
|
||||
<label class="layui-form-label">关键词</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keywords" placeholder="搜索姓名,手机号" autocomplete="off"
|
||||
class="layui-input"
|
||||
value="<?= \Yii::$app->request->get("keywords") ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">
|
||||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<table id="dtable" lay-filter="dtable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--工具栏模板-->
|
||||
<script type="text/html" id="toolBarTpl">
|
||||
<div class="layui-btn-container">
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="batch_status_yes">批量营业</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_status_no">批量停业</button>-->
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="batch_qrcode">打包二维码</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!--行操作列模板-->
|
||||
<script type="text/html" id="rowBarTpl">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">模型上传</button>
|
||||
|
||||
|
||||
{{# if(d.initial_path){ }}
|
||||
<a href="{{d.initial_path}}"
|
||||
download="{{d.initial_name}}.{{d.initial_path_ext}}">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="">下载初始模型</button>
|
||||
</a>
|
||||
{{# } }}
|
||||
|
||||
{{# if(d.final_path){ }}
|
||||
<a href="{{d.final_path}}"
|
||||
download="{{d.final_name}}.{{d.final_path_ext}}">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载最终模型</button>
|
||||
</a>
|
||||
{{# } }}
|
||||
|
||||
|
||||
{{# if(d.pdf_path){ }}
|
||||
<a href="{{d.pdf_path}}"
|
||||
download="{{d.pdf_name}}.{{d.pdf_path_ext}}">
|
||||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载PDF报告</button>
|
||||
</a>
|
||||
{{# } }}
|
||||
<!-- <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>-->
|
||||
</script>
|
||||
|
||||
|
||||
<!--<script type="text/html" id="statusTpl">-->
|
||||
<!-- {{# if(d.status == '0'){ }}-->
|
||||
<!-- <span class="layui-badge layui-bg-red">停业</span>-->
|
||||
<!-- {{# } else{ }}-->
|
||||
<!-- <span class="layui-badge layui-bg-blue">营业</span>-->
|
||||
<!-- {{# } }}-->
|
||||
<!--</script>-->
|
||||
|
||||
|
||||
<script>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
|
||||
|
||||
layui.config({
|
||||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'user', 'table', 'form'], function () {
|
||||
var $ = layui.$
|
||||
, form = layui.form
|
||||
, table = layui.table
|
||||
, admin = layui.admin;
|
||||
|
||||
|
||||
form.render();
|
||||
|
||||
//search
|
||||
form.on('submit(dtable-search)', function (obj) {
|
||||
var field = obj.field;
|
||||
reload_table_data(field);
|
||||
});
|
||||
|
||||
|
||||
//重新加载表格数据
|
||||
function reload_table_data(conf) {
|
||||
table.reload('dtable', {
|
||||
url: '<?=\Yii::$app->urlManager->createUrl(['store/report/index'])?>'
|
||||
, page: true
|
||||
, where: conf
|
||||
});
|
||||
};
|
||||
|
||||
//执行渲染
|
||||
table.render({
|
||||
//指定原始表格元素选择器(推荐id选择器)
|
||||
elem: '#dtable'
|
||||
//容器高度
|
||||
//,height: 315
|
||||
//容器宽度
|
||||
//,width: 720
|
||||
//设置表头
|
||||
, cols: [[
|
||||
{checkbox: true}
|
||||
, {field: 'id', title: 'ID', width: 80}
|
||||
, {field: 'real_name', title: '姓名', width: 100}
|
||||
, {field: 'mobile_phone', title: '电话', width: 120}
|
||||
, {field: 'store_name', title: '门店名称'}
|
||||
, {field: 'model_number', title: '模型编号'}
|
||||
, {field: 'initial_name', title: '初始模型'}
|
||||
, {field: 'final_name', title: '最终模型'}
|
||||
, {field: 'pdf_name', title: 'PDF报告'}
|
||||
// , {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
|
||||
, {field: 'created_at_cn', title: '创建时间', width: 150}
|
||||
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 400}
|
||||
]
|
||||
]
|
||||
, url: '<?=\Yii::$app->urlManager->createUrl(['store/report/index'])?>'
|
||||
, page: true
|
||||
//指向自定义工具栏模板选择器
|
||||
, toolbar: '#toolBarTpl'
|
||||
//头部工具栏右侧的图标按钮
|
||||
, defaultToolbar: []
|
||||
, limit: 20
|
||||
, limits: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
|
||||
, title: '<?=$this->title?>'
|
||||
, data: []
|
||||
, done: function (res, curr, count) {
|
||||
setTimeout(function () {
|
||||
$(".layui-table-main tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
$(".layui-table-header tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//监听工具条
|
||||
table.on('tool(dtable)', function (obj) {
|
||||
var row_data = obj.data;
|
||||
var lay_event = obj.event;
|
||||
var id = row_data.id;
|
||||
var confirm_url = null;
|
||||
var confirm_tip = null;
|
||||
var ids = [];
|
||||
ids.push(id);
|
||||
|
||||
if (lay_event == "delete") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/delete'])?>";
|
||||
confirm_tip = "确定删除此门店吗";
|
||||
}
|
||||
if (lay_event == "status_yes") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-yes'])?>";
|
||||
confirm_tip = "确定此门店变更为营业吗?";
|
||||
}
|
||||
if (lay_event == "status_no") {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-no'])?>";
|
||||
confirm_tip = "确定此门店变更为停业吗?";
|
||||
}
|
||||
//if (lay_event == "find_qrcode") {
|
||||
// confirm_url = "<?//=\Yii::$app->urlManager->createUrl(['store/report/edit'])?>//";
|
||||
// confirm_tip = "确定上传报告吗?";
|
||||
//}
|
||||
if (lay_event == 'edit') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/report/edit'])?>" + "?id=" + id;
|
||||
location.href = confirm_url;
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm_url != null) {
|
||||
layer.confirm(confirm_tip, {
|
||||
btn: ['确定', '取消']
|
||||
}, function (index) {
|
||||
layer.close(index)
|
||||
$.ajax(confirm_url, {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
ids: ids,
|
||||
_csrf: _csrf
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
if (lay_event == 'find_qrcode') {
|
||||
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
|
||||
//弹出层
|
||||
layer.open({
|
||||
type: 1,
|
||||
shade: 0,
|
||||
offset: 'auto',
|
||||
area: 'auth',
|
||||
shadeClose: true,
|
||||
scrollbar: false,
|
||||
title: "图片预览", //不显示标题
|
||||
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, type, err) {
|
||||
layer.msg(xhr.responseText, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
})
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//监听工具栏
|
||||
table.on('toolbar(dtable)', function (obj) {
|
||||
var lay_event = obj.event;
|
||||
var check_status = table.checkStatus('dtable');
|
||||
var ids = [];
|
||||
$(check_status.data).each(function (index) {
|
||||
ids.push(check_status.data[index]['id']);
|
||||
});
|
||||
if (lay_event == 'batch_qrcode') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/batch-qrcode'])?>";
|
||||
location.href = confirm_url;
|
||||
return;
|
||||
}
|
||||
if (ids.length == 0) {
|
||||
return layer.msg("请选择需要操作项");
|
||||
}
|
||||
|
||||
var confirm_url = null;
|
||||
var confirm_tip = null;
|
||||
if (lay_event == 'batch_delete') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/delete'])?>";
|
||||
confirm_tip = "确定将选中门店删除吗";
|
||||
}
|
||||
|
||||
if (lay_event == 'batch_status_yes') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-yes'])?>";
|
||||
confirm_tip = "确定将选中门店变更为营业吗";
|
||||
}
|
||||
if (lay_event == 'batch_status_no') {
|
||||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-no'])?>";
|
||||
confirm_tip = "确定将选中门店变更为停业吗";
|
||||
}
|
||||
|
||||
if (confirm_url != null) {
|
||||
layer.confirm(confirm_tip, {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.ajax(confirm_url, {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
ids: ids,
|
||||
_csrf: _csrf
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, type, err) {
|
||||
layer.msg(xhr.responseText, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
})
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
form.on('select(province)', function (res) {
|
||||
app.province_id = res.value;
|
||||
$(app.province).each(function (i) {
|
||||
if (app.province[i].id == app.province_id) {
|
||||
app.city = app.province_id != 0 ? app.province[i].list : [];
|
||||
//app.city_id = app.province_id != 0 ? app.province[i].list[0]['id'] : 0;
|
||||
app.area = app.province_id != 0 ? app.city[0].list : [];
|
||||
//app.area_id = app.province_id != 0 ? app.city[0].list[0]['id'] : 0;
|
||||
app.province_id = app.province_id == 0 ? '' : app.province_id;
|
||||
app.$forceUpdate();
|
||||
setTimeout(function () {
|
||||
form.render('select');
|
||||
}, 500);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
form.on('select(city)', function (res) {
|
||||
app.city_id = res.value;
|
||||
$(app.city).each(function (i) {
|
||||
if (app.city[i].id == app.city_id) {
|
||||
app.area = app.city[i].list;
|
||||
//app.area_id = app.city[i].list[0]['id'];
|
||||
app.$forceUpdate();
|
||||
setTimeout(function () {
|
||||
form.render('select');
|
||||
}, 500);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
form.on('select(area)', function (res) {
|
||||
app.area_id = res.value;
|
||||
setTimeout(function () {
|
||||
form.render('select');
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
function previewImg(obj) {
|
||||
var img = new Image();
|
||||
img.src = obj.src;
|
||||
var imgw = img.width;
|
||||
var imgh = img.height;
|
||||
var img_th = imgh / imgw * 500;
|
||||
var imgHtml = "<img src='" + obj.src + "' width='500px' height='" + img_th + "px'/>";
|
||||
//弹出层
|
||||
layer.open({
|
||||
type: 1,
|
||||
shade: 0.8,
|
||||
offset: 'auto',
|
||||
area: [500 + 'px', (img_th + 50) + 'px'],
|
||||
shadeClose: true,
|
||||
scrollbar: false,
|
||||
title: "图片预览", //不显示标题
|
||||
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||
cancel: function () {
|
||||
//layer.msg('捕获就是从页面已经存在的元素上,包裹layer的结构', { time: 5000, icon: 6 });
|
||||
}
|
||||
});
|
||||
}
|
||||
<?php $this->endBlock(); ?>
|
||||
</script>
|
||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||
|
||||
218
modules/store/views/theme/customise.php
Normal file
218
modules/store/views/theme/customise.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Any
|
||||
* @description KISS
|
||||
* @date 2020-11-5
|
||||
* @version 1.0.0
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
use app\components\SiteHelper;
|
||||
use app\widgets\PickFile;
|
||||
$layui_js_file = "/statics/layuiadmin/layui/layui.all.2.5.5.js?v=1.0.0";
|
||||
$this->registerJsFile($layui_js_file, ['depends' => 'app\modules\admin\assets\AppAsset']);
|
||||
|
||||
$this->title = '网站设置';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header"><?= $this->title ?></div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">站点名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteName" placeholder="请输入站点名称" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteName", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">站点简称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteShortName" placeholder="请输入站点简称" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteShortName", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">站点域名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteDomain" placeholder="请输入站点域名" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteDomain", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">移动站点域名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteWapDomain" placeholder="请输入移动站点域名" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteWapDomain", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">站点简介</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteBriefIntro" placeholder="请输入站点简介" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteBriefIntro", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">站点描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="siteDescription" placeholder="请输入站点描述" class="layui-textarea"><?= SiteHelper::getCustomiseOptionByKey("siteDescription", "hump") ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">站点关键词</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="siteKeywords" placeholder="请输入站点关键词" class="layui-textarea"><?= SiteHelper::getCustomiseOptionByKey("siteKeywords", "hump") ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'images',
|
||||
'id' => 'site_logo_upload',
|
||||
'name' => 'siteLogo',
|
||||
'label' => '站点Logo',
|
||||
'value' => SiteHelper::getCustomiseOptionByKey("siteLogo","hump"),
|
||||
'tip' => '图片大小100px×100px'
|
||||
])?>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'images',
|
||||
'id' => 'site_mini_logo_upload',
|
||||
'name' => 'siteMiniLogo',
|
||||
'label' => '站点正方形Logo',
|
||||
'value' => SiteHelper::getCustomiseOptionByKey("siteMiniLogo","hump"),
|
||||
'tip' => '图片大小100px×100px'
|
||||
])?>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'images',
|
||||
'id' => 'site_ico_upload',
|
||||
'name' => 'siteIco',
|
||||
'label' => '站点favicon.ico',
|
||||
'value' => SiteHelper::getCustomiseOptionByKey("siteIco","hump"),
|
||||
'tip' => '图片大小100px×100px',
|
||||
])?>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">ICP备案号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteIcp" placeholder="请输入ICP备案号" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteIcp", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系电话</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteTel" placeholder="请输入联系电话" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteTel", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系地址</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteAddress" placeholder="请输入联系地址" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteAddress", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系邮箱</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="siteEmail" placeholder="请输入联系邮箱" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("siteEmail", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系邮编</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="sitePostcode" placeholder="请输入联系邮编" autocomplete="off" class="layui-input" value="<?= SiteHelper::getCustomiseOptionByKey("sitePostcode", "hump") ?>">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">公司介绍</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="siteCompanyIntro" placeholder="请输入公司介绍" class="layui-textarea"><?= SiteHelper::getCustomiseOptionByKey("siteCompanyIntro", "hump") ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<div class="" >
|
||||
<button class="layui-btn" lay-submit="" lay-filter="admin-theme-customise">立即提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
layui.config({
|
||||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'user', 'upload'], function () {
|
||||
var $ = layui.$
|
||||
, setter = layui.setter
|
||||
, admin = layui.admin
|
||||
, form = layui.form
|
||||
, router = layui.router()
|
||||
,upload = layui.upload
|
||||
, search = router.search;
|
||||
|
||||
form.render();
|
||||
//提交
|
||||
var submitLock = false;
|
||||
form.on('submit(admin-theme-customise)', function (obj) {
|
||||
if (submitLock) {
|
||||
return false;
|
||||
}
|
||||
submitLock = true;
|
||||
//请求登入接口
|
||||
//console.log(obj)
|
||||
var url = '<?= \Yii::$app->urlManager->createUrl(["/admin/theme/customise"]) ?>';
|
||||
var returnUrl = "<?= \Yii::$app->request->get('return_url') ?>";
|
||||
var data = obj.field;
|
||||
data._csrf = _csrf;
|
||||
$.ajax(url, {
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data,
|
||||
timeout: 10000,
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
}, function () {
|
||||
if (returnUrl) {
|
||||
location.href = returnUrl;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 2
|
||||
, time: 1000
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, type, err) {
|
||||
|
||||
},
|
||||
complete: function () {
|
||||
submitLock = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
<?php $this->endBlock(); ?>
|
||||
</script>
|
||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
351
runtime/debug/6538d7e888223.data
Normal file
351
runtime/debug/6538d7e888223.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538d83b2268c.data
Normal file
211
runtime/debug/6538d83b2268c.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d83b6cd57.data
Normal file
281
runtime/debug/6538d83b6cd57.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d83cbde8b.data
Normal file
281
runtime/debug/6538d83cbde8b.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d84b9ca59.data
Normal file
281
runtime/debug/6538d84b9ca59.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538d84fbd4e3.data
Normal file
211
runtime/debug/6538d84fbd4e3.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538d8508df1a.data
Normal file
211
runtime/debug/6538d8508df1a.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d850dbd99.data
Normal file
281
runtime/debug/6538d850dbd99.data
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
421
runtime/debug/6538d877563b1.data
Normal file
421
runtime/debug/6538d877563b1.data
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
351
runtime/debug/6538d881427a5.data
Normal file
351
runtime/debug/6538d881427a5.data
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
351
runtime/debug/6538d8882ec54.data
Normal file
351
runtime/debug/6538d8882ec54.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538d8bf4676b.data
Normal file
211
runtime/debug/6538d8bf4676b.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d8bf98840.data
Normal file
281
runtime/debug/6538d8bf98840.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d8ea40195.data
Normal file
281
runtime/debug/6538d8ea40195.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538d8f62d0b4.data
Normal file
211
runtime/debug/6538d8f62d0b4.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538d8f67a715.data
Normal file
281
runtime/debug/6538d8f67a715.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538dace2b541.data
Normal file
211
runtime/debug/6538dace2b541.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538dace7faf2.data
Normal file
281
runtime/debug/6538dace7faf2.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538dae766203.data
Normal file
211
runtime/debug/6538dae766203.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538dae7b57f8.data
Normal file
281
runtime/debug/6538dae7b57f8.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538daec469a1.data
Normal file
211
runtime/debug/6538daec469a1.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538daec8b599.data
Normal file
281
runtime/debug/6538daec8b599.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538daee4b0b9.data
Normal file
211
runtime/debug/6538daee4b0b9.data
Normal file
File diff suppressed because one or more lines are too long
12
runtime/debug/6538daee97e13.data
Normal file
12
runtime/debug/6538daee97e13.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538daeea51db.data
Normal file
281
runtime/debug/6538daeea51db.data
Normal file
File diff suppressed because one or more lines are too long
211
runtime/debug/6538db0176b29.data
Normal file
211
runtime/debug/6538db0176b29.data
Normal file
File diff suppressed because one or more lines are too long
281
runtime/debug/6538db01b6074.data
Normal file
281
runtime/debug/6538db01b6074.data
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user