Browse Source

与分销系统整合

zhengchengwu 5 years ago
parent
commit
309bea37c3

+ 27 - 0
addons/ewei_shopv2/core/inc/functions.php View File

3202
     return "{$field['type']}{$length}{$signed}{$null}{$default}{$increment}";
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
 function isINSwsApp($W, $GPC, $reset=false) {
3217
 function isINSwsApp($W, $GPC, $reset=false) {
3206
     $key = '__ewei_shopv2_swsapp_session_' . $W['uniacid'];
3218
     $key = '__ewei_shopv2_swsapp_session_' . $W['uniacid'];
3207
     if (isset($GPC[$key]) && !$reset) {
3219
     if (isset($GPC[$key]) && !$reset) {
3253
     $sgjUserDb = new DB($conf);
3265
     $sgjUserDb = new DB($conf);
3254
     $member = $sgjUserDb->get('sgj_user_user', array('id' => $userId));
3266
     $member = $sgjUserDb->get('sgj_user_user', array('id' => $userId));
3255
     return $member;
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 View File

12
 	{
12
 	{
13
 		global $_W;
13
 		global $_W;
14
 		global $_GPC;
14
 		global $_GPC;
15
-		
15
+
16
 		//如果在圣卫士app
16
 		//如果在圣卫士app
17
 		$sws = isINSwsApp($_W, $_GPC, true);
17
 		$sws = isINSwsApp($_W, $_GPC, true);
18
 		if($sws ) {
18
 		if($sws ) {
30
 							if($member) {
30
 							if($member) {
31
 								pdo_update('ewei_shop_member_ky_bind', ['member_id'=>$member['id']], ['id'=>$ky['id']]);
31
 								pdo_update('ewei_shop_member_ky_bind', ['member_id'=>$member['id']], ['id'=>$ky['id']]);
32
 								m('account')->setLogin($member);
32
 								m('account')->setLogin($member);
33
+								$_W["openid"] = $member['openid'];
33
 								$this->sws['login'] = true;
34
 								$this->sws['login'] = true;
34
 							}else {
35
 							}else {
35
 								$mobile = $kyUser['mobile'];
36
 								$mobile = $kyUser['mobile'];
43
 
44
 
44
 								$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
45
 								$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
45
 								m('account')->setLogin($member);
46
 								m('account')->setLogin($member);
47
+								$_W["openid"] = $member['openid'];
46
 								$this->sws['login'] = true;
48
 								$this->sws['login'] = true;
47
 							}
49
 							}
48
 						}
50
 						}
49
 					}else {
51
 					}else {
50
 						m('account')->setLogin($member);
52
 						m('account')->setLogin($member);
53
+						$_W["openid"] = $member['openid'];
51
 						$this->sws['login'] = true;
54
 						$this->sws['login'] = true;
52
 					}
55
 					}
53
 				} else {
56
 				} else {
57
 						if($member) {
60
 						if($member) {
58
 							pdo_insert('ewei_shop_member_ky_bind', ['member_id'=>$member['id'], 'ky_user_id'=>$kyUser['id']]);
61
 							pdo_insert('ewei_shop_member_ky_bind', ['member_id'=>$member['id'], 'ky_user_id'=>$kyUser['id']]);
59
 							m('account')->setLogin($member);
62
 							m('account')->setLogin($member);
63
+							$_W["openid"] = $member['openid'];
60
 							$this->sws['login'] = true;
64
 							$this->sws['login'] = true;
61
 						}else {
65
 						}else {
62
 							$mobile = $kyUser['mobile'];
66
 							$mobile = $kyUser['mobile'];
70
 
74
 
71
 							$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
75
 							$member = pdo_get('ewei_shop_member', ['id'=>$uid]);
72
 							m('account')->setLogin($member);
76
 							m('account')->setLogin($member);
77
+							$_W["openid"] = $member['openid'];
73
 							$this->sws['login'] = true;
78
 							$this->sws['login'] = true;
74
 						}
79
 						}
75
 					}
80
 					}
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
 		m("shop")->checkClose();
167
 		m("shop")->checkClose();
82
 		$preview = intval($_GPC["preview"]);
168
 		$preview = intval($_GPC["preview"]);
83
 		$wap = m("common")->getSysset("wap");
169
 		$wap = m("common")->getSysset("wap");

+ 11 - 3
addons/ewei_shopv2/core/model/account.php View File

12
 			if (!empty($openid)) {
12
 			if (!empty($openid)) {
13
 				return $openid;
13
 				return $openid;
14
 			}
14
 			}
15
-
16
 			$url = urlencode(base64_encode($_SERVER['QUERY_STRING']));
15
 			$url = urlencode(base64_encode($_SERVER['QUERY_STRING']));
17
 			$loginurl = mobileUrl('account/login', array('mid' => $_GPC['mid'], 'backurl' => $_W['isajax'] ? '' : $url));
16
 			$loginurl = mobileUrl('account/login', array('mid' => $_GPC['mid'], 'backurl' => $_W['isajax'] ? '' : $url));
18
 
17
 
48
 		$key = '__ewei_shopv2_member_session_' . $_W['uniacid'];
47
 		$key = '__ewei_shopv2_member_session_' . $_W['uniacid'];
49
 
48
 
50
 		if (isset($_GPC[$key])) {
49
 		if (isset($_GPC[$key])) {
51
-			
50
+
52
 			$session = json_decode(base64_decode($_GPC[$key]), true);
51
 			$session = json_decode(base64_decode($_GPC[$key]), true);
53
 			if (is_array($session)) {
52
 			if (is_array($session)) {
54
 				$member = m('member')->getMember($session['openid']);
53
 				$member = m('member')->getMember($session['openid']);
54
+
55
 				if (is_array($member) && $session['ewei_shopv2_member_hash'] == md5($member['pwd'] . $member['salt'])) {
55
 				if (is_array($member) && $session['ewei_shopv2_member_hash'] == md5($member['pwd'] . $member['salt'])) {
56
 					$GLOBALS['_W']['ewei_shopv2_member_hash'] = md5($member['pwd'] . $member['salt']);
56
 					$GLOBALS['_W']['ewei_shopv2_member_hash'] = md5($member['pwd'] . $member['salt']);
57
 					$GLOBALS['_W']['ewei_shopv2_member'] = $member;
57
 					$GLOBALS['_W']['ewei_shopv2_member'] = $member;
58
 					return $member['openid'];
58
 					return $member['openid'];
59
 				}
59
 				}
60
-
60
+				
61
 				isetcookie($key, false, -100);
61
 				isetcookie($key, false, -100);
62
 			}
62
 			}
63
 		}
63
 		}
67
 	{
67
 	{
68
 		global $_W;
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
 		if (!is_array($member)) {
78
 		if (!is_array($member)) {
71
 			$member = m('member')->getMember($member);
79
 			$member = m('member')->getMember($member);
72
 		}
80
 		}

+ 4 - 0
data/config.php View File

22
 $config['other_db']['sgj_user']['pconnect'] = 0;
22
 $config['other_db']['sgj_user']['pconnect'] = 0;
23
 $config['other_db']['sgj_user']['tablepre'] = '';
23
 $config['other_db']['sgj_user']['tablepre'] = '';
24
 
24
 
25
+$config['fxtokenkey'] = 'kN*5&AHqLP7&IGRKvHoElJm*2YY6Nw*QSScJ4ff&DH&ofGnbfQIks1A1NT9AbIDB';
26
+
25
 //prod
27
 //prod
26
 // $config['db']['master']['host'] = 'shengws2015.mysql.rds.aliyuncs.com';
28
 // $config['db']['master']['host'] = 'shengws2015.mysql.rds.aliyuncs.com';
27
 // $config['db']['master']['username'] = 'syh';
29
 // $config['db']['master']['username'] = 'syh';
41
 // $config['other_db']['sgj_user']['pconnect'] = 0;
43
 // $config['other_db']['sgj_user']['pconnect'] = 0;
42
 // $config['other_db']['sgj_user']['tablepre'] = '';
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
 $config['db']['slave_status'] = false;
48
 $config['db']['slave_status'] = false;
45
 $config['db']['slave']['1']['host'] = '';
49
 $config['db']['slave']['1']['host'] = '';
46
 $config['db']['slave']['1']['username'] = '';
50
 $config['db']['slave']['1']['username'] = '';

+ 8 - 0
framework/function/file.func.php View File

228
 	}
228
 	}
229
 
229
 
230
 	$save_path = ATTACHMENT_ROOT . '/' . $result['path'];
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
 	if (!file_move($file['tmp_name'], $save_path)) {
239
 	if (!file_move($file['tmp_name'], $save_path)) {
232
 		return error(-1, '保存上传文件失败');
240
 		return error(-1, '保存上传文件失败');
233
 	}
241
 	}