正在显示
1 个修改的文件
包含
31 行增加
和
9 行删除
@@ -236,6 +236,11 @@ class Store extends Api | @@ -236,6 +236,11 @@ class Store extends Api | ||
236 | } | 236 | } |
237 | unset($param['code']); | 237 | unset($param['code']); |
238 | $order_sn = $param['order_sn'] = get_order_sn(); | 238 | $order_sn = $param['order_sn'] = get_order_sn(); |
239 | + // 获取入驻支付金额 | ||
240 | + $pay_data = []; | ||
241 | + $param['money'] = $this->house_model->whereIn('id',$param['house_ids'])->sum('price'); | ||
242 | + $param['status'] = 1; | ||
243 | + if($param['money'] > 0) { | ||
239 | // 获取配置 | 244 | // 获取配置 |
240 | $app = new Application(ConfigService::load()); | 245 | $app = new Application(ConfigService::load()); |
241 | $payment = $app->payment; | 246 | $payment = $app->payment; |
@@ -257,7 +262,9 @@ class Store extends Api | @@ -257,7 +262,9 @@ class Store extends Api | ||
257 | } else { | 262 | } else { |
258 | $this->error($order_result['return_msg']); | 263 | $this->error($order_result['return_msg']); |
259 | } | 264 | } |
260 | - $param['money'] = $this->house_model->whereIn('id',$param['house_ids'])->sum('price'); | 265 | + } else { |
266 | + $param['status'] = 2; | ||
267 | + } | ||
261 | Db::startTrans(); | 268 | Db::startTrans(); |
262 | $result = false; | 269 | $result = false; |
263 | $result_invite = true; | 270 | $result_invite = true; |
@@ -281,7 +288,7 @@ class Store extends Api | @@ -281,7 +288,7 @@ class Store extends Api | ||
281 | if(!$result || !$result_invite) { | 288 | if(!$result || !$result_invite) { |
282 | $this->error('申请提交失败'); | 289 | $this->error('申请提交失败'); |
283 | } | 290 | } |
284 | - $this->success('申请提交成功',['id'=>$id,'pay_data'=>$pay_data]); | 291 | + $this->success('申请提交成功',['id'=>$id,'pay_status'=>$param['status'],'pay_data'=>$pay_data]); |
285 | } | 292 | } |
286 | 293 | ||
287 | /** | 294 | /** |
@@ -964,6 +971,11 @@ class Store extends Api | @@ -964,6 +971,11 @@ class Store extends Api | ||
964 | $param = (new StoreValidate())->goCheck('house_new'); | 971 | $param = (new StoreValidate())->goCheck('house_new'); |
965 | $store = $this->get_store(); | 972 | $store = $this->get_store(); |
966 | $order_sn = $param['order_sn'] = get_order_sn(); | 973 | $order_sn = $param['order_sn'] = get_order_sn(); |
974 | + // 获取入驻支付金额 | ||
975 | + $pay_data = []; | ||
976 | + $param['money'] = $this->house_model->whereIn('id',$param['house_ids'])->sum('price'); | ||
977 | + $param['status'] = 1; | ||
978 | + if($param['money'] > 0) { | ||
967 | // 获取配置 | 979 | // 获取配置 |
968 | $app = new Application(ConfigService::load()); | 980 | $app = new Application(ConfigService::load()); |
969 | $payment = $app->payment; | 981 | $payment = $app->payment; |
@@ -974,27 +986,37 @@ class Store extends Api | @@ -974,27 +986,37 @@ class Store extends Api | ||
974 | 'out_trade_no' => $order_sn, | 986 | 'out_trade_no' => $order_sn, |
975 | 'total_fee' => 1, // $param['money'] * 100 | 987 | 'total_fee' => 1, // $param['money'] * 100 |
976 | 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址 | 988 | 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址 |
977 | - 'notify_url' => url('index/ajax/store_order_notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址 | ||
978 | - 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'), | 989 | + 'notify_url' => url('index/ajax/store_order_notify', [], true, true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址 |
990 | + 'openid' => Db::name('third')->where('user_id', $this->auth->id)->value('openid'), | ||
979 | ]; | 991 | ]; |
980 | $order = new Order($attributes); | 992 | $order = new Order($attributes); |
981 | $order_result = $payment->prepare($order); | 993 | $order_result = $payment->prepare($order); |
982 | - if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') { | 994 | + if ($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') { |
983 | $prepayId = $order_result->prepay_id; | 995 | $prepayId = $order_result->prepay_id; |
984 | $pay_data = $payment->configForJSSDKPayment($prepayId); | 996 | $pay_data = $payment->configForJSSDKPayment($prepayId); |
985 | } else { | 997 | } else { |
986 | $this->error($order_result['return_msg']); | 998 | $this->error($order_result['return_msg']); |
987 | } | 999 | } |
988 | - $param['money'] = $this->house_model->whereIn('id',$param['house_ids'])->sum('price'); | 1000 | + } else { |
1001 | + $param['status'] = 2; | ||
1002 | + } | ||
989 | $model = new StoreOrder(); | 1003 | $model = new StoreOrder(); |
990 | Db::startTrans(); | 1004 | Db::startTrans(); |
991 | $result = false; | 1005 | $result = false; |
992 | - $result_invite = true; | 1006 | + $result_invite = $res_store = true; |
993 | try{ | 1007 | try{ |
994 | $param['store_id'] = $store['id']; | 1008 | $param['store_id'] = $store['id']; |
995 | $param['user_id'] = $this->auth->id; | 1009 | $param['user_id'] = $this->auth->id; |
996 | $result = $model->add($param); | 1010 | $result = $model->add($param); |
997 | $id = $model->id; | 1011 | $id = $model->id; |
1012 | + if($param['money'] == 0) { | ||
1013 | + // 新增关联社区 | ||
1014 | + $update = [ | ||
1015 | + 'id' => $store['id'], | ||
1016 | + 'house_ids' => $store['house_ids'].','.$param['house_ids'] | ||
1017 | + ]; | ||
1018 | + $res_store = Db::name('store')->where('id',$param['store_id'])->update($update); | ||
1019 | + } | ||
998 | Db::commit(); | 1020 | Db::commit(); |
999 | } catch (PDOException $e) { | 1021 | } catch (PDOException $e) { |
1000 | Db::rollback(); | 1022 | Db::rollback(); |
@@ -1003,10 +1025,10 @@ class Store extends Api | @@ -1003,10 +1025,10 @@ class Store extends Api | ||
1003 | Db::rollback(); | 1025 | Db::rollback(); |
1004 | $this->error($e->getMessage()); | 1026 | $this->error($e->getMessage()); |
1005 | } | 1027 | } |
1006 | - if(!$result || !$result_invite) { | 1028 | + if(!$result || !$result_invite || !$res_store) { |
1007 | $this->error('提交失败'); | 1029 | $this->error('提交失败'); |
1008 | } | 1030 | } |
1009 | - $this->success('提交成功',['id'=>$id,'pay_data'=>$pay_data]); | 1031 | + $this->success('提交成功',['id'=>$id,'pay_status'=>$param['status'],'pay_data'=>$pay_data]); |
1010 | } | 1032 | } |
1011 | 1033 | ||
1012 | /** | 1034 | /** |
-
请 注册 或 登录 后发表评论