wesmiler 4 달 전
부모
커밋
01af669e40

+ 1 - 0
.gitignore

@@ -3,4 +3,5 @@
 .env.*.php
 .env.php
 .env
+/vendor
 

+ 0 - 111
app/Http/Controllers/Admin/DepositController.php

@@ -1,111 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Admin;
-
-use App\Services\Common\DepositService;
-
-/**
- * 保证金管理
- * @package App\Http\Controllers\Admin
- */
-class DepositController extends Backend
-{
-
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * GoodsController constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->service = new DepositService();
-    }
-
-    /**
-     * 列表
-     * @return array
-     */
-    public function index()
-    {
-        $pageSize = request()->get('limit', 10);
-        $list = $this->service->getDataList(request()->all(), $pageSize);
-        $message = array(
-            "msg" => '操作成功',
-            "code" => 0,
-            "data" => isset($list['list'])? $list['list']:[],
-            "counts" => isset($list['counts'])? $list['counts']:[],
-            "count" => isset($list['total'])? $list['total']:0,
-        );
-        return $message;
-    }
-
-
-    /**
-     * 审核
-     * @return array
-     */
-    public function confirm()
-    {
-        $params = request()->post();
-        if(DepositService::make()->confirm($this->userId,$params)){
-            return message(DepositService::make()->getError(), true);
-        }else{
-            return message(DepositService::make()->getError(), false);
-        }
-    }
-
-    /**
-     * 打款
-     * @return array
-     */
-    public function payment()
-    {
-        $params = request()->post();
-        if(DepositService::make()->payment($this->userId,$params)){
-            return message(DepositService::make()->getError(), true);
-        }else{
-            return message(DepositService::make()->getError(), false);
-        }
-    }
-
-    /**
-     * 获取配置
-     * @return array
-     */
-    public function getSetting()
-    {
-        if($config = DepositService::make()->getSetting()){
-            return message(1010, true, $config);
-        }else{
-            return message(1009, false);
-        }
-    }
-
-    /**
-     * 保存设置
-     * @return array
-     */
-    public function saveSetting()
-    {
-        $params = request()->post();
-        if(DepositService::make()->saveSetting($this->userId,$params)){
-            return message(DepositService::make()->getError(), true);
-        }else{
-            return message(DepositService::make()->getError(), false);
-        }
-    }
-
-    /**
-     * 删除数据
-     * @return mixed
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function delete()
-    {
-        $result = $this->service->delete();
-        return $result;
-    }
-}

+ 0 - 95
app/Http/Controllers/Admin/MessageController.php

@@ -1,95 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Http\Controllers\Admin;
-
-use App\Services\Common\MessageService;
-
-/**
- * 消息管理-控制器
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Http\Controllers
- */
-class MessageController extends Backend
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->service = new MessageService();
-    }
-
-    public function index()
-    {
-        $pageSize = request()->get('limit', 10);
-        $list = $this->service->getDataList(request()->all(), $pageSize);
-        $message = array(
-            "msg" => '操作成功',
-            "code" => 0,
-            "data" => isset($list['list'])? $list['list']:[],
-            "count" => isset($list['total'])? $list['total']:0,
-        );
-        return $message;
-    }
-
-    /**
-     * 历史记录
-     * @return array
-     * @throws \Psr\Container\ContainerExceptionInterface
-     * @throws \Psr\Container\NotFoundExceptionInterface
-     */
-    public function history()
-    {
-        $pageSize = request()->get('limit', 10);
-        $list = $this->service->getDataList(request()->all(), $pageSize);
-        $message = array(
-            "msg" => '操作成功',
-            "code" => 0,
-            "data" => isset($list['list'])? $list['list']:[],
-            "count" => isset($list['total'])? $list['total']:0,
-            "unread" => isset($list['unread'])? $list['unread']:0,
-        );
-        return $message;
-    }
-
-    /**
-     * 聊天列表
-     * @return array
-     * @throws \Psr\Container\ContainerExceptionInterface
-     * @throws \Psr\Container\NotFoundExceptionInterface
-     */
-    public function chatList()
-    {
-        $pageSize = request()->get('limit', 10);
-        $list = $this->service->getChatList(request()->all(), $pageSize);
-        $message = array(
-            "msg" => '操作成功',
-            "code" => 0,
-            "data" => isset($list['list'])? $list['list']:[],
-            "count" => isset($list['total'])? $list['total']:0,
-        );
-        return $message;
-    }
-
-    /**
-     * 选项列表
-     * @return mixed
-     */
-    public function options(){
-        $result = $this->service->options();
-        return message(1002,true, $result);
-    }
-}

+ 4 - 4
app/Http/Controllers/Admin/DriverController.php

@@ -12,15 +12,15 @@
 namespace App\Http\Controllers\Admin;
 
 
-use App\Services\Common\DriverService;
+use App\Services\Common\StoreService;
 
 /**
- * 司机管理-控制器
+ * 商户管理-控制器
  * @author laravel开发员
  * @since 2020/11/11
  * @package App\Http\Controllers
  */
-class DriverController extends Backend
+class StoreController extends Backend
 {
     /**
      * 构造函数
@@ -30,7 +30,7 @@ class DriverController extends Backend
     public function __construct()
     {
         parent::__construct();
-        $this->service = new DriverService();
+        $this->service = new StoreService();
     }
 
     public function index()

+ 0 - 72
app/Http/Controllers/Api/v1/DepositController.php

@@ -1,72 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api\v1;
-
-use App\Http\Controllers\Api\webApp;
-use App\Services\Api\DepositService;
-
-/**
- * 保证金管理
- * @package App\Http\Controllers\Api
- */
-class DepositController extends webApp
-{
-
-    /**
-     * 记录
-     */
-    public function index()
-    {
-        $params =request()->post();
-        $pageSize = request()->post('pageSize', 15);
-        $params['user_id'] = isset($params['user_id'])? $params['user_id'] : $this->userId;
-        if($info = DepositService::make()->getDataList($params,$pageSize)){
-            return message(DepositService::make()->getError(), true, $info);
-        }else{
-            return message(DepositService::make()->getError(), false);
-        }
-    }
-
-    /**
-     * 充值
-     */
-    public function pay()
-    {
-        $params = request()->all();
-        if($info = DepositService::make()->pay($this->userId, $params)){
-            return message(DepositService::make()->getError(), true, $info);
-        }else{
-            return message(DepositService::make()->getError(), false);
-        }
-    }
-
-    /**
-     * 退保
-     */
-    public function refund()
-    {
-        $params = request()->all();
-        if($info = DepositService::make()->refund($this->userId, $params)){
-            return message(DepositService::make()->getError(), true, $info);
-        }else{
-            return message(DepositService::make()->getError(), false);
-        }
-    }
-
-    /**
-     * 详情
-     */
-    public function info()
-    {
-        $id = request()->post('id',0);
-        if($id<=0){
-            return message(1036, false);
-        }
-        $info = DepositService::make()->getInfo($id);
-        if($info){
-            return message(1010, true, $info);
-        }else{
-            return message(1009, false);
-        }
-    }
-}

+ 0 - 39
app/Http/Controllers/Api/v1/MessageController.php

@@ -1,39 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api\v1;
-
-use App\Http\Controllers\Api\webApp;
-use App\Services\Api\MessageService;
-
-/**
- * 消息管理
- * Class MessageController
- * @package App\Http\Controllers\Api
- */
-class MessageController extends webApp
-{
-    /**
-     * 消息记录
-     * @return array
-     */
-    public function index()
-    {
-        $params = request()->post();
-        $pageSize = request()->post('pageSize', 20);
-        $datas = MessageService::make()->getDataList($params,$pageSize);
-        return message(1010, true, $datas);
-    }
-
-    /**
-     * 站内推送消息历史
-     * @return array|mixed
-     */
-    public function history()
-    {
-        $params = request()->post();
-        $pageSize = request()->post('pageSize', 20);
-        $params['user_id'] = $this->userId;
-        $datas = MessageService::make()->getDataList($params, $pageSize);
-        return message(1010, true, $datas);
-    }
-}

+ 37 - 0
app/Models/GoodsCategoryModel.php

@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+/**
+ * 商品分类管理-模型
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Models
+ */
+class GoodsCategoryModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'goods_categorys';
+
+    // 封面图
+    public function getIconAttribute($value)
+    {
+        $thumb = $value? get_image_url($value) : get_image_url('/images/goods/goods.jpeg');
+        return $thumb;
+    }
+
+    public function setIconAttribute($value)
+    {
+
+        return $value? get_image_path($value) : '';
+    }
+}

+ 13 - 11
app/Models/DepositModel.php

@@ -12,24 +12,26 @@
 namespace App\Models;
 
 /**
- * 保证金-模型
+ * 商家店铺管理-模型
  * @author laravel开发员
  * @since 2020/11/11
- * Class CityModel
  * @package App\Models
  */
-class DepositModel extends BaseModel
+class StoreModel extends BaseModel
 {
     // 设置数据表
-    protected $table = 'deposit_orders';
+    protected $table = 'stores';
 
-    /**
-     * 用户
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
-     */
-    public function user()
+    // 封面图
+    public function getLogoAttribute($value)
     {
-        return $this->hasOne(MemberModel::class, 'id','user_id')
-            ->select(['id','mobile','nickname','realname','status']);
+        $thumb = $value? get_image_url($value) : get_image_url('/images/store/logo.jpeg');
+        return $thumb;
+    }
+
+    public function setLogoAttribute($value)
+    {
+
+        return $value? get_image_path($value) : '';
     }
 }

+ 0 - 424
app/Services/Common/DepositService.php

@@ -1,424 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services\Common;
-
-use App\Models\AccountLogModel;
-use App\Models\ActionLogModel;
-use App\Models\ConfigModel;
-use App\Models\DepositModel;
-use App\Models\MemberModel;
-use App\Models\MessageModel;
-use App\Services\BaseService;
-use App\Services\ConfigService;
-use App\Services\PaymentService;
-use App\Services\RedisService;
-use App\Services\SmsService;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 保证金订单管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Api
- */
-class DepositService extends BaseService
-{
-    // 静态对象
-    protected static $instance = null;
-
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function __construct()
-    {
-        $this->model = new DepositModel();
-    }
-
-    /**
-     * 静态入口
-     */
-    public static function make()
-    {
-        if (!self::$instance) {
-            self::$instance = new static();
-        }
-        return self::$instance;
-    }
-
-    /**
-     * 列表数据
-     * @param $params
-     * @param int $pageSize
-     * @return array
-     */
-    public function getDataList($params, $pageSize = 15)
-    {
-        $query = $this->getQuery($params);
-        $refundStatus = isset($params['refund_status']) ? $params['refund_status'] : -1;
-
-        $model = clone $query;
-        $counts = [
-            'count'=> $model->count('a.id'),
-            'total'=> $model->sum($refundStatus>=0?'a.refund_money':'a.money'),
-        ];
-
-
-        if($refundStatus==0){
-            $query->orderBy('a.refund_status', 'asc')
-                ->orderBy('a.refund_at', 'desc')
-                ->orderBy('a.id', 'desc');
-        }else if($refundStatus>0){
-            $query->orderBy('a.refund_at', 'desc')
-                ->orderBy('a.id', 'desc');
-        }else{
-            $query->orderBy('a.create_time', 'desc')
-                ->orderBy('a.id', 'desc');
-        }
-
-
-        $field = ["a.*"];
-        $list = $query->select($field)
-            ->paginate($pageSize > 0 ? $pageSize : 9999999);
-        $list = $list ? $list->toArray() : [];
-        if ($list) {
-            foreach ($list['data'] as &$item){
-                $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H:i:s') : '';
-                $item['time_text'] = $item['create_time']? datetime($item['create_time'],'Y年m月d日') : '';
-            }
-            $datas = [
-                'pageSize' => $pageSize,
-                'total' => isset($list['total']) ? $list['total'] : 0,
-                'list' => isset($list['data']) ? $list['data'] : [],
-                'counts' => $counts,
-            ];
-
-            // 消息已读
-            MessageModel::where(['is_read'=>2,'type'=>$refundStatus>=0?4:3,'mark'=>1])->update(['is_read'=>1,'update_time'=>time()]);
-        }
-        return $datas;
-    }
-
-
-    /**
-     * 查询条件
-     * @param $params
-     * @return mixed
-     */
-    public function getQuery($params)
-    {
-        $where = ['a.status' => 0, 'a.mark' => 1];
-        $status = isset($params['status']) ? $params['status'] : 0;
-        if ($status > 0) {
-            $where['a.status'] = $status;
-        } else {
-            unset($where['a.status']);
-        }
-
-        $model = $this->model->with(['user'])->from('deposit_orders as a')
-            ->leftJoin('member as b','b.id','=','a.user_id')
-            ->where($where)
-            ->where(function ($query) use ($params) {
-                $refundNo= isset($params['refund_no']) ? trim($params['refund_no']) : '';
-                $orderNo = isset($params['order_no']) ? trim($params['order_no']) : '';
-                $refundStatus = isset($params['refund_status']) ? $params['refund_status'] : -1;
-                if($refundNo){
-                    $query->where(function($query) use($refundNo){
-                        $query->where('a.refund_no', 'like', "%{$refundNo}%")
-                            ->orWhere('a.refund_transaction_id', 'like', "%{$refundNo}%");
-                    });
-                }else if($orderNo){
-                    $query->where(function($query) use($orderNo){
-                        $query->where('a.order_no', 'like', "%{$orderNo}%")
-                            ->orWhere('a.transaction_id', 'like', "%{$orderNo}%");
-                    });
-                }
-
-                if($refundStatus==0){
-                    $query->where(['a.status'=>3])->where('a.refund_status','>',1);
-                }else if($refundStatus>0){
-                    $query->where(['a.status'=>3])->where('a.refund_status', $refundStatus);
-                }
-
-                // 用户
-                $account = isset($params['account']) ? trim($params['account']) : '';
-                if ($account) {
-                    $query->where(function ($query) use ($account) {
-                        $query->where('b.mobile', 'like', "%{$account}%")
-                            ->orWhere('b.nickname', 'like', "%{$account}%");
-                    });
-                }
-
-                $userId = isset($params['user_id']) ? intval($params['user_id']) : 0;
-                if ($userId>0) {
-                    $query->where('a.user_id', $userId);
-                }
-            });
-
-        return $model;
-    }
-
-    /**
-     * 详情信息
-     * @param $id
-     * @return mixed
-     */
-    public function getInfo($id)
-    {
-        $cacheKey = "caches:deposit:info_{$id}";
-        $info = RedisService::get($cacheKey);
-        if($info){
-            return $info;
-        }
-
-        $info = $this->model->with(['user'])->where(['order_id' => $id])->first();
-        $info = $info? $info->toArray() :[];
-        if($info){
-            RedisService::set($cacheKey, $info, rand(5,10));
-        }
-        return $info;
-    }
-
-    /**
-     * 获取保证金配置
-     * @return array
-     */
-    public function getSetting()
-    {
-        $config = ConfigService::make()->getConfigByGroup(5);
-        return [
-            'deposit_money'=> isset($config['deposit_money']['value'])? $config['deposit_money']['value'] : '',
-            'deposit_desc'=> isset($config['deposit_desc']['value'])? $config['deposit_desc']['value'] : '',
-            'deposit_refund_desc'=> isset($config['deposit_refund_desc']['value'])? $config['deposit_refund_desc']['value'] : '',
-        ];
-    }
-
-    /**
-     * 保存保证金配置
-     * @return array
-     */
-    public function saveSetting($userId, $params)
-    {
-        $check = false;
-        $names = ['deposit_money'=>'接单保证金','deposit_desc'=>'保证金充值说明','deposit_refund_desc'=>'保证金退保说明'];
-        $notes = ['deposit_money'=>'接单保证金金额/元。'];
-        foreach ($params as $key => $value){
-            $name = isset($names[$key])? $names[$key] : '';
-            $note = isset($notes[$key])? $notes[$key] : '';
-            if($name){
-                $check = true;
-                $oldValue = ConfigService::make()->getConfigByCode($key);
-                if($value && $oldValue != $value){
-                    $id = ConfigModel::where(['code'=> $key,'mark'=>1])->value('id');
-                    if($id){
-                        ConfigModel::where(['id'=> $id])->update(['value'=>$value, 'update_time'=>time()]);
-                    }else{
-                        ConfigModel::insetGetId(['title'=> $name,'config_group_id'=>5,'type'=>$key=='deposit_money'? 'readonly': 'textarea','code'=>$key,'value'=>$value,'note'=>$note,'create_time'=>time(),'status'=>1,'mark'=>1, 'update_time'=>time()]);
-                    }
-
-                    // 清除缓存
-                    RedisService::clear("caches:config:code:".$key);
-                }
-            }
-        }
-
-        if(!$check){
-            $this->error = '未修改';
-            return false;
-        }
-
-        $this->error = '设置成功';
-        RedisService::clear("caches:config:groups:5");
-        RedisService::keyDel("caches:config:app*");
-        RedisService::keyDel(env('APP_NAME')."_cache:*");
-        ActionLogModel::setRecord(session('userId'), ['type' => 1, 'title' => "修改保证金配置", 'content' => json_encode(request()->post(), 256), 'module' => 'admin']);
-        ActionLogModel::record();
-        return true;
-    }
-
-    /**
-     * 审核
-     * @param $adminId
-     * @param $params
-     * @return array|false
-     */
-    public function confirm($adminId, $params)
-    {
-        $id = isset($params['id'])? intval($params['id']) : 0;
-        $status = isset($params['refund_status'])? intval($params['refund_status']) : 0;
-        $confirmRemark = isset($params['refund_confirm_remark'])? trim($params['refund_confirm_remark']) : '';
-
-        $info = $this->model->with(['user'])->where(['id'=> $id,'mark'=>1])->first();
-        $userInfo = isset($info['user'])? $info['user'] : [];
-        $orderStatus = isset($info['refund_status'])? $info['refund_status'] : 0;
-        $orderUserId = isset($info['user_id'])? $info['user_id'] : 0;
-        $refundMoney = isset($info['refund_money'])? $info['refund_money'] : 0;
-        if(empty($info) || empty($userInfo) || $orderUserId<=0 || $refundMoney<=0){
-            $this->error = '退保申请信息不存在或参数错误';
-            return false;
-        }
-
-        if($orderStatus != 1){
-            $this->error = '退保订单状态不可操作';
-            return false;
-        }
-
-        if(!in_array($status,[2,3])){
-            $this->error = '退保审核状态错误';
-            return false;
-        }
-
-        if($status == 3 && empty($confirmRemark)){
-            $this->error = '请填写审核驳回备注';
-            return false;
-        }
-
-        DB::beginTransaction();
-        $updateOrder = ['refund_status'=>$status,'confirm_admin_id'=>$adminId,'update_time'=>time(),'refund_confirm_remark'=>$confirmRemark];
-
-        // 如果驳回
-        if($status == 3){
-            $updateData = ['deposit'=> $refundMoney,'update_time'=>time()];
-            if(!MemberModel::where(['id'=> $orderUserId])->update($updateData)){
-                DB::rollBack();
-                $this->error = '退保审核处理失败';
-                return false;
-            }
-        }else if($status == 2){
-            // 线上直接退款逻辑
-            $payType = isset($info['pay_type'])? $info['pay_type'] : 0;
-            $order = [
-                'money' => $refundMoney,
-                'pay_type' => $payType,
-                'order_no' => isset($info['order_no'])? $info['order_no'] : '',
-                'out_trade_no' => isset($info['refund_no'])? $info['refund_no'] : '',
-                'transaction_id' => isset($info['transaction_id'])? $info['transaction_id'] : '',
-                'remark'=> '退保'
-            ];
-            if(!PaymentService::make()->refund($order)){
-                DB::rollBack();
-                $this->error = '退保退款处理失败';
-                return false;
-            }
-
-            // 支付宝调用成功直接完成
-            if($payType == 20){
-                $updateOrder['refund_status'] = 4;
-                $updateOrder['remark'] = '已退保';
-            }
-        }
-
-        if(!$this->model->where(['id'=> $id])->update($updateOrder)){
-            DB::rollBack();
-            $this->error = '退款审核处理失败';
-            return false;
-        }
-
-
-        DB::commit();
-        $this->error = '退款审核成功';
-        ActionLogModel::setRecord(session('userId'), ['type' => 1, 'title' => "保证金退保审核", 'content' => json_encode(request()->post(), 256), 'module' => 'admin']);
-        ActionLogModel::record();
-        return ['id'=>$id,'money'=>$refundMoney,'refund_status'=>$status];
-    }
-
-    /**
-     * 打款
-     * @param $adminId
-     * @param $params
-     * @return array|false
-     */
-    public function payment($adminId, $params)
-    {
-        $id = isset($params['id'])? intval($params['id']) : 0;
-
-        $info = $this->model->with(['user'])->where(['id'=> $id,'mark'=>1])->first();
-        $userInfo = isset($info['user'])? $info['user'] : [];
-        $orderStatus = isset($info['refund_status'])? $info['refund_status'] : 0;
-        $orderUserId = isset($info['user_id'])? $info['user_id'] : 0;
-        $refundMoney = isset($info['refund_money'])? $info['refund_money'] : 0;
-        if(empty($info) || empty($userInfo) || $orderUserId<=0 || $refundMoney<=0){
-            $this->error = '退保申请信息不存在或参数错误';
-            return false;
-        }
-
-        if($orderStatus == 4){
-            $this->error = '退保订单已打款';
-            return false;
-        }
-
-        if($orderStatus != 2){
-            $this->error = '退保订单状态不可操作';
-            return false;
-        }
-
-        // 线上直接退款逻辑
-        $payType = isset($info['pay_type'])? $info['pay_type'] : 0;
-        $order = [
-            'money' => $refundMoney,
-            'pay_type' => $payType,
-            'order_no' => isset($info['order_no'])? $info['order_no'] : '',
-            'out_trade_no' => isset($info['refund_no'])? $info['refund_no'] : '',
-            'transaction_id' => isset($info['transaction_id'])? $info['transaction_id'] : '',
-            'remark'=> '退保'
-        ];
-        DB::beginTransaction();
-        if(!PaymentService::make()->refund($order)){
-            DB::rollBack();
-            $this->error = '退保退款处理请求失败';
-            return false;
-        }
-
-        if($payType == 20 && !$this->model->where(['id'=> $id])->update(['refund_status'=>4,'remark'=>'已退保','update_time'=>time()])){
-            DB::rollBack();
-            $this->error = '退保退款处理失败';
-            return false;
-        }
-
-        DB::commit();
-        $this->error = '退保打款请求成功';
-
-        ActionLogModel::setRecord(session('userId'), ['type' => 1, 'title' => "保证金退款打款", 'content' => json_encode(request()->post(), 256), 'module' => 'admin']);
-        ActionLogModel::record();
-        return ['id'=>$id,'money'=>$refundMoney,'status'=>$orderStatus];
-    }
-
-    /**
-     * 统计
-     * @param int $type
-     * @return array|mixed
-     */
-    public function getTotal($type=0)
-    {
-        $cacheKey = "caches:deposit:total_{$type}";
-        $data = RedisService::get($cacheKey);
-        if($data){
-            return $data;
-        }
-
-        $data = $this->model->where(['mark'=>1])
-            ->where(function($query) use($type){
-                if($type== 1){
-                    $query->where(['status'=>3])->whereIn('refund_status',[2,4]);
-                }else {
-                    $query->where(['status'=>3]);
-                }
-            })->sum('money');
-        if($data){
-            RedisService::set($cacheKey, $data, rand(300, 600));
-        }
-
-        return $data;
-    }
-
-}

+ 0 - 1
app/Services/Common/GoodsService.php

@@ -14,7 +14,6 @@ namespace App\Services\Common;
 use App\Models\GoodsModel;
 use App\Services\BaseService;
 use App\Services\RedisService;
-use wxkxklmyt\Scws;
 
 /**
  * 商品管理-服务类

+ 123 - 0
app/Services/Common/StoreService.php

@@ -0,0 +1,123 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\GoodsModel;
+use App\Models\StoreModel;
+use App\Services\BaseService;
+use App\Services\RedisService;
+
+/**
+ * 商家店铺管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class StoreService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * AdService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new StoreModel();
+    }
+
+    /**
+     * 列表
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 15)
+    {
+        $query = $this->getQuery($params);
+        $list = $query->select(['a.*'])
+            ->orderBy('a.create_time','desc')
+            ->orderBy('a.id','desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list? $list->toArray() :[];
+        if($list){
+            foreach($list['data'] as &$item){
+                $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H.i.s') : '';
+            }
+        }
+
+        return [
+            'pageSize'=> $pageSize,
+            'total'=>isset($list['total'])? $list['total'] : 0,
+            'list'=> isset($list['data'])? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 查询
+     * @param $params
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public function getQuery($params)
+    {
+        $where = ['a.mark' => 1];
+        $status = isset($params['status'])? $params['status'] : 1;
+        if($status>0){
+            $where['a.status'] = $status;
+        }else{
+            unset($where['a.status']);
+        }
+        $model = $this->model->with(['member'])
+            ->from('stores as a')
+            ->where($where)
+            ->where(function ($query) use($params){
+                $name = isset($params['name'])? $params['name'] : '';
+                if($name){
+                    $query->where(function ($query) use ($name){
+                        $query->where('a.name','like',"%{$name}%");
+                    });
+                }
+
+                $phone = isset($params['phone'])? $params['phone'] : '';
+                if($phone){
+                    $query->where(function ($query) use ($phone){
+                        $query->where('a.phone',$phone);
+                    });
+                }
+            });
+
+        return $model;
+    }
+
+
+    /**
+     * 添加或编辑
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        $data = request()->all();
+        // 图片处理
+        if(isset($data['logo'])){
+            $data['logo'] = get_image_path($data['logo']);
+        }
+
+        if(empty($data['name'])){
+            return  message('请填写店铺名称',false);
+        }
+
+        return parent::edit($data);
+    }
+
+}

+ 244 - 377
app/Services/PaymentService.php

@@ -12,12 +12,9 @@
 namespace App\Services;
 
 use App\Models\AccountLogModel;
-use App\Models\BalanceLogModel;
-use App\Models\DepositModel;
 use App\Models\MemberModel;
-use App\Models\MessageModel;
+use App\Models\OrderModel;
 use App\Models\PaymentModel;
-use App\Services\Api\MessageService;
 use Illuminate\Support\Facades\DB;
 use Yansongda\Pay\Pay;
 use Yansongda\Pay\Provider\Wechat;
@@ -60,17 +57,21 @@ class PaymentService extends BaseService
 
     /**
      * 创建支付
-     * @param string $scene 场景,deposit-保证金,depositRefund-保证金退款,withdraw-提现
+     * @param string $scene 场景,vip-VIP会员
      * @param int $payType
+     * @param int $isMin 是否是小程序
      * @return false|\Yansongda\Pay\Provider\Alipay|Wechat
      */
-    public function createPay($scene, $payType = 10)
+    public function createPay($scene, $payType = 10, $payPt= '')
     {
         $config = ConfigService::make()->getConfigOptionByGroup(6);
         if ($payType == 10) {
             $appid = isset($config['wxpay_appid']) ? $config['wxpay_appid'] : '';
+            $mpAppid = isset($config['wxpay_mp_appid']) ? $config['wxpay_mp_appid'] : '';
+            $minAppid = isset($config['wxpay_min_appid']) ? $config['wxpay_min_appid'] : '';
             $mchid = isset($config['wxpay_mchd']) ? $config['wxpay_mchd'] : '';
             $secretV3Key = isset($config['wxpay_key_v3']) ? $config['wxpay_key_v3'] : '';
+            $secretV2Key = isset($config['wxpay_key_v2']) ? $config['wxpay_key_v2'] : '';
             $wxpaySecretCert = isset($config['wxpay_secret_cert']) ? $config['wxpay_secret_cert'] : '';
             $wxpayPublicCert = isset($config['wxpay_public_cert']) ? $config['wxpay_public_cert'] : '';
             if (empty($appid) || empty($mchid) || empty($secretV3Key)) {
@@ -81,15 +82,32 @@ class PaymentService extends BaseService
             // 支付参数
             $payConfig = config('payment.wechat');
             $payConfig['wechat']['default']['mch_id'] = $mchid;
-            $payConfig['wechat']['default']['app_id'] = $appid;
-            $payConfig['wechat']['default']['mch_secret_key'] = $secretV3Key;
+            if($payPt == 'min'){
+                // 小程序支付
+                $payConfig['wechat']['default']['mini_app_id'] = $minAppid? $minAppid : $appid;
+            }else if($payPt == 'mp'){
+                // 公众号
+                $payConfig['wechat']['default']['mp_app_id'] = $mpAppid? $mpAppid : $appid;
+            }else{
+                // APP支付
+                $payConfig['wechat']['default']['app_id'] = $appid;
+            }
+
+            if($secretV3Key){
+                $payConfig['wechat']['default']['mch_secret_key'] = $secretV3Key;
+            }else if($secretV2Key){
+                $payConfig['wechat']['default']['mch_secret_key_v2'] = $secretV2Key;
+            }
+
             if ($wxpaySecretCert) {
                 $payConfig['wechat']['default']['mch_secret_cert'] = $wxpaySecretCert;
             }
             if ($wxpayPublicCert) {
                 $payConfig['wechat']['default']['mch_public_cert_path'] = $wxpayPublicCert;
             }
-            $payConfig['wechat']['default']['notify_url'] = url('/api/notify/' . $scene . '/10');
+            //$payConfig['wechat']['default']['notify_url'] = url('/api/notify/' . $scene . '/10');
+            $payConfig['wechat']['default']['notify_url'] = url(env('APP_URL').'api/notify/' . $scene . '/10');
+
             $this->config = $payConfig;
 
             return Pay::wechat($payConfig);
@@ -129,13 +147,90 @@ class PaymentService extends BaseService
     }
 
     /**
+     * 微信小程序支付
+     * @param $userInfo
+     * @param $order
+     * @param string $scene
+     * @return false|\Yansongda\Supports\Collection
+     */
+    public function minPay($userInfo, $order, $scene = 'pay')
+    {
+        $amount = isset($order['pay_money']) ? $order['pay_money'] : 0;
+        $openid = isset($order['openid']) ? $order['openid'] : '';
+        if ($amount < 0) {
+            $this->error = 2615;
+            return false;
+        }
+
+        if(empty($openid)){
+            $this->error = 2614;
+            return false;
+        }
+
+        $outTradeNo = isset($order['order_no']) && $order['order_no'] ? $order['order_no'] : get_order_num('PR');
+        // 是否调用过支付,是则用新的支付单号
+        if ($outTradeNo && $this->model->where(['out_trade_no' => $outTradeNo, 'mark' => 1])->value('id')) {
+            $outTradeNo = $outTradeNo . date('is') . rand(1, 9);
+        }
+        $body = isset($order['body']) ? $order['body'] : '';
+        $payData = [
+            'out_trade_no' => $outTradeNo,
+            'description' => $body ? $body : '订单支付',
+            'amount' => [
+                'total' => intval($amount * 100),
+                'currency' => 'CNY'
+            ],
+            'payer' => [
+                'openid' => $openid,
+            ],
+        ];
+
+        // 创建支付
+        try {
+            $pay = $this->createPay($scene, 10, 'min');
+            RedisService::set("caches:payments:wechat:{$scene}_{$outTradeNo}", ['order' => $order, 'config' => $this->config], 7200);
+            if (empty($pay)) {
+                $this->error = 2616;
+                return false;
+            }
+
+            $pay = $pay->mini($payData);
+        } catch (\Exception $exception) {
+            RedisService::set("caches:payments:wechat:{$scene}_{$outTradeNo}_error", ['order' => $order,'error'=>$exception->getTrace(), 'config' => $this->config], 7200);
+            $this->error = $exception->getMessage();
+            return false;
+        }
+
+        if ($pay->package) {
+            $data = [
+                'user_id' => $userInfo['id'],
+                'out_trade_no' => $outTradeNo,
+                'order_no' => $order['order_no'],
+                'params' => json_encode($pay, 256),
+                'total_fee' => $amount,
+                'pay_type' => 10,
+                'create_time' => time(),
+                'status' => 2,
+                'mark' => 1,
+            ];
+            if ($this->model->insertGetId($data)) {
+                $this->error = 2617;
+                return $pay;
+            }
+        }
+
+        $this->error = 2618;
+        return false;
+    }
+
+    /**
      * 微信支付
      * @param $userInfo
      * @param $order
      * @param string $scene
      * @return false|\Yansongda\Supports\Collection
      */
-    public function wechatPay($userInfo, $order, $scene = 'deposit')
+    public function wechatPay($userInfo, $order, $scene = 'pay')
     {
         $amount = isset($order['pay_money']) ? $order['pay_money'] : 0;
         if ($amount < 0) {
@@ -269,305 +364,186 @@ class PaymentService extends BaseService
         $payAt = '';
         $notifyData = [];
 
-        // 微信支付
-        if ($payType == 10) {
-            $resource = isset($data['resource']) ? $data['resource'] : [];
-            $ciphertext = isset($resource['ciphertext']) ? $resource['ciphertext'] : [];
-            $tradeStatus = isset($ciphertext['trade_state']) ? $ciphertext['trade_state'] : '';
-            if ($tradeStatus != 'SUCCESS') {
-                $this->error = 2622;
-                return false;
-            }
-
-            $outTradeNo = isset($ciphertext['out_trade_no']) ? $ciphertext['out_trade_no'] : '';
-            $transactionId = isset($ciphertext['transaction_id']) ? $ciphertext['transaction_id'] : '';
-            if (empty($outTradeNo)) {
-                $this->error = 2623;
-                return false;
-            }
-            $payAt = isset($ciphertext['success_time']) ? date('Y-m-d H:i:s', strtotime($ciphertext['success_time'])) : date('Y-m-d H:i:s');
-            $amount = isset($ciphertext['amount']) ? $ciphertext['amount'] : [];
-            $payTotal = isset($amount['total']) ? moneyFormat($amount['total'] / 100, 3) : 0;
-            $notifyData = $ciphertext;
-            if ($payTotal <= 0) {
-                $this->error = 2624;
-                return false;
-            }
-
-        } // 支付宝支付
-        else if ($payType == 20) {
-            // TRADE_SUCCESS
-            $tradeStatus = isset($data['trade_status']) ? $data['trade_status'] : '';
-            if ($tradeStatus != 'TRADE_SUCCESS' && $tradeStatus != 'TRADE_FINISHED') {
-                $this->error = 2622;
-                return false;
-            }
-
-            $outTradeNo = isset($data['out_trade_no']) ? $data['out_trade_no'] : '';
-            if (empty($outTradeNo)) {
-                $this->error = 2623;
-                return false;
-            }
-
-            $payTotal = isset($data['total_amount']) ? floatval($data['total_amount']) : 0;
-            $transactionId = isset($data['trade_no']) ? trim($data['trade_no']) : '';
-            $payAt = isset($data['send_pay_date']) ? trim($data['send_pay_date']) : date('Y-m-d H:i:s');
-            $notifyData = $data;
-            if ($payTotal <= 0) {
-                $this->error = 2624;
-                return false;
-            }
-        }
-
-        // 支付信息
-        $paymentInfo = $this->model->with(['user'])->where(['out_trade_no' => $outTradeNo, 'mark' => 1])
-            ->select(['user_id', 'order_no', 'pay_type', 'total_fee', 'status'])
-            ->first();
-        $status = isset($paymentInfo['status']) ? $paymentInfo['status'] : 0;
-        $totalFee = isset($paymentInfo['total_fee']) ? $paymentInfo['total_fee'] : 0;
-        $paymentPayType = isset($paymentInfo['pay_type']) ? $paymentInfo['pay_type'] : 0;
-        $orderNo = isset($paymentInfo['order_no']) ? $paymentInfo['order_no'] : '';
-        $payUserId = isset($paymentInfo['user_id'])? $paymentInfo['user_id'] : 0;
-        $payUser = isset($paymentInfo['user'])? $paymentInfo['user'] : [];
-        $username = isset($payUser['mobile'])? $payUser['mobile'] : $payUserId;
-        if (empty($paymentInfo) || empty($orderNo) || $payUserId<=0) {
-            $this->error = 2625;
-            return false;
-        }
+        try {
 
-        // 验证支付状态
-        if ($status == 1) {
-            $this->error = 2626;
-            return false;
-        }
+            // 微信支付
+            if ($payType == 10) {
+                $resource = isset($data['resource']) ? $data['resource'] : [];
+                $ciphertext = isset($resource['ciphertext']) ? $resource['ciphertext'] : [];
+                $tradeStatus = isset($ciphertext['trade_state']) ? $ciphertext['trade_state'] : '';
+                if ($tradeStatus != 'SUCCESS') {
+                    $this->error = 2622;
+                    return false;
+                }
 
-        // 验证支付方式
-        if ($paymentPayType != $payType) {
-            $this->error = 2627;
-            return false;
-        }
+                $outTradeNo = isset($ciphertext['out_trade_no']) ? $ciphertext['out_trade_no'] : '';
+                $transactionId = isset($ciphertext['transaction_id']) ? $ciphertext['transaction_id'] : '';
+                if (empty($outTradeNo)) {
+                    $this->error = 2623;
+                    return false;
+                }
+                $payAt = isset($ciphertext['success_time']) ? date('Y-m-d H:i:s', strtotime($ciphertext['success_time'])) : date('Y-m-d H:i:s');
+                $amount = isset($ciphertext['amount']) ? $ciphertext['amount'] : [];
+                $payTotal = isset($amount['total']) ? moneyFormat($amount['total'] / 100, 3) : 0;
+                $notifyData = $ciphertext;
+                if ($payTotal <= 0) {
+                    $this->error = 2624;
+                    return false;
+                }
 
-        if ($payTotal != $totalFee || $payTotal <= 0) {
-            $this->error = 2628;
-            return false;
-        }
+            } // 支付宝支付
+            else if ($payType == 20) {
+                // TRADE_SUCCESS
+                $tradeStatus = isset($data['trade_status']) ? $data['trade_status'] : '';
+                if ($tradeStatus != 'TRADE_SUCCESS' && $tradeStatus != 'TRADE_FINISHED') {
+                    $this->error = 2622;
+                    return false;
+                }
 
-        // 删除久远旧记录
-        $this->model->where(['mark' => 1])->where('create_time','<=', time() - 60 * 86400)->delete();
+                $outTradeNo = isset($data['out_trade_no']) ? $data['out_trade_no'] : '';
+                if (empty($outTradeNo)) {
+                    $this->error = 2623;
+                    return false;
+                }
 
-        // 更新订单数据
-        DB::beginTransaction();
-        $updateData = ['transaction_id' => $transactionId, 'result' => json_encode($notifyData, 256), 'pay_at' => $payAt, 'status' => 1, 'update_time' => time()];
-        if (!$this->model->where(['out_trade_no' => $outTradeNo, 'mark' => 1])->update($updateData)) {
-            $this->error = 2632;
-            DB::rollBack();
-            return false;
-        }
+                $payTotal = isset($data['total_amount']) ? floatval($data['total_amount']) : 0;
+                $transactionId = isset($data['trade_no']) ? trim($data['trade_no']) : '';
+                $payAt = isset($data['send_pay_date']) ? trim($data['send_pay_date']) : date('Y-m-d H:i:s');
+                $notifyData = $data;
+                if ($payTotal <= 0) {
+                    $this->error = 2624;
+                    return false;
+                }
+            }
 
-        /* TODO 订单验证和状态处理 */
-        // 充值订单
-        if ($scene == 'deposit') {
-            $orderInfo = DepositModel::where(['order_no' => $orderNo, 'type' => 1, 'mark' => 1])
-                ->select(['id as order_id', 'user_id', 'order_no', 'money as pay_money','before_money', 'pay_at as pay_time', 'pay_status', 'status'])
+            // 支付信息
+            $paymentInfo = $this->model->with(['user'])->where(['out_trade_no' => $outTradeNo, 'mark' => 1])
+                ->select(['user_id', 'order_no', 'pay_type', 'total_fee', 'status'])
                 ->first();
-            $orderStatus = isset($orderInfo['status']) ? $orderInfo['status'] : 0;
-            // 验证订单
-            if (empty($orderInfo)) {
-                DB::rollBack();
-                $this->error = 2629;
+            $status = isset($paymentInfo['status']) ? $paymentInfo['status'] : 0;
+            $totalFee = isset($paymentInfo['total_fee']) ? $paymentInfo['total_fee'] : 0;
+            $paymentPayType = isset($paymentInfo['pay_type']) ? $paymentInfo['pay_type'] : 0;
+            $orderType = isset($paymentInfo['order_type']) ? $paymentInfo['order_type'] : 0;
+            $orderNo = isset($paymentInfo['order_no']) ? $paymentInfo['order_no'] : '';
+            $payUserId = isset($paymentInfo['user_id']) ? $paymentInfo['user_id'] : 0;
+            if (empty($paymentInfo) || empty($orderNo) || $payUserId <= 0) {
+                $this->error = 2625;
                 return false;
             }
 
-            // 订单状态
-            if ($orderStatus != 1) {
-                DB::rollBack();
-                $this->error = 2630;
+            // 验证支付状态
+            if ($status == 1) {
+                $this->error = 2626;
                 return false;
             }
 
-            $updateData = ['pay_status' => 2, 'pay_at' => $payAt, 'transaction_id' => $transactionId, 'status' => 3, 'update_time' => time()];
-            if (!DepositModel::where(['order_no' => $orderNo, 'type' => 1, 'mark' => 1])->update($updateData)) {
-                $this->error = 2633;
-                DB::rollBack();
+            // 验证支付方式
+            if ($paymentPayType != $payType) {
+                $this->error = 2627;
                 return false;
             }
 
-        } // 保证金退款
-        else if ($scene == 'depositRefund') {
-            $orderInfo = DepositModel::where(['refund_no' => $orderNo, 'type' => 1, 'mark' => 1])
-                ->select(['id as order_id', 'user_id', 'refund_no as order_no', 'refund_money as pay_money','before_money', 'pay_at as pay_time', 'refund_status as status'])
-                ->first();
-            $orderStatus = isset($orderInfo['status']) ? $orderInfo['status'] : 0;
-            // 验证订单
-            if (empty($orderInfo)) {
-                DB::rollBack();
-                $this->error = 2629;
+            if ($payTotal != $totalFee || $payTotal <= 0) {
+                $this->error = 2628;
                 return false;
             }
 
-            // 订单状态
-            if ($orderStatus != 2) {
-                DB::rollBack();
-                $this->error = 2639;
-                return false;
-            }
+            // 删除久远旧记录
+            $this->model->where(['mark' => 1])->where('create_time', '<=', time() - 60 * 86400)->delete();
 
-            // 订单打款状态
-            if ($orderStatus == 4) {
+            // 更新订单数据
+            DB::beginTransaction();
+            $updateData = ['transaction_id' => $transactionId, 'result' => json_encode($notifyData, 256), 'pay_at' => $payAt, 'status' => 1, 'update_time' => time()];
+            if (!$this->model->where(['out_trade_no' => $outTradeNo, 'mark' => 1])->update($updateData)) {
+                $this->error = 2632;
                 DB::rollBack();
-                $this->error = 2630;
                 return false;
             }
 
-            $updateData = ['refund_pay_at' => $payAt, 'refund_transaction_id' => $transactionId, 'refund_status' => 4, 'update_time' => time()];
-            if (!DepositModel::where(['refund_no' => $orderNo, 'type' => 1, 'mark' => 1])->update($updateData)) {
-                $this->error = 2633;
-                DB::rollBack();
-                return false;
-            }
-        } else if($scene == 'withdraw'){
-            $orderInfo = BalanceLogModel::where(['order_no' => $orderNo, 'type' => 2, 'mark' => 1])
-                ->select(['id as order_id', 'user_id', 'order_no', 'money as pay_money','before_money', 'pay_at as pay_time', 'pay_status', 'status'])
-                ->first();
-            $orderStatus = isset($orderInfo['status']) ? $orderInfo['status'] : 0;
-            $payStatus = isset($orderInfo['pay_status']) ? $orderInfo['pay_status'] : 0;
-            // 验证订单
-            if (empty($orderInfo)) {
-                DB::rollBack();
-                $this->error = 2629;
-                return false;
-            }
+            /* TODO 订单验证和状态处理 */
+            $orderInfo = [];
+            // 商城订单支付
+            if ($scene == 'shop') {
+                $orderInfo = OrderModel::with(['member'])->where(['order_no' => $orderNo, 'mark' => 1])
+                    ->select(['id as order_id', 'user_id', 'expired_at', 'order_no', 'total as pay_money', 'pay_at as pay_time', 'remark', 'status'])
+                    ->first();
+                $orderStatus = isset($orderInfo['status']) ? $orderInfo['status'] : 0;
+                // 验证订单
+                if (empty($orderInfo)) {
+                    DB::rollBack();
+                    $this->error = 2629;
+                    return false;
+                }
 
-            // 订单状态
-            if ($orderStatus != 2) {
-                DB::rollBack();
-                $this->error = 2639;
-                return false;
-            }
+                // 订单状态
+                if ($orderStatus != 1) {
+                    DB::rollBack();
+                    $this->error = 2630;
+                    return false;
+                }
 
-            // 订单打款状态
-            if ($payStatus != 1) {
-                DB::rollBack();
-                $this->error = 2630;
-                return false;
-            }
+                $updateData = ['pay_at' => $payAt, 'transaction_id' => $transactionId, 'status' => 2, 'update_time' => time()];
+                if (!OrderModel::where(['order_no' => $orderNo, 'mark' => 1])->update($updateData)) {
+                    $this->error = 2633;
+                    DB::rollBack();
+                    return false;
+                }
 
-            $updateData = ['pay_status' => 2, 'pay_at' => $payAt, 'transaction_id' => $transactionId, 'update_time' => time()];
-            if (!BalanceLogModel::where(['order_no' => $orderNo, 'type' => 2, 'mark' => 1])->update($updateData)) {
-                $this->error = 2633;
-                DB::rollBack();
-                return false;
             }
-        }
-
-        // TODO 场景业务回调处理
-        $pushData = []; // 推送消息数据
-        $orderUserId = isset($orderInfo['user_id']) ? $orderInfo['user_id'] : 0;
-        RedisService::set("caches:notify:{$orderNo}_{$scene}:data", ['order' => $orderInfo, 'notify' => $data], 7200);
-        switch ($scene) {
-            case 'deposit': // 保证金充值
-                $updateData = ['deposit'=>DB::raw("deposit + {$payTotal}"),'update_time'=>time()];
-                if(!MemberModel::where(['id'=> $orderUserId,'mark'=>1])->update($updateData)){
+            // 退款
+            else if ($scene == 'refund') {
+                $orderInfo = OrderModel::where(['order_no' => $orderNo, 'mark' => 1])
+                    ->select(['id as order_id', 'user_id', 'order_no', 'total as pay_money', 'remark','refund_remark', 'pay_at as pay_time', 'refund_status as status'])
+                    ->first();
+                $refundRemark = isset($orderInfo['refund_remark']) ? $orderInfo['refund_remark'] : 'refund_remark';
+                $orderStatus = isset($orderInfo['status']) ? $orderInfo['status'] : 0;
+                // 验证订单
+                if (empty($orderInfo)) {
                     DB::rollBack();
-                    $this->error = 2180;
+                    $this->error = 2629;
                     return false;
                 }
 
-                // 缴纳保证金消息
-                $message = "用户{$username}充值了{$payTotal}元保证金";
-                $msgData = [
-                    'from_uid' => $orderUserId,
-                    'to_uid' => 0,
-                    'type' => 3,// 保证金消息
-                    'msg_type' => 4,
-                    'title' => '充值保证金消息',
-                    'description' => $message,
-                    'order_no' => $orderNo,
-                    'content' => json_encode([
-                        'title'=> $message.'<span class="ele-text-primary">查看订单</span>',
-                        'order_no'=> $orderNo,
-                        'money'=> $payTotal,
-                        'date'=> date('Y-m-d H:i:s'),
-                        'user_id'=> $orderUserId,
-                        'type'=> 'deposit',
-                        'remark'=> '充值保证金',
-                    ],256),
-                    'chat_key' => getChatKey($orderUserId,0),
-                    'create_time' => time(),
-                    'update_time' => time(),
-                    'is_read' => 2,
-                    'status' => 1
-                ];
-                MessageModel::insertGetId($msgData);
-            case 'depositRefund': // 保证金退款
-                $deposit = isset($orderInfo['before_money'])? $orderInfo['before_money'] : 0;
-                // 明细处理
-                $logId = AccountLogModel::where(['user_id'=>$orderUserId,'source_order_no'=> $orderNo,'mark'=>1])->value('id');
-                $log = [
-                    'user_id' => $orderUserId,
-                    'source_order_no' => isset($orderInfo['order_no']) ? $orderInfo['order_no'] : '',
-                    'type' => $scene=='deposit'? 2 : 3,
-                    'money' => $payTotal,
-                    'before_money' => $scene=='deposit'?$deposit:0,
-                    'date'=> date('Y-m-d'),
-                    'create_time' => time(),
-                    'remark' => $scene == 'deposit'? '充值保证金' :'退保申请',
-                    'status' => 1,
-                    'mark' => 1,
-                ];
-                if($logId){
-                   AccountLogModel::where(['id'=> $logId])->update([
-                        'status'=>1,
-                        'update_time'=>time(),
-                    ]);
-                }else if (!AccountLogModel::insertGetId($log)) {
+                // 订单状态
+                if ($orderStatus != 2) {
                     DB::rollBack();
-                    $this->error = 2180;
+                    $this->error = 2639;
                     return false;
-
                 }
-                break;
-            case 'withdraw': // 收入提现// 明细处理
-                $money = isset($orderInfo['before_money'])? $orderInfo['before_money'] : 0;
-                $logId = AccountLogModel::where(['user_id'=>$orderUserId,'source_order_no'=> $orderNo,'mark'=>1])->value('id');
-                $log = [
-                    'user_id' => $orderUserId,
-                    'source_order_no' => isset($orderInfo['order_no']) ? $orderInfo['order_no'] : '',
-                    'type' => 4,
-                    'money' => $payTotal,
-                    'before_money' => $money,
-                    'date'=> date('Y-m-d'),
-                    'create_time' => time(),
-                    'remark' => '收入提现',
-                    'status' => 1,
-                    'mark' => 1,
-                ];
-                if($logId){
-                    AccountLogModel::where(['id'=> $logId])->update([
-                        'status'=>1,
-                        'update_time'=>time(),
-                    ]);
-                }else if (!AccountLogModel::insertGetId($log)) {
+
+                // 订单打款状态
+                if ($orderStatus == 1) {
                     DB::rollBack();
-                    $this->error = 2180;
+                    $this->error = 2630;
                     return false;
+                }
 
+                $updateData = ['refund_status' => 1,'refund_remark'=>$refundRemark?$refundRemark.' 已退款成功':'已退款成功', 'update_time' => time()];
+                if (!OrderModel::where(['order_no' => $orderNo, 'mark' => 1])->update($updateData)) {
+                    $this->error = 2633;
+                    DB::rollBack();
+                    return false;
                 }
-                break;
-            default:
-                DB::rollBack();
-                $this->error = 2631;
-                return false;
-        }
+            }
 
-        if ($pushData && !MessageService::make()->pushMessage($orderInfo['user_id'], $pushData)) {
-            $this->error = MessageService::make()->getError();
+            // TODO 场景业务回调处理
+            $orderUserId = isset($orderInfo['user_id']) ? $orderInfo['user_id'] : 0;
+            RedisService::set("caches:payments:notify_{$scene}:catch_{$orderNo}_{$orderUserId}", ['order' => $orderInfo, 'notify' => $data], 7200);
+            switch ($scene) {
+                case 'shop': //
+                    break;
+                default:
+                    break;
+            }
+
+            $this->error = 2638;
+            DB::commit();
+            return true;
+        } catch (\Exception $exception){
+            $this->error = $exception->getMessage();
+            RedisService::set("caches:payments:notify_{$scene}:catch_" . $orderNo.'_error', ['notify' => $data,'error' => $exception->getMessage(),'trace'=>$exception->getTrace()], 7200);
             return false;
         }
-
-
-        DB::commit();
-        return true;
     }
 
     /**
@@ -579,7 +555,7 @@ class PaymentService extends BaseService
      * @throws \Yansongda\Pay\Exception\InvalidParamsException
      * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
      */
-    public function refund($order, $scene='depositRefund')
+    public function refund($order, $scene='vip')
     {
         $money = isset($order['money'])? $order['money'] : 0;
         $payType = isset($order['pay_type'])? $order['pay_type'] : 0;
@@ -647,113 +623,4 @@ class PaymentService extends BaseService
         $this->error = 2176;
         return $refundStatus;
     }
-
-    /**
-     * 企业打款到余额
-     * @param $order 订单参数:order_no-单号,pay_money-打款金额,account-打款账号(微信openid或支付宝账号),body-打款备注
-     * @param string $scene
-     * @param int $payType
-     * @return bool
-     */
-    public function transfer($order, $scene='withdraw', $payType=10)
-    {
-        $outTradeNo = isset($order['order_no']) && $order['order_no'] ? $order['order_no'] : get_order_num('WD');
-        $body = isset($order['body']) ? $order['body'] : '';
-        $amount = isset($order['pay_money']) ? $order['pay_money'] : 0;
-        $account = isset($order['account']) ? $order['account'] : '';  // 微信openid或支付宝账号
-        $realName = isset($order['real_name']) ? $order['real_name'] : '';  // 实名
-        if ($amount < 0) {
-            $this->error = 2037;
-            return false;
-        }
-
-        if(empty($account)){
-            $this->error = $payType == 10? 2044 : 2045;
-            return false;
-        }
-
-        // 创建支付
-        $result = [];
-        try {
-            $config = ConfigService::make()->getConfigOptionByGroup(6);
-            if ($payType == 10) {
-                $appid = isset($config['wxpay_appid']) ? $config['wxpay_appid'] : '';
-                $payData = [
-                    'appid' => $appid, // 微信小程序的app_id
-                    'out_batch_no' => $outTradeNo, // 商家批次单号
-                    'batch_name' => $body? $body : '收入提现',    // 该笔批量转账的名称
-                    'batch_remark' => $body? $body : '收入提现',  // 转账说明
-                    'total_amount' => intval($amount * 100),  // 转账金额,单位:分
-                    'total_num' => 1,   // 转账总笔数
-                    'transfer_detail_list' => [
-                        [
-                            'out_detail_no' => $outTradeNo,  // 商家明细单号
-                            'transfer_amount' => intval($amount * 100),  // 转账金额
-                            'transfer_remark' => $body? $body : '收入提现',  // 单条转账备注(微信用户会收到该备注)
-                            'openid' => $account, //  转账用户的 openid
-                        ],
-                    ],
-                ];
-
-                $pay = $this->createPay($scene, $payType);
-                RedisService::set("caches:payments:wechat:{$scene}_{$outTradeNo}_pay", ['order' => $order, 'config' => $this->config], 7200);
-                if (empty($pay)) {
-                    $this->error = 2616;
-                    return false;
-                }
-
-
-                $result = $pay->transfer($payData);
-                RedisService::set("caches:payments:wechat:{$scene}_{$outTradeNo}_result", ['order' => $order,'result'=> $result, 'config' => $this->config], 7200);
-                $msg = isset($result['message'])? trim($result['message']) : '';
-                $orderId = isset($result['batch_id'])? trim($result['batch_id']) : '';
-                if(empty($orderId)){
-                    $this->error = $msg? $msg : 2046;
-                    return false;
-                }
-
-                $this->error = 2047;
-                return ['order_no'=> $outTradeNo,'order_id'=> $orderId];
-            }else if ($payType == 20){
-                $payData = [
-                    'out_biz_no'   => $outTradeNo,//商户订单号,内部订单号
-                    'trans_amount' => $amount,  //订单总金额,单位为元,精确到小数点后两位,
-                    'biz_scene'    => 'DIRECT_TRANSFER',  //描述特定的业务场景,可传的参数如下:DIRECT_TRANSFER:单笔无密转账到支付宝,B2C现金红包PERSONAL_COLLECTION:C2C现金红包-领红包
-                    'product_code' => 'TRANS_ACCOUNT_NO_PWD',  //业务产品码,单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD;收发现金红包固定为:STD_RED_PACKET;
-                    'remark'       => $body? $body : '收入提现',//业务备注
-                    'order_title'  => $body? $body : '收入提现',//转账业务的标题,用于在支付宝用户的账单里显示
-                    'payee_info'   => [
-                        'identity'      => $account,//参与方的唯一标识'208823395231'
-                        'name'      => $realName,//参与方的唯一标识'208823395231'
-                        'identity_type' => 'ALIPAY_LOGON_ID',//参与方的标识类型,目前支持如下类型:1、ALIPAY_USER_ID 支付宝的会员ID2、ALIPAY_LOGON_ID:支付宝登录号,支持邮箱和手机号格式3、ALIPAY_OPEN_ID:支付宝openid
-                    ],//收款方信息
-                ];
-                $pay = $this->createPay($scene, $payType);
-                RedisService::set("caches:payments:alipay:{$scene}_{$outTradeNo}_pay", ['order' => $order, 'config' => $this->config], 7200);
-                if (empty($pay)) {
-                    $this->error = 2616;
-                    return false;
-                }
-
-
-                $result = $pay->transfer($payData);
-                RedisService::set("caches:payments:alipay:{$scene}_{$outTradeNo}_result", ['order' => $order,'result'=> $result, 'config' => $this->config], 7200);
-                $code = isset($result['code'])? intval($result['code']) : '';
-                $msg = isset($result['sub_msg'])? trim($result['sub_msg']) : '';
-                if($code != 10000){
-                    $this->error = $msg? $msg : 2046;
-                    return false;
-                }
-                $this->error = 2047;
-                return $result;
-            }
-
-            $this->error = 2046;
-            return false;
-        } catch (\Exception $exception) {
-            RedisService::set("caches:payments:trabsfer:{$scene}_{$outTradeNo}_error", ['order' => $order,'error'=>$exception->getTrace(), 'config' => $this->config], 7200);
-            $this->error = $exception->getMessage();
-            return false;
-        }
-    }
 }

+ 4 - 4
bootstrap/cache/packages.php

@@ -26,14 +26,14 @@
   ),
   'laravel/socialite' => 
   array (
-    'providers' => 
-    array (
-      0 => 'Laravel\\Socialite\\SocialiteServiceProvider',
-    ),
     'aliases' => 
     array (
       'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite',
     ),
+    'providers' => 
+    array (
+      0 => 'Laravel\\Socialite\\SocialiteServiceProvider',
+    ),
   ),
   'laravel/tinker' => 
   array (

+ 0 - 6
composer.json

@@ -10,23 +10,17 @@
     "require": {
         "php": "^8.0",
         "ext-json": "*",
-        "alibabacloud/dysmsapi-20170525": "2.0.24",
         "cboden/ratchet": "^0.4.4",
         "fideloper/proxy": "^4.4",
         "fruitcake/laravel-cors": "^2.0",
         "fukuball/jieba-php": "dev-master",
-        "getuilaboratory/getui-pushapi-php-client-v2": "dev-master",
         "gregwar/captcha": "^1.1",
         "guzzlehttp/guzzle": "^7.0.1",
-        "jaeger/querylist": "^4.2",
         "laravel/framework": "^8.12",
         "laravel/socialite": "^5.6",
         "laravel/tinker": "^2.5",
         "maatwebsite/excel": "^3.1",
         "socialiteproviders/weixin": "^4.1",
-        "socialiteproviders/weixin-web": "*",
-        "wechatpay/wechatpay-guzzle-middleware": "^0.2.2",
-        "wxkxklmyt/pscws4": "^0.0.2",
         "yansongda/pay": "~3.4.0"
     },
     "require-dev": {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2028 - 2131
composer.lock