Parcourir la source

fix():修改配置

geek il y a 4 ans
Parent
commit
f803ec1bd8

+ 1 - 0
application/api/controller/Order.php

@@ -320,6 +320,7 @@ class Order extends BaseController {
             (new OrderService())->notify($input['OrderNumber']);
             Until::output([]);
         }
+        (new OrderService())->notify($input['OrderNumber']);
         Until::output(['decode' => md5('ef17f532-4661-b07c-5346-65dfa304c0d8'.$input['OrderNumber']),
             'encode' => $this->request->header('serchkey')]);
     }

+ 5 - 0
application/api/controller/Pay.php

@@ -8,6 +8,7 @@ namespace app\api\controller;
 
 
 use app\api\BaseController;
+use app\api\exception\ApiException;
 use app\api\model\AdminModel;
 use app\api\model\BrandModel;
 use app\api\model\CompanyModel;
@@ -103,6 +104,10 @@ class Pay extends BaseController {
                 'remark'        => $input['remark']
             ]);
         } else {
+            $rs = $model::where(['pay_code' => $input['code']])->find();
+            if (!empty($rs)) {
+                throw new ApiException('存在相同payCode');
+            }
             $id = $model->insertGetId([
                 'pay_code'      => $input['code'],
 //                'master_pay_id' => $input['masterPayId'],

+ 4 - 1
application/api/controller/Store.php

@@ -247,12 +247,15 @@ class Store extends BaseController {
         Until::check($rule, $input);
         $model = new StoreModel();
         $squares = Until::returnSquarePoint($input['lon'], $input['lat']);
-        $info = $model::where("latitude<>0 and latitude>{$squares['right-bottom']['lat']} and latitude<{$squares['left-top']['lat']} and 
+        $info = $model::where("status = 1 and latitude<>0 and latitude>{$squares['right-bottom']['lat']} and latitude<{$squares['left-top']['lat']} and 
         longitude>{$squares['left-top']['lng']} and longitude<{$squares['right-bottom']['lng']}")
             ->field('*,' . "(6378.138 * 2 * asin(sqrt(pow(sin((latitude * pi() / 180 - " . $input['lat'] . " * pi() / 180) / 2),2) + 
             cos(latitude * pi() / 180) * cos(" . $input['lat'] . " * pi() / 180) * pow(sin((longitude * pi() / 180 - " . $input['lon'] . " * pi() / 180) / 2),2))) * 1000) as distance")
             ->find();
         $info = Until::modelToArray($info);
+        if (empty($info)) {
+            Until::output(['info' => []]);
+        }
         $disModel = new DiscussModel();
         $storeScore = $disModel::where(['store_id' => $info['id']])->avg('store_score');
         $info['score'] = (int)$storeScore;

+ 2 - 2
application/api/model/PayModel.php

@@ -27,8 +27,8 @@ class PayModel  extends BaseModel {
 
     public function getPayInfo() {
         $selectModel = $this->alias('p')
-            ->field('p.*,g.group_name')
-            ->join('group g','g.id = p.group_id')
+            ->field('p.*')
+//            ->join('group g','g.id = p.group_id')
             ->where($this->getWhere())
             ->find();
         return Until::modelToArray($selectModel);

+ 28 - 24
application/common/service/OrderService.php

@@ -15,9 +15,9 @@ use app\api\model\UserModel;
 use app\api\model\WriteOffModel;
 use app\common\until\Until;
 use GuzzleHttp\Client;
+use think\console\command\Help;
 use think\facade\Cache;
 use think\facade\Config;
-use const http\Client\Curl\Features\UNIX_SOCKETS;
 
 class OrderService {
 
@@ -29,6 +29,7 @@ class OrderService {
         $orderSn = Until::createSn();
         $productInfo = (new ProductModel())::where(['id' => $input['productId']])->find();
         $userInfo = (new UserModel())::where(['id' => Until::$userId])->find();
+        $userInfo = Until::modelToArray($userInfo);
         if (empty($userInfo)) {
             throw new ApiException('无此用户');
         }
@@ -72,25 +73,28 @@ class OrderService {
         //payCode string支付标识
         //username string用户名
         //}
-        $otherData = [
-            'openId'   => $userInfo['open_id'],
-            'attach'   => 'storeId:'.$input['storeId'],
-            'money'    => $orderMoney * 100,
-            'mark'     => '购买了'.$productInfo['product_name'],
-            'orderId'  => $orderSn,
-            'username' => $userInfo['name'],
-            'payCode'  => strtoupper($this->userName),
-        ];
-        $wxOrderInfo = $this->createOrderForOther($otherData);
-        $order = [
-            'nonceStr'  => $wxOrderInfo['nonceStr'],
-            'package'   => $wxOrderInfo['pack'],
-            'paySign'   => $wxOrderInfo['paySign'],
-            'timeStamp' => $wxOrderInfo['timeStamp'],
-            'signType'  => $wxOrderInfo['signType'],
-            'orderSn' => $orderSn,
-            'orderId' => $orderId
-        ];
+        if (!Until::$isAdmin) {
+            $otherData = [
+                'openId'   => $userInfo['open_id'],
+                'attach'   => 'storeId:'.$input['storeId'],
+                'money'    => $orderMoney * 100,
+                'mark'     => '购买了'.$productInfo['product_name'],
+                'orderId'  => $orderSn,
+                'username' => $userInfo['name'],
+                'payCode'  => strtoupper($this->userName),
+            ];
+            $wxOrderInfo = $this->createOrderForOther($otherData);
+            $order = [
+                'nonceStr'  => $wxOrderInfo['nonceStr'],
+                'package'   => $wxOrderInfo['pack'],
+                'paySign'   => $wxOrderInfo['paySign'],
+                'timeStamp' => $wxOrderInfo['timeStamp'],
+                'signType'  => $wxOrderInfo['signType'],
+                'orderSn' => $orderSn,
+                'orderId' => $orderId
+            ];
+        }
+
         return $order;
     }
 
@@ -183,16 +187,16 @@ class OrderService {
 
     public function notify(string $orderSn) {
         $model = new OrderModel();
-        $rs = $model::where(['order_sn' => $orderSn,'status' => 2])->find();
-        if (!empty($rs)) {
+        $rs = $model::where(['order_sn' => $orderSn])->find();
+        if (empty($rs) || $rs['status'] === 2) {
             return;
         }
+//        var_dump($rs);
         $model::where(['order_sn' => $orderSn])->update(['status' => 2,'pay_time' => date('Y-m-d H:i:s')]);
         $model::where(['pay_sn' => $orderSn])->update(['status' => 2,'pay_time' => date('Y-m-d H:i:s')]);
-
         $wModel = new WriteOffModel();
         $code  = $this->changeCode();
-        $wModel::where(['order_id' => $rs['order_id']])->update([
+        $wModel::where(['order_id' => $rs['id']])->update([
             'write_off_code' => $code,
             'over_time' => date('Y-m-d  H:i:s', time() + 5 * 60),
         ]);

+ 0 - 28
public/api.yaml

@@ -1120,39 +1120,11 @@ paths:
             schema:
               required:
                 - code
-                - groupId
-                - masterPayId
-                - masterAppId
-                - xcxSecret
               properties:
                 code:
                   description: 支付code
                   type: string
                   default: jj公司
-                groupId:
-                  description: 集团id
-                  type: integer
-                  default: '1'
-                masterPayId:
-                  description: 主商户号
-                  type: string
-                  default: a01
-                subPayId:
-                  description: 子商户号
-                  type: string
-                  default: '1'
-                masterAppId:
-                  description: 主appId
-                  type: string
-                  default: '1'
-                subAppId:
-                  description: 子appId
-                  type: string
-                  default: '1'
-                xcxSecret:
-                  description: 秘钥
-                  type: string
-                  default: '1'
                 status:
                   description: '状态 1正常  2删除'
                   type: integer