zhengchengwu 5 лет назад
Родитель
Сommit
309bea37c3

+ 27 - 0
addons/ewei_shopv2/core/inc/functions.php Просмотреть файл

@@ -3202,6 +3202,18 @@ function _db_build_field_sql_ab($field) {
3202 3202
     return "{$field['type']}{$length}{$signed}{$null}{$default}{$increment}";
3203 3203
 }
3204 3204
 
3205
+function checkFxToken($token, $orgId, $time) {
3206
+    $key = $GLOBALS['_W']['config']['fxtokenkey'];
3207
+    $string = md5('org_id='.$orgId . '&time='.$time);
3208
+    $string = 'string='.$string.'&key='.$key; 
3209
+    $signToken = md5($string);
3210
+
3211
+    if ($token===$signToken) {
3212
+        return true;
3213
+    }
3214
+    return false;
3215
+}
3216
+
3205 3217
 function isINSwsApp($W, $GPC, $reset=false) {
3206 3218
     $key = '__ewei_shopv2_swsapp_session_' . $W['uniacid'];
3207 3219
     if (isset($GPC[$key]) && !$reset) {
@@ -3253,4 +3265,19 @@ function getKyUser($userId) {
3253 3265
     $sgjUserDb = new DB($conf);
3254 3266
     $member = $sgjUserDb->get('sgj_user_user', array('id' => $userId));
3255 3267
     return $member;
3268
+}
3269
+
3270
+function getOrgCreate($id) {
3271
+    $conf = $GLOBALS['_W']['config']['other_db']['sgj_user'];
3272
+    $sgjUserDb = new DB($conf);
3273
+    $member = $sgjUserDb->get('sgj_user_admin', array('id' => $id));
3274
+    return $member;
3275
+}
3276
+
3277
+
3278
+function getOrg($id) {
3279
+    $conf = $GLOBALS['_W']['config']['other_db']['sgj_user'];
3280
+    $sgjUserDb = new DB($conf);
3281
+    $org = $sgjUserDb->get('sgj_user_org', array('id' => $id));
3282
+    return $org;
3256 3283
 }

+ 87 - 1
addons/ewei_shopv2/core/inc/page_mobile.php Просмотреть файл

@@ -12,7 +12,7 @@ class MobilePage extends Page
12 12
 	{
13 13
 		global $_W;
14 14
 		global $_GPC;
15
-		
15
+
16 16
 		//如果在圣卫士app
17 17
 		$sws = isINSwsApp($_W, $_GPC, true);
18 18
 		if($sws ) {
@@ -30,6 +30,7 @@ class MobilePage extends Page
30 30
 							if($member) {
31 31
 								pdo_update('ewei_shop_member_ky_bind', ['member_id'=>$member['id']], ['id'=>$ky['id']]);
32 32
 								m('account')->setLogin($member);
33
+								$_W["openid"] = $member['openid'];
33 34
 								$this->sws['login'] = true;
34 35
 							}else {
35 36
 								$mobile = $kyUser['mobile'];
@@ -43,11 +44,13 @@ class MobilePage extends Page
43 44
 
44 45
 								$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
45 46
 								m('account')->setLogin($member);
47
+								$_W["openid"] = $member['openid'];
46 48
 								$this->sws['login'] = true;
47 49
 							}
48 50
 						}
49 51
 					}else {
50 52
 						m('account')->setLogin($member);
53
+						$_W["openid"] = $member['openid'];
51 54
 						$this->sws['login'] = true;
52 55
 					}
53 56
 				} else {
@@ -57,6 +60,7 @@ class MobilePage extends Page
57 60
 						if($member) {
58 61
 							pdo_insert('ewei_shop_member_ky_bind', ['member_id'=>$member['id'], 'ky_user_id'=>$kyUser['id']]);
59 62
 							m('account')->setLogin($member);
63
+							$_W["openid"] = $member['openid'];
60 64
 							$this->sws['login'] = true;
61 65
 						}else {
62 66
 							$mobile = $kyUser['mobile'];
@@ -70,6 +74,7 @@ class MobilePage extends Page
70 74
 
71 75
 							$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
72 76
 							m('account')->setLogin($member);
77
+							$_W["openid"] = $member['openid'];
73 78
 							$this->sws['login'] = true;
74 79
 						}
75 80
 					}
@@ -78,6 +83,87 @@ class MobilePage extends Page
78 83
 			}
79 84
 
80 85
 		}
86
+		
87
+		//如果在分销系统(不是人人商城的分销系统,而且用beego新建的系统,在系统里通过ifram加载人人商城的分销系统)的iframe
88
+		if(isset($_GPC['fxtoken']) && isset($_GPC['fxorgid']) && isset($_GPC['timestamp']) && isset($_GPC['fxadmin'])) {
89
+	
90
+			if(checkFxToken($_GPC['fxtoken'], $_GPC['fxorgid'], $_GPC['timestamp']) && !m("account")->checkAppLogin()) {
91
+				$org = getOrg($_GPC['fxorgid']);
92
+				$orgName = $org? $org['org_name']:'';
93
+				$orgLogo = $org? $org['org_logo']:'';
94
+				$ky = pdo_get('ewei_shop_member_org_bind', ['org_id'=>$_GPC['fxorgid']]);
95
+				if($ky) {
96
+					$member = pdo_get('ewei_shop_member', ['id'=>$ky['member_id']]);
97
+					if (empty($member)) {
98
+						$kyAdmin = getOrgCreate($_GPC['fxadmin']);
99
+						if($kyAdmin) {
100
+							$member = pdo_get('ewei_shop_member', ['mobile'=>$kyAdmin['mobile']]);
101
+							if($member) {
102
+								pdo_update('ewei_shop_member_org_bind', ['member_id'=>$member['id']], ['id'=>$ky['id']]);
103
+								if($member["isagent"] != 1 || $member["status"] != 1) {
104
+									$member["isagent"] = 1;
105
+									$member["status"] = 1;
106
+									pdo_update('ewei_shop_member', ['isagent'=>1, 'status'=>1], ['id'=>$member['id']]);
107
+								}
108
+								m('account')->setLogin($member);
109
+								$_W["openid"] = $member['openid'];
110
+							}else {
111
+								$mobile = $kyAdmin['mobile'];
112
+								$salt = m('account')->getSalt();
113
+								$openid = 'wap_user_' . $_W['uniacid'] . '_' . $mobile . '_' . time();
114
+								$nickname = substr($mobile, 0, 3) . 'xxxx' . substr($mobile, 7, 4);
115
+								$data = array('isagent'=>1, 'status'=>1, 'uniacid' => $_W['uniacid'], 'mobile' => $kyAdmin['mobile'], 'nickname' => $orgName?:$nickname, 'openid' => $openid, 'pwd' => '', 'salt' => $salt, 'createtime' => time(), 'mobileverify' => 1, 'comefrom' => 'mobile');
116
+								
117
+								pdo_insert('ewei_shop_member', $data);
118
+								$uid = pdo_insertid();
119
+								pdo_update('ewei_shop_member_org_bind', ['member_id'=>$uid], ['id'=>$ky['id']]);
120
+
121
+								$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
122
+								m('account')->setLogin($member);
123
+								$_W["openid"] = $member['openid'];
124
+							}
125
+						}
126
+					}else {
127
+						m('account')->setLogin($member);
128
+						$_W["openid"] = $member['openid'];
129
+					}
130
+				} else {
131
+					$kyAdmin = getOrgCreate($_GPC['fxadmin']);
132
+					if($kyAdmin) {
133
+						$member = pdo_get('ewei_shop_member', ['mobile'=>$kyAdmin['mobile']]);
134
+						if($member) {
135
+							pdo_insert('ewei_shop_member_org_bind', ['member_id'=>$member['id'], 'org_id'=>$_GPC['fxorgid']]);
136
+							if($member["isagent"] != 1 || $member["status"] != 1) {
137
+								$member["isagent"] = 1;
138
+								$member["status"] = 1;
139
+								pdo_update('ewei_shop_member', ['isagent'=>1, 'status'=>1], ['id'=>$member['id']]);
140
+							}
141
+							m('account')->setLogin($member);
142
+							$_W["openid"] = $member['openid'];
143
+						}else {
144
+							$mobile = $kyAdmin['mobile'];
145
+							$salt = m('account')->getSalt();
146
+							$openid = 'wap_user_' . $_W['uniacid'] . '_' . $mobile . '_' . time();
147
+							$nickname = substr($mobile, 0, 3) . 'xxxx' . substr($mobile, 7, 4);
148
+							$data = array('isagent'=>1, 'status'=>1, 'uniacid' => $_W['uniacid'], 'mobile' => $kyAdmin['mobile'], 'nickname' => $orgName?:$nickname, 'openid' => $openid, 'pwd' => '', 'salt' => $salt, 'createtime' => time(), 'mobileverify' => 1, 'comefrom' => 'mobile');
149
+							
150
+							pdo_insert('ewei_shop_member', $data);
151
+							$uid = pdo_insertid();
152
+							pdo_insert('ewei_shop_member_org_bind', ['member_id'=>$uid, 'org_id'=>$_GPC['fxorgid']]);
153
+
154
+							$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
155
+							m('account')->setLogin($member);
156
+							$_W["openid"] = $member['openid'];
157
+						}
158
+					}
159
+
160
+				}
161
+			
162
+			}
163
+
164
+		}
165
+
166
+
81 167
 		m("shop")->checkClose();
82 168
 		$preview = intval($_GPC["preview"]);
83 169
 		$wap = m("common")->getSysset("wap");

+ 11 - 3
addons/ewei_shopv2/core/model/account.php Просмотреть файл

@@ -12,7 +12,6 @@ class Account_EweiShopV2Model
12 12
 			if (!empty($openid)) {
13 13
 				return $openid;
14 14
 			}
15
-
16 15
 			$url = urlencode(base64_encode($_SERVER['QUERY_STRING']));
17 16
 			$loginurl = mobileUrl('account/login', array('mid' => $_GPC['mid'], 'backurl' => $_W['isajax'] ? '' : $url));
18 17
 
@@ -48,16 +47,17 @@ class Account_EweiShopV2Model
48 47
 		$key = '__ewei_shopv2_member_session_' . $_W['uniacid'];
49 48
 
50 49
 		if (isset($_GPC[$key])) {
51
-			
50
+
52 51
 			$session = json_decode(base64_decode($_GPC[$key]), true);
53 52
 			if (is_array($session)) {
54 53
 				$member = m('member')->getMember($session['openid']);
54
+
55 55
 				if (is_array($member) && $session['ewei_shopv2_member_hash'] == md5($member['pwd'] . $member['salt'])) {
56 56
 					$GLOBALS['_W']['ewei_shopv2_member_hash'] = md5($member['pwd'] . $member['salt']);
57 57
 					$GLOBALS['_W']['ewei_shopv2_member'] = $member;
58 58
 					return $member['openid'];
59 59
 				}
60
-
60
+				
61 61
 				isetcookie($key, false, -100);
62 62
 			}
63 63
 		}
@@ -67,6 +67,14 @@ class Account_EweiShopV2Model
67 67
 	{
68 68
 		global $_W;
69 69
 
70
+		//载入日志函数
71
+load()->func('logging');
72
+//记录文本日志
73
+logging_run('=============================记录字符串日志数据=');
74
+//记录数组数据
75
+logging_run(array('username' => is_array($member), 'age' => '18'));
76
+
77
+
70 78
 		if (!is_array($member)) {
71 79
 			$member = m('member')->getMember($member);
72 80
 		}

+ 4 - 0
data/config.php Просмотреть файл

@@ -22,6 +22,8 @@ $config['other_db']['sgj_user']['charset'] = 'utf8mb4';
22 22
 $config['other_db']['sgj_user']['pconnect'] = 0;
23 23
 $config['other_db']['sgj_user']['tablepre'] = '';
24 24
 
25
+$config['fxtokenkey'] = 'kN*5&AHqLP7&IGRKvHoElJm*2YY6Nw*QSScJ4ff&DH&ofGnbfQIks1A1NT9AbIDB';
26
+
25 27
 //prod
26 28
 // $config['db']['master']['host'] = 'shengws2015.mysql.rds.aliyuncs.com';
27 29
 // $config['db']['master']['username'] = 'syh';
@@ -41,6 +43,8 @@ $config['other_db']['sgj_user']['tablepre'] = '';
41 43
 // $config['other_db']['sgj_user']['pconnect'] = 0;
42 44
 // $config['other_db']['sgj_user']['tablepre'] = '';
43 45
 
46
+// $config['ssodomain'] = '8&o!5VSz^iWe*PzhDogC5%m*S$ZlyB3c%5R4CrWjTwJJSJdEbop6do@eFR*7deTY';
47
+
44 48
 $config['db']['slave_status'] = false;
45 49
 $config['db']['slave']['1']['host'] = '';
46 50
 $config['db']['slave']['1']['username'] = '';

+ 8 - 0
framework/function/file.func.php Просмотреть файл

@@ -228,6 +228,14 @@ function file_upload($file, $type = 'image', $name = '', $compress = false) {
228 228
 	}
229 229
 
230 230
 	$save_path = ATTACHMENT_ROOT . '/' . $result['path'];
231
+	//载入日志函数
232
+load()->func('logging');
233
+//记录文本日志
234
+logging_run('记录字符串日志数据');
235
+//记录数组数据
236
+logging_run(array('$save_path' => $save_path, 'age' => '18'));
237
+
238
+
231 239
 	if (!file_move($file['tmp_name'], $save_path)) {
232 240
 		return error(-1, '保存上传文件失败');
233 241
 	}