Quellcode durchsuchen

读取电影收益、溢价配置

family vor 1 Jahr
Ursprung
Commit
dc3052f140

+ 7 - 2
app/common/repositories/movie/CinemaSchedRepository.php

@@ -98,6 +98,9 @@ class CinemaSchedRepository extends BaseRepository
98 98
         $where = ['film_sign' => $film_sign, 'show_date' => $show_date];
99 99
         if ($show_date == strtotime(date('Y-m-d'))) $where['show_time'] = $show_time;
100 100
 
101
+        $movie_commission_rate_config = Db::name('system_config_value')->where('config_key', 'movie_commission_rate_config')->find();
102
+        $movie_commission_rate_config = !empty($movie_commission_rate_config) ? json_decode($movie_commission_rate_config['value'], true) : [];
103
+
101 104
         $cinema_sched = $this->dao->search(null, $where)->when($with, function ($query) use ($with) {
102 105
             $query->with($with);
103 106
         })->when($latitude && $longitude, function ($query) use ($field, $longitude, $latitude) {
@@ -115,7 +118,7 @@ class CinemaSchedRepository extends BaseRepository
115 118
             $cinema_sched[$key]['distance'] = isset($value['distance']) ? round($value['distance'] / 1000, 2) : 0.00;
116 119
             $cinema_sched[$key]['show_date'] = date('m-d', $value['show_date']);
117 120
 
118
-            $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price']);
121
+            $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price'], $movie_commission_rate_config);
119 122
             $cinema_sched[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
120 123
         }
121 124
 
@@ -219,9 +222,11 @@ class CinemaSchedRepository extends BaseRepository
219 222
                 $filmList[$fValue['film_sign']] = $fValue;
220 223
             }
221 224
         }
225
+        $movie_commission_rate_config = Db::name('system_config_value')->where('config_key', 'movie_commission_rate_config')->find();
226
+        $movie_commission_rate_config = !empty($movie_commission_rate_config) ? json_decode($movie_commission_rate_config['value'], true) : [];
222 227
 
223 228
         foreach ($cinema_sched as $key => $value) {
224
-            $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price']);
229
+            $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price'], $movie_commission_rate_config);
225 230
 
226 231
             $cinema_sched[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
227 232
             $cinema_sched[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];

+ 23 - 7
app/common/repositories/movie/MovieRepository.php

@@ -96,12 +96,15 @@ class MovieRepository extends BaseRepository
96 96
      */
97 97
     public function getCinemaSched($film_sign = '', $cinema_sign = '')
98 98
     {
99
+        $movie_commission_rate_config = Db::name('system_config_value')->where('config_key', 'movie_commission_rate_config')->find();
100
+        $movie_commission_rate_config = !empty($movie_commission_rate_config) ? json_decode($movie_commission_rate_config['value'], true) : [];
101
+
99 102
         $result = DouHuoMallFilmApiRequest::getCinemaSched($film_sign, $cinema_sign);
100 103
         $cinemaSchedList = (isset($result['code']) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE))
101 104
             ? $result['data']['list'] : [];
102 105
         foreach ($cinemaSchedList as $dateDay => &$fileSchedValue) {
103 106
             foreach ($fileSchedValue as $key => $value) {
104
-                $pcYanglaojinGongxian = static::getPvYanglaojinScore($value['cost_price']);
107
+                $pcYanglaojinGongxian = static::getPvYanglaojinScore($value['cost_price'], $movie_commission_rate_config);
105 108
 
106 109
                 $fileSchedValue[$key]['price'] = $pcYanglaojinGongxian['cost_price']; // 销售价
107 110
                 $fileSchedValue[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
@@ -152,6 +155,9 @@ class MovieRepository extends BaseRepository
152 155
             }
153 156
         }
154 157
 
158
+        $movie_commission_rate_config = Db::name('system_config_value')->where('config_key', 'movie_commission_rate_config')->find();
159
+        $movie_commission_rate_config = !empty($movie_commission_rate_config) ? json_decode($movie_commission_rate_config['value'], true) : [];
160
+
155 161
         $seat = [];
156 162
         $schedSeatList = (isset($result['code']) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) ? $result['data'] : [];
157 163
         foreach ($schedSeatList as $key => $value) {
@@ -170,7 +176,7 @@ class MovieRepository extends BaseRepository
170 176
             }
171 177
             unset($schedSeatList[$key]['price']);
172 178
 
173
-            $pcYanglaojinGongxian = self::getPvYanglaojinScore($channel_price['price']);
179
+            $pcYanglaojinGongxian = self::getPvYanglaojinScore($channel_price['price'], $movie_commission_rate_config);
174 180
             $schedSeatList[$key]['channel_sn'] = base64_encode(json_encode($channel_price, JSON_FORCE_OBJECT));
175 181
             $schedSeatList[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
176 182
             $schedSeatList[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
@@ -229,6 +235,11 @@ class MovieRepository extends BaseRepository
229 235
             $filmRepository = app()->make(FilmRepository::class);
230 236
             $filminfo = $filmRepository->getFilmInfo($params['film_sign']);
231 237
 
238
+            // 电影分佣比例配置
239
+            $movie_commission_rate_config = Db::name('system_config_value')->where('config_key', 'movie_commission_rate_config')->find();
240
+            $movie_commission_rate_config = !empty($movie_commission_rate_config) ? json_decode($movie_commission_rate_config['value'], true) : [];
241
+            $premium_ratio = isset($movie_commission_rate_config['premium_rate']) ? $movie_commission_rate_config['premium_rate'] : self::premium_ratio;
242
+
232 243
             $_order = [
233 244
                 'uid' => $userinfo->uid,
234 245
                 'mobile' => $params['phone'] ?? $userinfo->phone,
@@ -237,7 +248,7 @@ class MovieRepository extends BaseRepository
237 248
                 'plat_order' => $submitOrder['data']['plat_order'],
238 249
                 'price' => $order_price,
239 250
                 'number' => count($sched_seat),
240
-                'order_price' => bcadd((string)$order_price, bcmul((string)$order_price, (string)self::premium_ratio, 2), 2),
251
+                'order_price' => bcadd((string)$order_price, bcmul((string)$order_price, (string)$premium_ratio, 2), 2),
241 252
                 'channel_type' => $channel_sn['channel_type'],
242 253
                 'city_sign' => $cinema['city_sign'],
243 254
                 'city_name' => $cinema['city_name'],
@@ -642,12 +653,16 @@ class MovieRepository extends BaseRepository
642 653
      * @param $cost_price
643 654
      * @return array
644 655
      */
645
-    public static function getPvYanglaojinScore($cost_price)
656
+    public static function getPvYanglaojinScore($cost_price, $movie_commission_rate_config)
646 657
     {
647
-        $premium = round($cost_price * self::premium_ratio, 2);
658
+        $premium_ratio = isset($movie_commission_rate_config['premium_rate']) ? $movie_commission_rate_config['premium_rate'] : self::premium_ratio;
659
+        $pv_ratio = isset($movie_commission_rate_config['pv_rate']) ? $movie_commission_rate_config['pv_rate'] : self::pv_ratio;
660
+        $yanglaojin_ratio = isset($movie_commission_rate_config['consumer_yanglaojin_rate']) ? $movie_commission_rate_config['consumer_yanglaojin_rate'] : self::yanglaojin_ratio;
661
+
662
+        $premium = round($cost_price * $premium_ratio, 2);
648 663
         $cost_price = bcadd((string)$cost_price, (string)$premium, 2);
649
-        $pv = $gongxian = $score = bcmul((string)$premium, self::pv_ratio, 2);
650
-        $yanglaojin = bcmul((string)$premium, self::yanglaojin_ratio, 2);
664
+        $pv = $gongxian = $score = bcmul((string)$premium, $pv_ratio, 2);
665
+        $yanglaojin = bcmul((string)$premium, $yanglaojin_ratio, 2);
651 666
 
652 667
         return compact('premium', 'cost_price', 'pv', 'yanglaojin', 'gongxian', 'score');
653 668
     }
@@ -719,6 +734,7 @@ class MovieRepository extends BaseRepository
719 734
 
720 735
         // 电影分佣比例配置
721 736
         $movie_commission_rate_config = Db::name('system_config_value')->where('config_key', 'movie_commission_rate_config')->find();
737
+        $movie_commission_rate_config = !empty($movie_commission_rate_config) ? json_decode($movie_commission_rate_config['value'], true) : [];
722 738
         // 让利金额
723 739
         $concession_pri = bcmul((string)$orderinfo['price'], $movie_commission_rate_config['premium_rate'], 2);
724 740
         // 养老金

+ 1 - 1
route/api.php

@@ -1292,7 +1292,7 @@ Route::group('api/', function () {
1292 1292
     //电影 - 下单业务
1293 1293
     Route::group('movie', function () {
1294 1294
         Route::post('submit_order', '/submitOrder');
1295
-        Route::post('confirm_order', '/confirmOrder');
1295
+//        Route::post('confirm_order', '/confirmOrder');
1296 1296
         Route::get('order_list', '/getOrderList'); // 订单列表
1297 1297
         Route::get('order_info', '/getOrderInfo');
1298 1298
     })->prefix('api.movie.Movie')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);