WIN-2308041133\Administrator 2 weeks ago
parent
commit
5c42d4f980

+ 4 - 3
app/api/controller/v1/order/StoreOrderController.php

@@ -235,11 +235,12 @@ class StoreOrderController
      */
     public function pay(Request $request, StorePinkServices $services, OrderPayServices $payServices, YuePayServices $yuePayServices)
     {
-        [$uni, $paytype, $quitUrl, $type] = $request->postMore([
+        [$uni, $paytype, $quitUrl, $type,$open_id] = $request->postMore([
             ['uni', ''],
             ['paytype', ''],
             ['quitUrl', ''],
-            ['type', 0]
+            ['type', 0],
+            ['open_id','']
         ], true);
         if (!$uni) return app('json')->fail(100100);
         $orderInfo = $this->services->get(['order_id' => $uni]);
@@ -289,7 +290,7 @@ class StoreOrderController
                     return app('json')->status('success', 410216);
                 }
             default:
-                $payInfo = $payServices->beforePay($order->toArray(), $paytype, ['quitUrl' => $quitUrl]);
+                $payInfo = $payServices->beforePay($order->toArray(), $paytype, ['quitUrl' => $quitUrl],$open_id);
                 return app('json')->status($payInfo['status'], $payInfo['payInfo']);
         }
     }

+ 14 - 4
app/services/agent/AgentLevelServices.php

@@ -68,7 +68,7 @@ class AgentLevelServices extends BaseServices
         $count = $this->dao->count($where);
         foreach ($list as &$item) {
             $item['one_brokerage_ratio'] = bcdiv(bcmul((string)sys_config('store_brokerage_ratio'), bcadd('100', (string)$item['one_brokerage'], 2), 2), '100', 2);
-            $item['two_brokerage_ratio'] = bcdiv(bcmul((string)sys_config('store_brokerage_two'), bcadd('100', (string)$item['two_brokerage'], 2), 2), '100', 2);
+//            $item['two_brokerage_ratio'] = bcdiv(bcmul((string)sys_config('store_brokerage_two'), bcadd('100', (string)$item['two_brokerage'], 2), 2), '100', 2);
         }
         return compact('count', 'list');
     }
@@ -268,11 +268,16 @@ class AgentLevelServices extends BaseServices
             'class' => 'tips-info',
             'domProps' => ['innerHTML' => '在分销一级佣金基础上浮(0-1000之间整数)百分比,目前一级返佣比率:10%,上浮5%,则返佣比率:一级返佣比率 * (1 + 一级上浮比率) = 10.50%']
         ])->max(1000)->precision(0);
-        $field[] = Form::number('two_brokerage', '二级上浮', 0)->appendRule('suffix', [
+        $field[] = Form::number('discount', '等级折扣', 0)->appendRule('suffix', [
             'type' => 'div',
             'class' => 'tips-info',
-            'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
-        ])->min(0)->max(1000)->precision(0);
+            'domProps' => ['innerHTML' => '购买商品享受折扣(0-1000之间整数)百分比']
+        ])->max(100)->precision(0);
+//        $field[] = Form::number('two_brokerage', '二级上浮', 0)->appendRule('suffix', [
+//            'type' => 'div',
+//            'class' => 'tips-info',
+//            'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
+//        ])->min(0)->max(1000)->precision(0);
         $field[] = Form::radio('status', '是否显示', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
         return create_form('添加分销员等级', $field, Url::buildUrl('/agent/level'), 'POST');
     }
@@ -303,6 +308,11 @@ class AgentLevelServices extends BaseServices
             'class' => 'tips-info',
             'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
         ])->min(0)->max(1000)->precision(0);
+//        $field[] = Form::number('two_brokerage', '二级上浮', $levelInfo['two_brokerage'])->appendRule('suffix', [
+//            'type' => 'div',
+//            'class' => 'tips-info',
+//            'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
+//        ])->min(0)->max(1000)->precision(0);
         $field[] = Form::radio('status', '是否显示', $levelInfo['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
 
         return create_form('编辑分销员等级', $field, Url::buildUrl('/agent/level/' . $id), 'PUT');

+ 19 - 14
app/services/pay/OrderPayServices.php

@@ -104,7 +104,7 @@ class OrderPayServices
      * @email 136327134@qq.com
      * @date 2023/2/15
      */
-    public function beforePay(array $orderInfo, string $payType, array $options = [])
+    public function beforePay(array $orderInfo, string $payType, array $options = [],string $openid = '')
     {
         $wechat = $payType == PayServices::WEIXIN_PAY;
 
@@ -119,21 +119,26 @@ class OrderPayServices
 
         switch ($payType) {
             case PayServices::WEIXIN_PAY:
-                $openid = '';
-                if (request()->isWechat() || request()->isRoutine()) {
-                    if (request()->isWechat()) {
-                        $userType = 'wechat';
-                    } else {
-                        $userType = 'routine';
-                    }
-                    /** @var WechatUserServices $services */
-                    $services = app()->make(WechatUserServices::class);
-                    $openid = $services->uidToOpenid($orderInfo['pay_uid'] ?? $orderInfo['uid'], $userType);
-                    if (!$openid) {
-                        throw new ApiException(410275);
+                if ($openid == ''){
+                    $openid = '';
+                    if (request()->isWechat() || request()->isRoutine()) {
+                        if (request()->isWechat()) {
+                            $userType = 'wechat';
+                        } else {
+                            $userType = 'routine';
+                        }
+                        /** @var WechatUserServices $services */
+                        $services = app()->make(WechatUserServices::class);
+                        $openid = $services->uidToOpenid($orderInfo['pay_uid'] ?? $orderInfo['uid'], $userType);
+                        if (!$openid) {
+                            throw new ApiException(410275);
+                        }
                     }
+                    $options['openid'] = $openid;
+                }else{
+                    $options['openid'] = $openid;
                 }
-                $options['openid'] = $openid;
+
                 break;
             case PayServices::ALLIN_PAY:
                 if ($wechat) {