edit修改相关内容

This commit is contained in:
admin 2023-11-22 11:17:56 +08:00
parent a3589dab7d
commit 40ef83d9b4
129 changed files with 14589 additions and 10596 deletions

View File

@ -29,9 +29,61 @@ class HelloController extends Controller
/** /**
* This command echoes what you have entered as the message. * This command echoes what you have entered as the message.
* @param string $message the message to be echoed. * @param string $message the message to be echoed.
* @return int Exit code
*/ */
public function actionIndex($message = 'hello world') public function actionIndex($message = 'hello world')
{
$appkey = "9d4c0b68-4d39-4964-9cd3-c54acc4e74ec";
$url = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
$arr = [
'RequestData' => [
'ShipperCode' => 'YD',
'LogisticCode' => '433575600989933',
],
'DataType' => 2,
'EBusinessID' => '1816614',
'RequestType' => '8002',
];
$arr['DataSign'] = base64_encode(strtolower(md5(json_encode($arr['RequestData']).$appkey)));
$arr['RequestData'] = json_encode($arr['RequestData']);
$res = $this->send_post($url,($arr));
var_dump($res);
var_dump($arr);
}
function send_post($url, $post_data) {
$postdata = http_build_query($post_data);
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
function request_by_curl($remote_server, $post_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $remote_server);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'mypost=' . $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "jb51.net's CURL Example beta");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
/**
* This command echoes what you have entered as the message.
* @param string $message the message to be echoed.
* @return int Exit code
*/
public function actionIndexs($message = 'hello world')
{ {
$query = BallCart::find()->alias('ball') $query = BallCart::find()->alias('ball')
->leftJoin(['store' => Store::tableName()], 'ball.store_id=store.id') ->leftJoin(['store' => Store::tableName()], 'ball.store_id=store.id')

View File

@ -6,9 +6,12 @@ return [
// 'username' => 'cxaibc', // 'username' => 'cxaibc',
// 'password' => 'tm2CtPfmRXSif6mn', // 'password' => 'tm2CtPfmRXSif6mn',
'dsn' => 'mysql:host=app.3dxh.dev.1nww.com;dbname=cxfoot', /*'dsn' => 'mysql:host=app.3dxh.dev.1nww.com;dbname=cxfoot',
'username' => 'cxfoot', 'username' => 'cxfoot',
'password' => 'bm8kB3eKddhCW83s', 'password' => 'bm8kB3eKddhCW83s',*/
'dsn' => 'mysql:host=127.0.0.1;dbname=cxfoot',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',

View File

@ -30,11 +30,18 @@ class SiteController extends Controller
public function actionIndex() public function actionIndex()
{ {
$code = $this->request->get('code'); $code = $this->request->get('code');
$url = "https://app.3dxh.h5.dev.1nww.com/#/White?code={$code}"; $state = $this->request->get('state');
$to_state = "";
if(!empty($state)){
$explode = explode('_',$state);
if(!empty($explode) && count($explode) >= 2){
$to_state = "&dev_id={$explode[0]}&store_id={$explode[1]}";
}
}
$url = "https://app.3dxh.h5.dev.1nww.com/#/White?code={$code}{$to_state}";
// echo $url;
// exit();
return $this->redirect($url); return $this->redirect($url);
echo($code);
exit();
return $this->render('index');
} }
} }

View File

@ -0,0 +1,202 @@
<?php
/**
* @author Any
* @description KISS
* @date 2021年6月2日
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\controllers;
use app\models\Dev;
use app\models\wechat\WechatApp;
use app\modules\api\behaviors\LoginBehavior;
use app\models\common\CommonAddressActionForm;
use app\models\common\CommonAddressListForm;
use app\models\common\CommonAddressEditForm;
use app\models\Address;
use app\modules\api\models\WindowsApiForm;
use Wechat\Wechat;
class WechatController extends Controller
{
public $_cx_token_type;
public $enableCsrfValidation = false;
public function behaviors()
{
return array_merge(parent::behaviors(), [
/*'login' => [
'class' => LoginBehavior::className(),
'ignore' => [
'wechat/index',
]
]*/
]);
}
private $_msg_template = array(
'text' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[%s]]></Content></xml>',//文本回复XML模板
'image' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[image]]></MsgType><Image><MediaId><![CDATA[%s]]></MediaId></Image></xml>',//图片回复XML模板
'music' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[music]]></MsgType><Music><Title><![CDATA[%s]]></Title><Description><![CDATA[%s]]></Description><MusicUrl><![CDATA[%s]]></MusicUrl><HQMusicUrl><![CDATA[%s]]></HQMusicUrl><ThumbMediaId><![CDATA[%s]]></ThumbMediaId></Music></xml>',//音乐模板
'news' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[news]]></MsgType><ArticleCount>%s</ArticleCount><Articles>%s</Articles></xml>',// 新闻主体
'news_item' => '<item><Title><![CDATA[%s]]></Title><Description><![CDATA[%s]]></Description><PicUrl><![CDATA[%s]]></PicUrl><Url><![CDATA[%s]]></Url></item>',//某个新闻模板
);
/**
* @微信入口
*/
public function actionIndex(){
if(!empty($_GET["signature"]) && !empty($_GET['echostr'])){
return $this->checkSignature();
}
return $this->responseMsg();
}
private function checkSignature()
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = "3dxh";
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
return $_GET['echostr'];
}else{
return false;
}
}
public function responseMsg(){
$xml_str = file_get_contents("php://input");
/*
获得请求时POST:XML字符串
不能用$_POST获取因为没有key
*/
\Yii::info("进入",'wxpay');
$msg = "";
if(!empty($xml_str)){
// 解析该xml字符串利用simpleXML
// libxml_disable_entity_loader(true);
//禁止xml实体解析防止xml注入
$request_xml = simplexml_load_string($xml_str, 'SimpleXMLElement', LIBXML_NOCDATA);
\Yii::info(json_encode($request_xml),'wxpay');
// $msg = sprintf($this->_msg_template['text'], $request_xml->FromUserName, $request_xml->ToUserName, time(), );
\Yii::info($msg,'wxpay');
//判断该消息的类型通过元素MsgType
switch ($request_xml->MsgType){
case 'event':
//判断具体的时间类型(关注、取消、点击)
$event = $request_xml->Event;
if ($event=='subscribe') { // 关注事件
// $this->_doSubscribe($request_xml);
}elseif ($event=='CLICK') {//菜单点击事件
// $this->_doClick($request_xml);
}elseif ($event=='VIEW') {//连接跳转事件
// $this->_doView($request_xml);
}elseif ($event=='SCAN') {
$id = $request_xml->EventKey;
// 查找数据,并发送文本
$find = Dev::findOne([
'id' => $id,
]);
if(empty($find)){
return false;
}
$wechat_mp = "";
$wechat_app = WechatApp::findOne([
'cx_mch_id' => 0,
'is_delete' => 0
]);
if($wechat_app){
if (!is_dir(\Yii::$app->runtimePath . '/pem')) {
mkdir(\Yii::$app->runtimePath . '/pem');
file_put_contents(\Yii::$app->runtimePath . '/pem/index.html', '');
}
$cert_pem_file = null;
if ($wechat_app->cert_pem) {
$cert_pem_file = \Yii::$app->runtimePath . '/pem/' . md5($wechat_app->cert_pem);
if (!file_exists($cert_pem_file))
file_put_contents($cert_pem_file, $wechat_app->cert_pem);
}
$key_pem_file = null;
if ($wechat_app->key_pem) {
$key_pem_file = \Yii::$app->runtimePath . '/pem/' . md5($wechat_app->key_pem);
if (!file_exists($key_pem_file))
file_put_contents($key_pem_file, $wechat_app->key_pem);
}
$wechat_mp = new Wechat([
'appId' => $wechat_app->app_id,
'appSecret' => $wechat_app->app_secret,
'mchId' => $wechat_app->mch_id,
'apiKey' => $wechat_app->key,
'certPem' => $cert_pem_file,
'keyPem' => $key_pem_file,
]);
// 推送客服消息
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".$wechat_mp->getAccessToken();
$to_url = urlencode(\Yii::$app->request->getHostInfo()."/site");
$state = $find->id."_".$find->store_id;
$res_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$wechat_app->app_id}&redirect_uri={$to_url}&response_type=code&scope=snsapi_userinfo&state={$state}#wechat_redirect";
try{
$to_user = reset($request_xml->FromUserName);
}catch (\Exception $e){
$to_user = $request_xml->FromUserName;
}
$arr = [
'touser' => $to_user,
'msgtype' => 'news',
'news' => [
'articles' => [
[
'title' => '333',
'description' => '23432432',
'url' => $res_url,
'picurl' => \Yii::$app->request->getHostInfo().'/upload/0/1/upload/image/2023/1026/1698312821606159.jpg',
]
],
],
];
$res = $wechat_mp->curl->post($url,json_encode($arr));
\Yii::info(json_encode($res),'wxpay');
\Yii::info(json_encode($arr).$request_xml->FromUserName,'wxpay');
}
$text = "欢迎来到英舒迪公众号";
$msg = sprintf($this->_msg_template['text'], $request_xml->FromUserName, $request_xml->ToUserName, time(),$text);
}else{
}
break;
case 'text'://文本消息
// $this->_doText($request_xml);
break;
case 'image'://图片消息
// $this->_doImage($request_xml);
break;
case 'voice'://语音消息
// $this->_doVoice($request_xml);
break;
case 'video'://视频消息
// $this->_doVideo($request_xml);
break;
case 'shortvideo'://短视频消息
// $this->_doShortvideo($request_xml);
break;
case 'location'://位置消息
// $this->_doLocation($request_xml);
break;
case 'link'://链接消息
// $this->_doLink($request_xml);
break;
}
}
return $msg;
}
}

View File

@ -0,0 +1,2 @@
1700535696
s:136:"74_KmyxOVSr9WvpDlklucVAGhhN7X3q59Cmv3-Ovx4wqp9ShpMuGqrDkXrO_1d1ePJ95GnkNPVz8WmFvqC2ko9MvH8VSsiJBp4yebHlhMV9ky5_AkQKw42MxF3pZtISZVhAIAHOK";

View File

@ -44,6 +44,9 @@ use Gumlet\ImageResizeException;
* @property int $updated_at 更新时间 * @property int $updated_at 更新时间
* @property int $type 0=用户1=管理员 * @property int $type 0=用户1=管理员
* @property int $is_view 是否有观看视频 * @property int $is_view 是否有观看视频
* @property int $age 年龄
* @property int $height 身高
* @property int $weight 体重
*/ */
class User extends \yii\db\ActiveRecord implements IdentityInterface class User extends \yii\db\ActiveRecord implements IdentityInterface
{ {
@ -85,7 +88,7 @@ class User extends \yii\db\ActiveRecord implements IdentityInterface
public function rules() public function rules()
{ {
return [ return [
[['username', 'password', 'auth_key', 'access_token', 'nickname', 'email', 'real_name', 'avatar_url', 'mobile_phone', 'mobile_prefix'], 'trim'], [['username', 'password', 'auth_key', 'access_token', 'nickname', 'email', 'real_name', 'avatar_url', 'mobile_phone', 'mobile_prefix','age','height','weight'], 'trim'],
[['cx_mch_id', 'gender', 'status', 'parent_id', 'is_modify_un', 'is_delete', 'country_id', 'city_id', 'created_at', 'updated_at', 'type'], 'integer'], [['cx_mch_id', 'gender', 'status', 'parent_id', 'is_modify_un', 'is_delete', 'country_id', 'city_id', 'created_at', 'updated_at', 'type'], 'integer'],
[['username', 'password', 'auth_key', 'access_token', 'nickname', 'avatar_url'], 'required'], [['username', 'password', 'auth_key', 'access_token', 'nickname', 'avatar_url'], 'required'],
[['birthday'], 'safe'], [['birthday'], 'safe'],

View File

@ -38,7 +38,8 @@ class RecordController extends Controller
'login' => [ 'login' => [
'class' => LoginBehavior::className(), 'class' => LoginBehavior::className(),
'ignore' => [ 'ignore' => [
'api/record/index' 'api/record/index',
'api/record/get-info'
] ]
] ]
]); ]);
@ -116,4 +117,5 @@ class RecordController extends Controller
$data = $recordForm->getMoneySum($date); $data = $recordForm->getMoneySum($date);
return $this->responseHandler($data); return $this->responseHandler($data);
} }
} }

View File

@ -19,6 +19,7 @@ use app\models\common\cms\CommonNoticeActionForm;
use app\models\common\cms\CommonNoticeListForm; use app\models\common\cms\CommonNoticeListForm;
use app\models\cms\Notice; use app\models\cms\Notice;
use app\components\SysErrCode; use app\components\SysErrCode;
use app\modules\api\models\RecordForm;
use app\modules\api\models\ReportForm; use app\modules\api\models\ReportForm;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
@ -65,6 +66,25 @@ class ReportController extends Controller
$data = $form->search(); $data = $form->search();
return $this->responseHandler($data); return $this->responseHandler($data);
} }
/**
* showdoc
* @catalog 数据列表
* @title 获取详情
* @description 数据列表-获取详情
* @method get
* @url /api/report/get-info
* @param /id 数据id
* @remark
*/
public function actionGetInfo(){
$recordForm = new ReportForm();
$recordForm->cx_mch_id = $this->cx_mch_id;
$recordForm->id = \Yii::$app->request->get('id');
$data = $recordForm->actionGetInfo();
return $this->responseHandler($data);
}
} }

View File

@ -83,12 +83,16 @@ class UserController extends Controller
return $this->responseHandler($data); return $this->responseHandler($data);
} }
/** /**
* showdoc * showdoc
* @catalog 会员注册 * @catalog 会员注册
* @method post * @method post
* @url /api/user/modify-user * @url /api/user/modify-user
* @param /weight 必填 体重
* @param /height 必填 身高
* @param /age 必填 年龄
* @param /gender 必填 男女
* @param /mobile_phone 必填 手机号
* @return {"code":0,"msg":"ok","data":{}} * @return {"code":0,"msg":"ok","data":{}}
* @remark * @remark
*/ */

View File

@ -0,0 +1,118 @@
<?php
/**
* @author Any
* @description KISS
* @date 2021年6月2日
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\api\controllers;
use app\modules\api\behaviors\LoginBehavior;
use app\models\common\CommonAddressActionForm;
use app\models\common\CommonAddressListForm;
use app\models\common\CommonAddressEditForm;
use app\models\Address;
use app\modules\api\models\WindowsApiForm;
class WechatController extends Controller
{
private $_msg_template = array(
'text' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[%s]]></Content></xml>',//文本回复XML模板
'image' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[image]]></MsgType><Image><MediaId><![CDATA[%s]]></MediaId></Image></xml>',//图片回复XML模板
'music' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[music]]></MsgType><Music><Title><![CDATA[%s]]></Title><Description><![CDATA[%s]]></Description><MusicUrl><![CDATA[%s]]></MusicUrl><HQMusicUrl><![CDATA[%s]]></HQMusicUrl><ThumbMediaId><![CDATA[%s]]></ThumbMediaId></Music></xml>',//音乐模板
'news' => '<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName><CreateTime>%s</CreateTime><MsgType><![CDATA[news]]></MsgType><ArticleCount>%s</ArticleCount><Articles>%s</Articles></xml>',// 新闻主体
'news_item' => '<item><Title><![CDATA[%s]]></Title><Description><![CDATA[%s]]></Description><PicUrl><![CDATA[%s]]></PicUrl><Url><![CDATA[%s]]></Url></item>',//某个新闻模板
);
/**
* @微信入口
*/
public function actionIndex(){
/*if(!empty($_GET["signature"]) && !empty($_GET['echostr'])){
return $this->checkSignature();
}*/
return $this->responseMsg();
}
private function checkSignature()
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = "3dxh";
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
return $_GET['echostr'];
}else{
return false;
}
}
public function responseMsg(){
$xml_str = file_get_contents("php://input");
/*
获得请求时POST:XML字符串
不能用$_POST获取因为没有key
*/
\Yii::info("进入",'wxpay');
$msg = "";
if(!empty($xml_str)){
// 解析该xml字符串利用simpleXML
// libxml_disable_entity_loader(true);
//禁止xml实体解析防止xml注入
$request_xml = simplexml_load_string($xml_str, 'SimpleXMLElement', LIBXML_NOCDATA);
\Yii::info($request_xml->MsgType,'wxpay');
$msg = sprintf($this->_msg_template['text'], $request_xml->ToUserName, $request_xml->FromUserName, time(), "333");
echo $msg;
exit();
//判断该消息的类型通过元素MsgType
switch ($request_xml->MsgType){
case 'event':
//判断具体的时间类型(关注、取消、点击)
$event = $request_xml->Event;
if ($event=='subscribe') { // 关注事件
// $this->_doSubscribe($request_xml);
}elseif ($event=='CLICK') {//菜单点击事件
// $this->_doClick($request_xml);
}elseif ($event=='VIEW') {//连接跳转事件
// $this->_doView($request_xml);
}else{
}
break;
case 'text'://文本消息
// $this->_doText($request_xml);
break;
case 'image'://图片消息
// $this->_doImage($request_xml);
break;
case 'voice'://语音消息
// $this->_doVoice($request_xml);
break;
case 'video'://视频消息
// $this->_doVideo($request_xml);
break;
case 'shortvideo'://短视频消息
// $this->_doShortvideo($request_xml);
break;
case 'location'://位置消息
// $this->_doLocation($request_xml);
break;
case 'link'://链接消息
// $this->_doLink($request_xml);
break;
}
}
return $msg;
}
}

View File

@ -61,30 +61,28 @@ class LoginByWxoaForm extends ApiModel
} }
$access_token = $res['data']['access_token']; $access_token = $res['data']['access_token'];
$openid = $res['data']['openid']; $openid = $res['data']['openid']??'';
//用户是否存在 $user_oauth = UserOauth::findOne([
$user_oauth = null; 'cx_mch_id' => $this->cx_mch_id,
if ($openid != 0) { 'is_delete' => 0,
//优选使用unionid 'openid' => $openid
$user_oauth = UserOauth::findOne([ ]);
'cx_mch_id' => $this->cx_mch_id,
'is_delete' => 0, if (empty($user_oauth)) {
'openid' => $openid
]);
}
if ($user_oauth == null) {
$user_oauth = new UserOauth(); $user_oauth = new UserOauth();
$user_oauth->cx_mch_id = 0; $user_oauth->cx_mch_id = 0;
$user_oauth->type = 'wxoa'; $user_oauth->type = 'wxoa';
$user_oauth->openid = $openid; $user_oauth->openid = $openid;
$user_oauth->created_at = time(); $user_oauth->created_at = time();
$user_oauth->user_id = 0;
$user_oauth->is_delete = 0;
$res = $user_oauth->save(); $res = $user_oauth->save();
if ($res['code'] != 0) { if (!$res) {
return ['code' => 1, 'msg' => '登陆失败']; return ['code' => 1, 'msg' => '登陆失败'];
} }
} }
$data = ['code' => 0, 'msg' => '登陆成功', 'data' => $openid]; $data = ['code' => 0, 'msg' => '登陆成功', 'openid' => $openid];
return $data; return $data;
} }

View File

@ -12,6 +12,7 @@
namespace app\modules\api\models; namespace app\modules\api\models;
use app\models\Report;
use function AlibabaCloud\Client\value; use function AlibabaCloud\Client\value;
use app\components\FlashStorage; use app\components\FlashStorage;
use app\components\SiteHelper; use app\components\SiteHelper;
@ -45,6 +46,8 @@ class RecordForm extends ApiModel
//门店管理员-2 总部管理员-8 BOSS管理员-7 //门店管理员-2 总部管理员-8 BOSS管理员-7
public $type = [2, 7, 8]; public $type = [2, 7, 8];
public $id;
public function rules() public function rules()
{ {
return [ return [
@ -227,4 +230,6 @@ class RecordForm extends ApiModel
$record = $create->queryAll(); $record = $create->queryAll();
return $record; return $record;
} }
} }

View File

@ -109,5 +109,39 @@ class ReportForm extends ApiModel
]; ];
} }
/**
* @catalog 数据列表
* @title 获取详情
* @description 数据列表-获取详情
*/
public function actionGetInfo(){
if(empty($id)){
return $this->apiReturnError('请求错误');
}
$find = Report::findOne([
'id' => $this->id,
]);
if(empty($find)){
return $this->apiReturnError('暂无数据');
}
if(intval($find->step) !== 3){
return $this->apiReturnError('暂未生成结果');
}
$json_de = [];
if(!empty($find->json)){
$json_de = json_decode($find->json,true);
}
$res = $json_de??[];
$find_store = Store::findOne([
'id' => $find->store_id,
]);
$res['store'] = [
'id' => $find->store_id,
'name' => $find_store->name??'暂无门店',
];
$res['created_date'] = date('Y-m-d H:i:s',$find->created_at);
return $this->apiReturnSuccess('ok',$res);
}
} }

View File

@ -36,16 +36,19 @@ class UserModifyForm extends ApiModel
public $is_view; public $is_view;
public $openid; public $openid;
public $token_type; public $token_type;
public $age;
public $height;
public $weight;
public function rules() public function rules()
{ {
return [ return [
[['openid'], 'string'], [['openid','age','height','weight'], 'string'],
[['real_name'], 'required'], [['real_name'], 'required'],
[['gender'], 'required'], [['gender'], 'required'],
[['is_view'], 'required'], // [['is_view'], 'required'],
[['mobile_phone'], 'required'], [['mobile_phone'], 'required'],
[['mobile_phone'], 'filter', 'filter' => 'trim'], [['mobile_phone'], 'filter', 'filter' => 'trim'],
[['mobile_phone'], 'match', 'pattern' => '/^[1][34578][0-9]{9}$/'], [['mobile_phone'], 'match', 'pattern' => '/^[1][34578][0-9]{9}$/'],
@ -75,40 +78,55 @@ class UserModifyForm extends ApiModel
$form = new LoginForm(); $form = new LoginForm();
//有绑定信息 去登陆 //有绑定信息 去登陆
$user = User::findOne(['mobile_phone' => $this->mobile_phone]); /*$user = User::findOne(['mobile_phone' => $this->mobile_phone]);
if (!empty($user->mobile_phone) && !empty($user->is_view)) { if (!empty($user->mobile_phone)) {
$form = new LoginForm(); $form = new LoginForm();
$form->cx_mch_id = 0; $form->cx_mch_id = 0;
$form->username = $user->username; $form->username = $user->username;
$form->password = '123456'; $form->password = '123456';
$form->token_type = 3; $form->token_type = 3;
return $form->login($user); return $form->login($user);
} }*/
//没有信息 去绑定 //没有信息 去绑定
$t = \Yii::$app->db->beginTransaction(); $t = \Yii::$app->db->beginTransaction();
try { try {
$username = User::generateUsername(); $username = User::generateUsername();
$password = '123456'; $password = '123456';
$password_encryption = \Yii::$app->security->generatePasswordHash($password); $password_encryption = \Yii::$app->security->generatePasswordHash($password);
$user = User::findOne(['mobile_phone' => $this->mobile_phone]);
if(empty($user)){
$user = new User();
$user->cx_mch_id = 0;
$user->real_name = $this->real_name;
$user->mobile_phone = $this->mobile_phone;
$user->gender = $this->gender;
$user->is_view = $this->is_view;
$user->mobile_prefix = '86';
$user->nickname = $this->real_name;
$user->avatar_url = User::DEFAULT_AVATAR_URL;
$user->access_token = \Yii::$app->security->generateRandomString();
$user->type = User::TYPE_USER;
$user->username = $username;
$user->password = $password_encryption;
$user->auth_key = \Yii::$app->security->generateRandomString();
$user->age = $this->age;
$user->height = $this->height;
$user->weight = $this->weight;
$res = $user->save();
if (!$res) {
$t->rollBack();
return $this->getModelError($user);
}
}else{
$user->updated_at = time();
$user->age = $this->age;
$user->height = $this->height;
$user->weight = $this->weight;
$user->save();
}
$user = new User();
$user->cx_mch_id = 0;
$user->real_name = $this->real_name;
$user->mobile_phone = $this->mobile_phone;
$user->gender = $this->gender;
$user->is_view = $this->is_view;
$user->mobile_prefix = '86';
$user->nickname = $this->real_name;
$user->avatar_url = User::DEFAULT_AVATAR_URL;
$user->access_token = \Yii::$app->security->generateRandomString();
$user->type = User::TYPE_USER;
$user->username = $username;
$user->password = $password_encryption;
$user->auth_key = \Yii::$app->security->generateRandomString();;
$res = $user->save();
if ($this->openid) { if ($this->openid) {
$user_outh = UserOauth::findOne(['openid' => $this->openid]); $user_outh = UserOauth::findOne(['openid' => $this->openid]);
@ -116,7 +134,7 @@ class UserModifyForm extends ApiModel
$t->rollBack(); $t->rollBack();
return ['code' => 1, 'msg' => '请重新进行微信授权',]; return ['code' => 1, 'msg' => '请重新进行微信授权',];
} }
if ($user_outh->user_id == 0) { if (empty($user_outh->user_id)) {
$user_outh->user_id = $user->id; $user_outh->user_id = $user->id;
$res1 = $user_outh->save(); $res1 = $user_outh->save();
if (!$res1) { if (!$res1) {
@ -126,10 +144,6 @@ class UserModifyForm extends ApiModel
} }
} }
if (!$res) {
$t->rollBack();
return $this->getModelError($user);
}
$t->commit(); $t->commit();
$form->username = $username; $form->username = $username;
$form->password = $password; $form->password = $password;

View File

@ -93,6 +93,19 @@ class DevController extends Controller
$data = $form->getBallQrcode(); $data = $form->getBallQrcode();
return $this->responseHandler($data); return $this->responseHandler($data);
} }
//设备二维码
public function actionQrWechatcode($id = 0)
{
if (!\Yii::$app->request->isPost) {
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new DevActionForm();
$form->attributes = \Yii::$app->request->post();
$data = $form->actionQrWechatcode();
return $this->responseHandler($data);
}
public function actionBatchQrcode() public function actionBatchQrcode()
{ {

View File

@ -25,11 +25,14 @@ use app\models\Store;
use app\models\StoreUser; use app\models\StoreUser;
use app\models\User; use app\models\User;
use app\models\Admin; use app\models\Admin;
use app\models\wechat\WechatApp;
use app\modules\api\controllers\Controller;
use app\modules\store\models\AdminModel; use app\modules\store\models\AdminModel;
use app\models\common\CommonUserEditForm; use app\models\common\CommonUserEditForm;
use app\modules\api\components\Mqtt; use app\modules\api\components\Mqtt;
use app\modules\api\models\StoreCityForm; use app\modules\api\models\StoreCityForm;
use PHPQRCode\QRcode; use PHPQRCode\QRcode;
use Wechat\Wechat;
class DevActionForm extends AdminModel class DevActionForm extends AdminModel
{ {
@ -38,6 +41,8 @@ class DevActionForm extends AdminModel
private $url = 'https://app.3dxh.h5.dev.1nww.com/#/White'; private $url = 'https://app.3dxh.h5.dev.1nww.com/#/White';
public $wechat_mp;
public function rules() public function rules()
{ {
@ -70,6 +75,76 @@ class DevActionForm extends AdminModel
} }
//设备二维码
public function actionQrWechatcode($id = 0)
{
$ball = Dev::findOne($this->ids);
if ($ball == null) {
return ['code' => 1, 'msg' => '该设备不存在'];
}
$store = Store::findOne($ball->store_id);
if ($store == null) {
return ['code' => 1, 'msg' => '该设备所在门店不存在'];
}
$path = 'qrcode/';
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$hostname = $this->url;
$filename = 'qrcode/' . md5($ball->dev_number."wechat_01") . '.png';
if(is_dir($filename)){
return ['code' => 0, 'msg' => 'ok', 'data' => \Yii::$app->request->getHostInfo() . '/' . $filename];
}
//微信小程序
$wechat_app = WechatApp::findOne([
'cx_mch_id' => 0,
'is_delete' => 0
]);
if($wechat_app){
if (!is_dir(\Yii::$app->runtimePath . '/pem')) {
mkdir(\Yii::$app->runtimePath . '/pem');
file_put_contents(\Yii::$app->runtimePath . '/pem/index.html', '');
}
$cert_pem_file = null;
if ($wechat_app->cert_pem) {
$cert_pem_file = \Yii::$app->runtimePath . '/pem/' . md5($wechat_app->cert_pem);
if (!file_exists($cert_pem_file))
file_put_contents($cert_pem_file, $wechat_app->cert_pem);
}
$key_pem_file = null;
if ($wechat_app->key_pem) {
$key_pem_file = \Yii::$app->runtimePath . '/pem/' . md5($wechat_app->key_pem);
if (!file_exists($key_pem_file))
file_put_contents($key_pem_file, $wechat_app->key_pem);
}
$this->wechat_mp = new Wechat([
'appId' => $wechat_app->app_id,
'appSecret' => $wechat_app->app_secret,
'mchId' => $wechat_app->mch_id,
'apiKey' => $wechat_app->key,
'certPem' => $cert_pem_file,
'keyPem' => $key_pem_file,
]);
}
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$this->wechat_mp->getAccessToken();
$arr = [
'action_name' => 'QR_LIMIT_SCENE',
'action_info' => [
'scene' => [
'scene_id' => $ball->id,
],
],
];
$res = $this->wechat_mp->curl->post($url,json_encode($arr));
$res = json_decode($res->response,true);
$url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($res['ticket']);
$res = $this->wechat_mp->curl->get($url);
file_put_contents($filename,$res->response);
return ['code' => 0, 'msg' => 'ok', 'data' => \Yii::$app->request->getHostInfo() . '/' . $filename];
}
/** /**
* @param $store * @param $store
* @param $ball * @param $ball

View File

@ -64,7 +64,7 @@ class ReportListForm extends AdminModel
} }
$query = Report::find()->alias('o') $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') ->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,o.json')
->leftJoin(['u' => User::tableName()], 'o.user_id=u.id') ->leftJoin(['u' => User::tableName()], 'o.user_id=u.id')
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id') ->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
->where([ ->where([
@ -86,7 +86,15 @@ class ReportListForm extends AdminModel
foreach ($list as $index => $item) { foreach ($list as $index => $item) {
if(!empty($item['json'])){
$item['json'] = json_decode($item['json'],true);
}
if(empty($item['json'])){
$item['json'] = [
'status' => 0, # 当前状态1.有报告0,
''
];
}
$item['user_type'] = $storeUser->user_type; $item['user_type'] = $storeUser->user_type;

View File

@ -81,6 +81,7 @@ $this->params['breadcrumbs'][] = $this->title;
<script type="text/html" id="rowBarTpl"> <script type="text/html" id="rowBarTpl">
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="qrcode">查看二维码</button> <button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="qrcode">查看二维码</button>
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="wechatqrcode">查看公众号二维码</button>
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</button> <button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</button>
@ -173,7 +174,7 @@ $this->params['breadcrumbs'][] = $this->title;
// , {field: 'pdf_name', title: 'PDF报告'} // , {field: 'pdf_name', title: 'PDF报告'}
, {field: 'status', title: '状态', templet: '#statusTpl', width: 80} , {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
, {field: 'created_at_cn', title: '创建时间', width: 150} , {field: 'created_at_cn', title: '创建时间', width: 150}
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 240} , {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 280}
] ]
] ]
, url: '<?=\Yii::$app->urlManager->createUrl(['store/dev/index'])?>' , url: '<?=\Yii::$app->urlManager->createUrl(['store/dev/index'])?>'
@ -283,6 +284,54 @@ $this->params['breadcrumbs'][] = $this->title;
}) })
} }
if (lay_event == "wechatqrcode") {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/qr-wechatcode'])?>";
confirm_tip = "确定查看此设备二维码吗?";
layer.closeAll()
layer.load(2);
return $.ajax(confirm_url, {
type: "POST",
dataType: "json",
data: {
ids: ids,
_csrf: _csrf
},
success: function (res) {
layer.closeAll('loading');
if (res.code == 0) {
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: 2
, time: 1000
}, function () {
});
}
},
error: function (xhr, type, err) {
layer.closeAll('loading');
layer.msg(xhr.responseText, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
})
}
if (confirm_url != null) { if (confirm_url != null) {

View File

@ -80,7 +80,7 @@ $this->params['breadcrumbs'][] = $this->title;
<!--行操作列模板--> <!--行操作列模板-->
<script type="text/html" id="rowBarTpl"> <script type="text/html" id="rowBarTpl">
{{# if(d.user_type == 1){ }} <!--{{# if(d.user_type == 1){ }}
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">初始模型上传</button> <button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">初始模型上传</button>
{{# } }} {{# } }}
@ -109,7 +109,7 @@ $this->params['breadcrumbs'][] = $this->title;
download="{{d.pdf_name}}.{{d.pdf_path_ext}}"> download="{{d.pdf_name}}.{{d.pdf_path_ext}}">
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载PDF报告</button> <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载PDF报告</button>
</a> </a>
{{# } }} {{# } }}-->
<!-- <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>--> <!-- <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>--> <!-- <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>-->
</script> </script>
@ -172,10 +172,10 @@ $this->params['breadcrumbs'][] = $this->title;
, {field: 'real_name', title: '姓名', width: 100} , {field: 'real_name', title: '姓名', width: 100}
, {field: 'mobile_phone', title: '电话', width: 120} , {field: 'mobile_phone', title: '电话', width: 120}
, {field: 'store_name', title: '门店名称'} , {field: 'store_name', title: '门店名称'}
, {field: 'model_number', title: '模型编号'} , {field: 'model_number', title: '设备编号'}
, {field: 'initial_name', title: '初始模型'} // , {field: 'initial_name', title: '初始模型'}
, {field: 'final_name', title: '最终模型'} // , {field: 'final_name', title: '最终模型'}
, {field: 'pdf_name', title: 'PDF报告'} // , {field: 'pdf_name', title: 'PDF报告'}
// , {field: 'status', title: '状态', templet: '#statusTpl', width: 80} // , {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
, {field: 'created_at_cn', title: '创建时间', width: 150} , {field: 'created_at_cn', title: '创建时间', width: 150}
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 400} , {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 400}

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

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

Some files were not shown because too many files have changed in this diff Show More