family před 1 rokem
rodič
revize
f6ec5ddd8b

+ 249 - 28
app/common/repositories/movie/MovieRepository.php

@@ -7,32 +7,9 @@
7 7
 
8 8
 namespace app\common\repositories\movie;
9 9
 
10
-use app\common\dao\store\product\ProductDao as dao;
11
-use app\common\model\store\product\Product;
12
-use app\common\model\user\User;
10
+use app\common\dao\movie\order\MovieOrderDao;
13 11
 use app\common\repositories\BaseRepository;
14
-use app\common\repositories\merchant\MerchantRepository;
15
-use app\common\repositories\store\coupon\StoreCouponRepository;
16 12
 use app\common\repositories\store\order\StoreOrderRepository;
17
-use app\common\repositories\store\product\ProductAttrRepository;
18
-use app\common\repositories\store\product\ProductAttrValueRepository;
19
-use app\common\repositories\store\product\ProductCateRepository;
20
-use app\common\repositories\store\product\ProductContentRepository;
21
-use app\common\repositories\store\product\ProductReplyRepository;
22
-use app\common\repositories\store\shipping\ShippingTemplateRepository;
23
-use app\common\repositories\store\StoreBrandRepository;
24
-use app\common\repositories\store\StoreCategoryRepository;
25
-use app\common\repositories\store\StoreSeckillActiveRepository;
26
-use app\common\repositories\store\StoreSeckillTimeRepository;
27
-use app\common\repositories\user\UserRelationRepository;
28
-use app\common\repositories\user\UserVisitRepository;
29
-use app\controller\merchant\gong\Goods;
30
-use app\traits\ShouxinyiApiRequest;
31
-use crmeb\exceptions\ApiException;
32
-use crmeb\services\QrcodeService;
33
-use crmeb\services\SwooleTaskService;
34
-use think\Exception;
35
-use think\exception\ValidateException;
36 13
 use think\facade\Db;
37 14
 use think\facade\Log;
38 15
 
@@ -40,18 +17,17 @@ use think\facade\Log;
40 17
  * Class MovieRepository
41 18
  * @package app\common\repositories\movie
42 19
  * @author xaboy
43
- * @mixin dao
20
+ * @mixin MovieOrderDao
44 21
  */
45 22
 class MovieRepository extends BaseRepository
46 23
 {
47 24
     protected $dao;
48
-    protected $filed = 'concession_pri,product_id,mer_id,brand_id,unit_name,rate,reply_count,store_info,cate_id,ficti,image,slider_image,store_name,keyword,sort,is_show,sales,price,refusal,cost,ot_price,stock,is_gift_bag,care_count,status,is_used,create_time,seckill,plate_mer_profit,type';
49 25
 
50 26
     /**
51 27
      * ProductRepository constructor.
52
-     * @param dao $dao
28
+     * @param MovieOrderDao $dao
53 29
      */
54
-    public function __construct(dao $dao)
30
+    public function __construct(MovieOrderDao $dao)
55 31
     {
56 32
         $this->dao = $dao;
57 33
     }
@@ -120,4 +96,249 @@ class MovieRepository extends BaseRepository
120 96
     {
121 97
         return DouHuoMallFilmApiRequest::getSchedSeat($relation_id, $sched_sign);
122 98
     }
99
+
100
+    /**
101
+     * 锁座订单
102
+     * @param $sched_sign
103
+     * @param $seat_sign
104
+     * @param $channel_type
105
+     * @param $third_order
106
+     * @param $order_price
107
+     * @param $phone
108
+     * @return mixed|string
109
+     */
110
+    public function submitOrder($userinfo, $params)
111
+    {
112
+        /** @var StoreOrderRepository $storeOrder */
113
+        $storeOrder = app()->make(StoreOrderRepository::class);
114
+        $order_sn = $storeOrder->getNewOrderId() . '0';
115
+
116
+        $order_price = round($params['number'] * $params['price'], 2);
117
+        $submitOrder = DouHuoMallFilmApiRequest::submitOrder($userinfo->phone, $params['channel_type'], $params['sched_sign'], $order_sn, $order_price);
118
+        if (!empty($submitOrder) && isset($submitOrder['code']) && ($submitOrder['code'] == 200) && isset($submitOrder['data']['plat_order'])){
119
+            $_order = [
120
+                'uid' => $userinfo->uid,
121
+                'mobile' => $userinfo->phone,
122
+                'order_sn' => $order_sn,
123
+                'plat_order' => $submitOrder['data']['plat_order'],
124
+                'price' => $params['price'],
125
+                'number' => $params['number'],
126
+                'order_price' => $order_price,
127
+                'channel_type' => $params['channel_type'],
128
+                'pay_type' => $params['pay_type'],
129
+                'city_sign' => $params['city_sign'],
130
+                'city_name' => $params['city_name'],
131
+                'area_code' => $params['area_code'],
132
+                'area_name' => $params['area_name'],
133
+                'cinema_sign' => $params['cinema_sign'],
134
+                'cinema_name' => $params['cinema_name'],
135
+                'address' => $params['address'],
136
+                'longitude' => $params['longitude'],
137
+                'latitude' => $params['latitude'],
138
+                'hall_sign' => $params['hall_sign'],
139
+                'hall_name' => $params['hall_name'],
140
+                'relation_id' => $params['relation_id'],
141
+                'sched_sign' => $params['sched_sign'],
142
+                'film_sign' => $params['film_sign'],
143
+                'film_name' => $params['film_name'],
144
+                'show_date' => $params['show_date'],
145
+                'show_time' => $params['show_time'],
146
+                'sched_seat' => $params['sched_seat'],
147
+                'create_time' => time()
148
+            ];
149
+
150
+            $group = Db::transaction(function () use ($userinfo, $_order) {
151
+                $_order = $this->dao->create($_order);
152
+                if ($_order) return static::pay();
153
+
154
+
155
+            });
156
+            return $group;
157
+        } else {
158
+            return $submitOrder;
159
+        }
160
+    }
161
+
162
+    private static function pay($payType,$code,$groupOrder,$title,$notify_url,$pay_mode=null,$appid=''){
163
+
164
+        $order_no = $groupOrder['group_order_sn'] ?? $groupOrder['order_no'];
165
+
166
+
167
+
168
+        if($payType == 'wx'){
169
+
170
+            if(!$code || $code == '' || $code =='undefined')
171
+                return "授权失败,code为空";
172
+            if($appid == '') {
173
+
174
+
175
+                $pay_wx = systemConfig('pay_wx');
176
+
177
+                if ($pay_wx == 2){
178
+                    $appid = env('WECHAT_MP.APPID');
179
+                    $new_secret = env('WECHAT_MP.SECRET');
180
+
181
+                    $app_id='app_0827b960-b932-45ec-b800-4e850091b419';
182
+                    $key='api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
183
+
184
+                }elseif ($pay_wx == 3){
185
+                    $appid = env('WECHAT_TDYL.APPID');
186
+                    $new_secret = env('WECHAT_TDYL.SECRET');
187
+
188
+
189
+                    Db::name('log')->insert(['data'=>'appid---'.$appid]);
190
+                    Db::name('log')->insert(['data'=>'new_secret---'.$new_secret]);
191
+                    $app_id='app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0';
192
+                    $key='api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
193
+
194
+                }
195
+
196
+            }else{
197
+                $app_id='app_0827b960-b932-45ec-b800-4e850091b419';
198
+                $key='api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
199
+                $new_secret = "c8cbe24fa3b83f77a88b79554b3aeab4";
200
+            }
201
+
202
+            $url = "https://api.weixin.qq.com/sns/jscode2session?appid=".$appid."&secret=".$new_secret."&js_code=".$code."&grant_type=authorization_code";
203
+            $get = curlGet($url);
204
+            Db::name('log')->insert(['data'=>'pay_wx---'.$pay_wx]);
205
+            Db::name('log')->insert(['data'=>'code---'.$code]);
206
+            Db::name('log')->insert(['data'=>'url---'.$url]);
207
+            Db::name('log')->insert(['data'=>'open_id---'.json_encode($get)]);
208
+            if(!isset($get['openid']) || empty($get['openid'])){
209
+                return '授权失败';
210
+            }
211
+            $openid = $get['openid'];
212
+
213
+            $member_id=0;
214
+            $type='2';
215
+            $pay_channel='wx_lite';
216
+
217
+            $expend=[
218
+                'open_id'=>$openid,
219
+                'wx_app_id'=> $appid
220
+            ];
221
+
222
+
223
+            if ($groupOrder['order_type'] = "marketing"){
224
+
225
+                db::name("test_log")->insert(["note"=>"pay_huifu" . json_encode($groupOrder)]);
226
+                // 创富宝 分账
227
+                //创富宝
228
+                $cfb = sprintf("%01.2f",round(bcmul($groupOrder['pay_price'],'0.094',5),2));//9.4%的分账
229
+
230
+                $cfb_member = "jsdk_member_1680162243019";
231
+                //  平台
232
+                $cxb = sprintf("%01.2f",round(bcsub($groupOrder['pay_price'],$cfb,5),2));//剩下的归平台
233
+
234
+                $div_members=[
235
+                    [
236
+                        'member_id'=>$member_id,
237
+                        'amount'=>$cxb,
238
+                        'fee_flag'=>'Y'
239
+                    ],
240
+                    [
241
+                        'member_id'=>$cfb_member,
242
+                        'amount'=>$cfb,
243
+                        'fee_flag'=>'N'
244
+                    ]
245
+                ];
246
+            }else{
247
+                $div_members=[
248
+                    [
249
+                        'member_id'=>$member_id,
250
+                        'amount'=>$groupOrder['pay_price'],
251
+                        'fee_flag'=>'Y'
252
+                    ]
253
+                ];
254
+            }
255
+
256
+            $params=[
257
+                'order_no'=>$order_no."_".rand(1000,9999),
258
+                'app_id'=>$app_id,
259
+                'pay_channel'=>$pay_channel,
260
+                'pay_amt'=>(string)$groupOrder['pay_price'],
261
+                'goods_title'=> strlen($title) > 64 ? mb_substr($title, 0, 64,'utf-8') : $title,// 解决因为太长不能支付问题
262
+                'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127,'utf-8') : $title,// 解决因为太长不能支付问题
263
+                'device_info'=>[
264
+                    'device_ip'=>app('request')->ip()
265
+//                    'device_ip'=>'115.171.134.68'
266
+                ],
267
+
268
+                'expend'=>json_encode($expend),
269
+                'div_members'=>json_encode($div_members),
270
+                'fee_mode'=>'I',
271
+                'notify_url'=>$notify_url
272
+            ];
273
+            if($pay_mode == 'delay'){
274
+                $params['pay_mode'] = 'delay';
275
+                unset($params['div_members']);
276
+                unset($params['fee_mode']);
277
+            }
278
+            return $this->Payment_create_traits_b($params,$type,$key);
279
+        }elseif($payType=='ALI'){
280
+//            throw new AuthException('支付宝正在升级,请使用微信支付');
281
+            $member_id=0;
282
+            $type='1';
283
+            $pay_channel='alipay_qr';
284
+            // 天地博爱科技通道
285
+            $app_id='app_44108546-d27a-48ee-88c1-84b45b75114f';
286
+            $key='api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9';
287
+            // 天地博爱通道
288
+//            $app_id='app_0827b960-b932-45ec-b800-4e850091b419';
289
+//            $key='api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
290
+
291
+            $div_members=[
292
+                [
293
+                    'member_id'=>$member_id,
294
+                    'amount'=>$groupOrder['pay_price'],
295
+                    'fee_flag'=>'Y'
296
+                ]
297
+            ];
298
+
299
+            $params=[
300
+                'order_no'=>$order_no."_".rand(1000,9999),
301
+                'app_id'=>$app_id,
302
+                'pay_channel'=>$pay_channel,
303
+                'pay_amt'=>(string)$groupOrder['pay_price'],
304
+                'goods_title'=> strlen($title) > 64 ? mb_substr($title, 0, 64,'utf-8') : $title,// 解决因为太长不能支付问题
305
+                'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127,'utf-8') : $title,// 解决因为太长不能支付问题
306
+                'device_info'=>[
307
+                    'device_ip'=>app('request')->ip()
308
+//                    'device_ip'=>'115.171.134.68'
309
+                ],
310
+
311
+//                    'expend'=>json_encode($expend),
312
+                'div_members'=>json_encode($div_members),
313
+                'fee_mode'=>'I',
314
+                'notify_url'=>$notify_url
315
+            ];
316
+            if($pay_mode == 'delay'){
317
+                $params['pay_mode'] = 'delay';
318
+                unset($params['div_members']);
319
+                unset($params['fee_mode']);
320
+            }
321
+            return $this->Payment_create_traits_a($params,$type,$key);
322
+        }
323
+
324
+    }
325
+
326
+    /**
327
+     * @param $third_order
328
+     * @param $order_price
329
+     * @return mixed|string
330
+     */
331
+    public function confirmOrder($third_order, $order_price)
332
+    {
333
+        return DouHuoMallFilmApiRequest::confirmOrder($third_order, $order_price);
334
+    }
335
+
336
+    /**
337
+     * @param $third_order
338
+     * @return mixed|string
339
+     */
340
+    public function getOrderInfo($third_order)
341
+    {
342
+        return DouHuoMallFilmApiRequest::getOrderInfo($third_order);
343
+    }
123 344
 }

+ 82 - 35
app/controller/api/movie/Movie.php

@@ -42,8 +42,8 @@ class Movie extends BaseController
42 42
     public function getMovieCity()
43 43
     {
44 44
         [$page, $limit] = $this->getPage();
45
-        $initial = $this->request->params(['initial']);
46
-        $city_name = $this->request->params(['city_name']);
45
+        $initial = $this->request->param('initial', '');
46
+        $city_name = $this->request->param('city_name', '');
47 47
 
48 48
         return app('json')->success($this->repository->getMovieCity($page, $limit, $initial, $city_name));
49 49
     }
@@ -55,7 +55,7 @@ class Movie extends BaseController
55 55
      */
56 56
     public function getArea()
57 57
     {
58
-        $city_sign = $this->request->params(['city_sign']);
58
+        $city_sign = $this->request->param('city_sign', '');
59 59
         if (empty($city_sign)) return app('json')->fail('请选择城市');
60 60
 
61 61
         return app('json')->success($this->repository->getMovieArea($city_sign));
@@ -69,8 +69,8 @@ class Movie extends BaseController
69 69
     public function getCinema()
70 70
     {
71 71
         [$page, $limit] = $this->getPage();
72
-        $city_sign = $this->request->params(['city_sign']);
73
-        $area_sign = $this->request->params(['area_sign']);
72
+        $city_sign = $this->request->param('city_sign', '');
73
+        $area_sign = $this->request->param('area_sign', '');
74 74
 
75 75
         return app('json')->success($this->repository->getCinema($page, $limit, $city_sign, $area_sign));
76 76
     }
@@ -83,8 +83,8 @@ class Movie extends BaseController
83 83
     public function getFilm()
84 84
     {
85 85
         [$page, $limit] = $this->getPage();
86
-        $cinema_sign = $this->request->params(['cinema_sign']);
87
-        $film_sign = $this->request->params(['film_sign']);
86
+        $cinema_sign = $this->request->param('cinema_sign', '');
87
+        $film_sign = $this->request->param('film_sign', '');
88 88
 
89 89
         return app('json')->success($this->repository->getFilm($page, $limit, $cinema_sign, $film_sign));
90 90
     }
@@ -96,10 +96,10 @@ class Movie extends BaseController
96 96
      */
97 97
     public function getCinemaSched()
98 98
     {
99
-        $cinema_sign = $this->request->params(['cinema_sign']);
99
+        $cinema_sign = $this->request->param('cinema_sign', '');
100 100
         if (empty($cinema_sign)) return app('json')->fail('请选择影院');
101 101
 
102
-        $film_sign = $this->request->params(['film_sign']);
102
+        $film_sign = $this->request->param('film_sign', '');
103 103
         if (empty($film_sign)) return app('json')->fail('请选择影片');
104 104
 
105 105
         return app('json')->success($this->repository->getCinemaSched($film_sign, $cinema_sign));
@@ -112,41 +112,88 @@ class Movie extends BaseController
112 112
      */
113 113
     public function getSchedSeat()
114 114
     {
115
-        $relation_id = $this->request->params(['relation_id']);
115
+        $relation_id = $this->request->param('relation_id', '');
116 116
         if (empty($cinema_sign)) return app('json')->fail('请选择场次');
117 117
 
118
-        $sched_sign = $this->request->params(['sched_sign']);
118
+        $sched_sign = $this->request->param('sched_sign', '');
119 119
         if (empty($film_sign)) return app('json')->fail('请选择场次');
120 120
 
121 121
         return app('json')->success($this->repository->getSchedSeat($relation_id, $sched_sign));
122 122
     }
123 123
 
124
-    //大仓会员商品列表
125
-    public function dacang_lst()
124
+    /**
125
+     * 锁座订单
126
+     *
127
+     * @return mixed
128
+     */
129
+    public function submitOrder()
126 130
     {
127
-        [$page, $limit] = $this->getPage();
128
-        $type = $this->request->param('type');
129
-        if ($type == '2') {
130
-            //银卡会员商品
131
-            $product_id = explode('=', systemConfig('product_ids_yin'));
131
+        $params = $this->request->params(
132
+            ['price', 0.00],
133
+            ['number', 0],
134
+            ['channel_type', ''],
135
+            ['pay_type', ''],
136
+            ['city_sign', ''],
137
+            ['city_name', ''],
138
+            ['area_code', ''],
139
+            ['area_name', ''],
140
+            ['cinema_sign', ''],
141
+            ['cinema_name', ''],
142
+            ['address', ''],
143
+            ['longitude', ''],
144
+            ['latitude', ''],
145
+            ['hall_sign', ''],
146
+            ['hall_name', ''],
147
+            ['relation_id', ''],
148
+            ['sched_sign', ''],
149
+            ['film_sign', ''],
150
+            ['film_name', ''],
151
+            ['show_date', ''],
152
+            ['show_time', ''],
153
+            ['sched_seat', '']
154
+        );
155
+
156
+        if (empty($params['sched_sign'])) return app('json')->fail('请选择场次');
157
+        if (empty($params['seat_sign'])) return app('json')->fail('请选择座位');
158
+        if (empty($params['channel_type'])) return app('json')->fail('请选择购票类型');
159
+
160
+        $result = $this->repository->submitOrder($this->request->userInfo(), $params);
161
+        if ($result['code'] == 200) {
162
+            return app('json')->success($result);
132 163
         } else {
133
-            //金卡会员商品
134
-            $product_id = explode('=', systemConfig('product_ids'));
135
-        }
136
-        $product_lst = Db::name('store_product')->page($page, $limit)->whereIn('product_id', $product_id)->field('image,store_name,product_id,sales')->select()->toArray();
137
-        $count = Db::name('store_product')->whereIn('product_id', $product_id)->count('product_id');
138
-        $ProductRepository = app()->make(repository::class);
139
-        foreach ($product_lst as $k => &$v) {
140
-            $v['yanglao'] = $ProductRepository->yanglaojin($v['product_id']);
141
-            $product_attr_value = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->field('unique,ot_price,price')->find();
142
-            $v['product_attr_unique'] = $product_attr_value['unique'];
143
-            $v['ot_price'] = $product_attr_value['ot_price'];
144
-            $v['price'] = $product_attr_value['price'];
164
+            return app('json')->fail($result);
145 165
         }
146
-        $return_data = [
147
-            'list' => $product_lst,
148
-            'count' => $count
149
-        ];
150
-        return app('json')->success($return_data);
166
+    }
167
+
168
+    /**
169
+     * 确认订单
170
+     *
171
+     * @return mixed
172
+     */
173
+    public function confirmOrder()
174
+    {
175
+        $relation_id = $this->request->param(['relation_id']);
176
+        if (empty($cinema_sign)) return app('json')->fail('请选择场次');
177
+
178
+        $sched_sign = $this->request->param(['sched_sign']);
179
+        if (empty($film_sign)) return app('json')->fail('请选择场次');
180
+
181
+        return app('json')->success($this->repository->confirmOrder($relation_id, $sched_sign));
182
+    }
183
+
184
+    /**
185
+     * 查询订单信息
186
+     *
187
+     * @return mixed
188
+     */
189
+    public function getOrderInfo()
190
+    {
191
+        $relation_id = $this->request->param(['relation_id']);
192
+        if (empty($cinema_sign)) return app('json')->fail('请选择场次');
193
+
194
+        $sched_sign = $this->request->param(['sched_sign']);
195
+        if (empty($film_sign)) return app('json')->fail('请选择场次');
196
+
197
+        return app('json')->success($this->repository->getOrderInfo($relation_id, $sched_sign));
151 198
     }
152 199
 }