|
@@ -28,9 +28,10 @@ class Wechat extends Api |
|
@@ -28,9 +28,10 @@ class Wechat extends Api |
28
|
1.前端获取jsjdk的配置
|
28
|
1.前端获取jsjdk的配置
|
29
|
*/
|
29
|
*/
|
30
|
public function get_jsjdk_config(){
|
30
|
public function get_jsjdk_config(){
|
|
|
31
|
+ if(empty(request()->param('store_id'))){return $this->error('门店信息错误');}
|
31
|
try{
|
32
|
try{
|
32
|
$param = request()->param();
|
33
|
$param = request()->param();
|
33
|
- $app = WehcatModule::getInstance()->initWechat();
|
34
|
+ $app = WehcatModule::getInstance(request()->param('store_id'))->initWechat();
|
34
|
$app->jssdk->setUrl($param['url']);
|
35
|
$app->jssdk->setUrl($param['url']);
|
35
|
$APIs = ['updateAppMessageShareData','updateTimelineShareData','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone','chooseWXPay','openLocation','getLocation'];
|
36
|
$APIs = ['updateAppMessageShareData','updateTimelineShareData','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone','chooseWXPay','openLocation','getLocation'];
|
36
|
$config = $app->jssdk->buildConfig($APIs, true);
|
37
|
$config = $app->jssdk->buildConfig($APIs, true);
|
|
@@ -162,13 +163,11 @@ class Wechat extends Api |
|
@@ -162,13 +163,11 @@ class Wechat extends Api |
162
|
|
163
|
|
163
|
public function get_user_info_by_code (){
|
164
|
public function get_user_info_by_code (){
|
164
|
$user_id = 0;
|
165
|
$user_id = 0;
|
165
|
- if(empty(request()->param('code'))){
|
|
|
166
|
- return $this->error('非法操作');
|
|
|
167
|
- }
|
|
|
168
|
-
|
166
|
+ if(empty(request()->param('code'))){return $this->error('非法操作');}
|
|
|
167
|
+ if(empty(request()->param('store_id'))){return $this->error('门店信息错误');}
|
169
|
|
168
|
|
170
|
try{
|
169
|
try{
|
171
|
- $app = WehcatModule::getInstance()->initWechat();
|
170
|
+ $app = WehcatModule::getInstance(request()->param('store_id'))->initWechat();
|
172
|
$oauth = $app->oauth;
|
171
|
$oauth = $app->oauth;
|
173
|
// 获取 OAuth 授权结果用户信息
|
172
|
// 获取 OAuth 授权结果用户信息
|
174
|
$user = $oauth->user();
|
173
|
$user = $oauth->user();
|
|
@@ -183,6 +182,7 @@ class Wechat extends Api |
|
@@ -183,6 +182,7 @@ class Wechat extends Api |
183
|
$save['status'] = 'normal';
|
182
|
$save['status'] = 'normal';
|
184
|
$save['jointime'] = $save['prevtime'] = $save['logintime'] = time();
|
183
|
$save['jointime'] = $save['prevtime'] = $save['logintime'] = time();
|
185
|
$save['loginip'] = $save['joinip'] = request()->ip();
|
184
|
$save['loginip'] = $save['joinip'] = request()->ip();
|
|
|
185
|
+ $save['store_id'] =request()->param('store_id');
|
186
|
$w['openid'] = $openid;
|
186
|
$w['openid'] = $openid;
|
187
|
$user = Db::name('user')->where($w)->find();
|
187
|
$user = Db::name('user')->where($w)->find();
|
188
|
//存在更新否则新增
|
188
|
//存在更新否则新增
|
|
@@ -298,16 +298,15 @@ class Wechat extends Api |
|
@@ -298,16 +298,15 @@ class Wechat extends Api |
298
|
if(empty($my_user_id)){return $this->error('用户信息错误');}
|
298
|
if(empty($my_user_id)){return $this->error('用户信息错误');}
|
299
|
$o_w["order_no"] = $order_no;
|
299
|
$o_w["order_no"] = $order_no;
|
300
|
$order_info = Db::name('verification_order')->where($o_w)->find();
|
300
|
$order_info = Db::name('verification_order')->where($o_w)->find();
|
|
|
301
|
+
|
301
|
$user_id = $order_info['user_id'];
|
302
|
$user_id = $order_info['user_id'];
|
302
|
$userInfo = Db::name('user')->where(['id'=>$user_id])->find();
|
303
|
$userInfo = Db::name('user')->where(['id'=>$user_id])->find();
|
303
|
$out_trade_no = $order_no;
|
304
|
$out_trade_no = $order_no;
|
304
|
- $o_w["order_no"] = $out_trade_no;
|
|
|
305
|
- $order_info = Db::name('verification_order')->where($o_w)->find();
|
|
|
306
|
$total_fee = $order_info['price'] * 100;
|
305
|
$total_fee = $order_info['price'] * 100;
|
307
|
//测试支付
|
306
|
//测试支付
|
308
|
$total_fee = mt_rand(1,10);//测试支付1分钱
|
307
|
$total_fee = mt_rand(1,10);//测试支付1分钱
|
309
|
//测试结束
|
308
|
//测试结束
|
310
|
- $app = WehcatModule::getInstance()->initWechatPay();
|
309
|
+ $app = WehcatModule::getInstance($order_info['verification_store_id'])->initWechatPay();
|
311
|
$result = $app->order->unify([
|
310
|
$result = $app->order->unify([
|
312
|
'body' => '优惠券购买',
|
311
|
'body' => '优惠券购买',
|
313
|
'out_trade_no' => $out_trade_no,
|
312
|
'out_trade_no' => $out_trade_no,
|
|
@@ -334,7 +333,7 @@ class Wechat extends Api |
|
@@ -334,7 +333,7 @@ class Wechat extends Api |
334
|
{"appid":"wx1c3cc5b4e2006be2","bank_type":"OTHERS","cash_fee":"10","fee_type":"CNY","is_subscribe":"Y","mch_id":"1609190540","nonce_str":"6477162663358","openid":"o5OQw6LSZr1gGhXWeYutDwjsu7UY","out_trade_no":"168552605462002","result_code":"SUCCESS","return_code":"SUCCESS","sign":"B3148E770FAEC4F6B6B0B40718D314DA","time_end":"20230531174105","total_fee":"10","trade_type":"JSAPI","transaction_id":"4200001852202305311195060106"}
|
333
|
{"appid":"wx1c3cc5b4e2006be2","bank_type":"OTHERS","cash_fee":"10","fee_type":"CNY","is_subscribe":"Y","mch_id":"1609190540","nonce_str":"6477162663358","openid":"o5OQw6LSZr1gGhXWeYutDwjsu7UY","out_trade_no":"168552605462002","result_code":"SUCCESS","return_code":"SUCCESS","sign":"B3148E770FAEC4F6B6B0B40718D314DA","time_end":"20230531174105","total_fee":"10","trade_type":"JSAPI","transaction_id":"4200001852202305311195060106"}
|
335
|
*/
|
334
|
*/
|
336
|
public function notify(){
|
335
|
public function notify(){
|
337
|
- $app = WehcatModule::getInstance()->initWechatPay();
|
336
|
+
|
338
|
$xml = file_get_contents("php://input");
|
337
|
$xml = file_get_contents("php://input");
|
339
|
|
338
|
|
340
|
$xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON
|
339
|
$xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON
|
|
@@ -537,7 +536,7 @@ class Wechat extends Api |
|
@@ -537,7 +536,7 @@ class Wechat extends Api |
537
|
$user_info = Db::name('user')->where(['id'=>$pid])->find();
|
536
|
$user_info = Db::name('user')->where(['id'=>$pid])->find();
|
538
|
$total_amount = $verification_store['commission'] * 100;
|
537
|
$total_amount = $verification_store['commission'] * 100;
|
539
|
//$total_amount = 100;
|
538
|
//$total_amount = 100;
|
540
|
- $app = WehcatModule::getInstance()->initWechatPay();
|
539
|
+ $app = WehcatModule::getInstance($verification_order['verification_store_id'])->initWechatPay();
|
541
|
$mch_billno=time().rand(10000,99999);
|
540
|
$mch_billno=time().rand(10000,99999);
|
542
|
$result = $app->redpack->sendNormal([
|
541
|
$result = $app->redpack->sendNormal([
|
543
|
'mch_billno' => $mch_billno,
|
542
|
'mch_billno' => $mch_billno,
|