|
|
@@ -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
|
}
|