用户端:
会员中心接口返回活动数据和结算额度数据 结算记录和提现记录接口 提现银行卡绑定,编辑接口 提现申请接口 提现审核功能,打款及备注功能 活动结束未核销订单自动完成定时任务
This commit is contained in:
		
							parent
							
								
									e9bbe382a2
								
							
						
					
					
						commit
						f14161e6e9
					
				@ -30,8 +30,10 @@ class Crontab extends Api
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
       try{
 | 
			
		||||
          $res = Order::timeoutCheck(true);
 | 
			
		||||
           $res = \app\common\model\school\classes\activity\order\Order::timeoutCheck(true);
 | 
			
		||||
//          $res = Order::timeoutCheck(true);
 | 
			
		||||
//           $res = \app\common\model\school\classes\activity\order\Order::timeoutCheck(true);
 | 
			
		||||
 | 
			
		||||
           (new \app\common\model\school\activity\order\SettleLog)->timeoutSettleCheck(true);
 | 
			
		||||
 | 
			
		||||
                 //得到近七天的开始结束时间 "start_date","end_date"
 | 
			
		||||
           $seven_date = NightSchoolBigData::getLastSevenDaysDate();
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,8 @@ use app\common\library\Ems;
 | 
			
		||||
use app\common\library\Sms;
 | 
			
		||||
use app\common\model\dyqc\ManystoreShop;
 | 
			
		||||
use app\common\model\manystore\UserAuth;
 | 
			
		||||
use app\common\model\school\activity\Activity;
 | 
			
		||||
use app\common\model\school\activity\order\SettleLog;
 | 
			
		||||
use fast\Random;
 | 
			
		||||
use think\Cache;
 | 
			
		||||
use think\Config;
 | 
			
		||||
@ -193,6 +195,12 @@ class User extends Api
 | 
			
		||||
        $data['shop_auth_info'] =  ManystoreShop::getAuthInfo($this->auth->id);
 | 
			
		||||
 | 
			
		||||
        $data['user_info']["avatar"] = $data['user_info']["avatar"]? cdnurl($data['user_info']["avatar"],true):$data['user_info']["avatar"];
 | 
			
		||||
 | 
			
		||||
        //结算钱包信息
 | 
			
		||||
        $data["settle_info"] = SettleLog::getUserSettleInfo($this->auth->id);
 | 
			
		||||
        //活动信息
 | 
			
		||||
        $data["activity_info"] = Activity::getActivityInfo($this->auth->id);
 | 
			
		||||
 | 
			
		||||
        $this->success('调用成功',$data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -314,7 +322,7 @@ class User extends Api
 | 
			
		||||
     * 修改会员个人信息
 | 
			
		||||
     *
 | 
			
		||||
     * @ApiMethod (POST)
 | 
			
		||||
     * @ApiParams (name="update_fields", type="json", required=true, description="本次需要更新的用户字段json格式:更新谁传谁的字段名,比如:只更新头像和昵称 则 json=['avatar','nickname']")
 | 
			
		||||
     * @ApiParams (name="update_fields", type="string", required=true, description="本次需要更新的用户字段json格式:更新谁传谁的字段名,比如:只更新头像和昵称 则 json=['avatar','nickname']")
 | 
			
		||||
     * @ApiParams (name="avatar", type="string", required=true, description="头像地址")
 | 
			
		||||
     * @ApiParams (name="username", type="string", required=true, description="用户名")
 | 
			
		||||
     * @ApiParams (name="nickname", type="string", required=true, description="昵称")
 | 
			
		||||
 | 
			
		||||
@ -94,11 +94,6 @@ class WechatUtil extends Api
 | 
			
		||||
     * @ApiParams   (name="cloud_resource_appid", type="string",required=false , description="云开发静态网站自定义 H5 配置参数: 第三方批量代云开发时必填,表示创建该 env 的 appid (小程序/第三方平台)")
 | 
			
		||||
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
 | 
			
		||||
     * @ApiReturnParams   (name="url_link", type="string", required=true, sample="生成的小程序 URL Link")
 | 
			
		||||
     * @ApiReturn({
 | 
			
		||||
    "code" => 1,
 | 
			
		||||
    "msg" => "获取成功",
 | 
			
		||||
    "data" => {}
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function link() {
 | 
			
		||||
        $q_params = [];
 | 
			
		||||
 | 
			
		||||
@ -21,5 +21,36 @@ class Base extends Api
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    protected function transactionCheck()
 | 
			
		||||
    {
 | 
			
		||||
       // 得到活动交易关闭时间段列表
 | 
			
		||||
$activity_close_times = config("site.activity_close_time") ?: [];
 | 
			
		||||
foreach ($activity_close_times as $key => $value) {
 | 
			
		||||
    // 解析时间区间
 | 
			
		||||
    $time_arr = explode("-", $value);
 | 
			
		||||
    $start_time = trim($time_arr[0]);
 | 
			
		||||
    $end_time = trim($time_arr[1]);
 | 
			
		||||
 | 
			
		||||
    // 当前时间
 | 
			
		||||
    $current_time = date("H:i");
 | 
			
		||||
 | 
			
		||||
    // 跨天时间段的处理
 | 
			
		||||
    if ($start_time > $end_time) {
 | 
			
		||||
        // 如果当前时间大于等于开始时间 或者 小于等于结束时间,则认为在范围内
 | 
			
		||||
        if ($current_time >= $start_time || $current_time <= $end_time) {
 | 
			
		||||
            $this->error("活动交易已关闭进入结算周期,期间您无法交易!");
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        // 普通时间段的处理
 | 
			
		||||
        if ($current_time >= $start_time && $current_time <= $end_time) {
 | 
			
		||||
            $this->error("活动交易已关闭进入结算周期,期间您无法交易!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -258,6 +258,8 @@ class NewActivity extends Base
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function add(){
 | 
			
		||||
 | 
			
		||||
        $this->transactionCheck();
 | 
			
		||||
        $user_id = 73;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
@ -348,6 +350,7 @@ class NewActivity extends Base
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function cancel(){
 | 
			
		||||
        $this->transactionCheck();
 | 
			
		||||
        $user_id = 0;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,7 @@ class Order extends Base
 | 
			
		||||
     */
 | 
			
		||||
    protected function _initialize()
 | 
			
		||||
    {
 | 
			
		||||
        $this->transactionCheck();
 | 
			
		||||
 | 
			
		||||
        $this->model = new OrderModel;
 | 
			
		||||
        parent::_initialize();
 | 
			
		||||
@ -169,7 +170,7 @@ class Order extends Base
 | 
			
		||||
            $res = $this->model->confirm($user_id, $activity_id,$num,$order_no,$param, $is_compute);
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
//            Log::log($e->getMessage());
 | 
			
		||||
            $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
 | 
			
		||||
            $this->error($e->getMessage().$e->getFile().$e->getLine(),['errcode'=>$e->getCode()]);
 | 
			
		||||
        }
 | 
			
		||||
        $this->success('执行成功,可用缓存key下单', $res);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,7 @@ class Pay extends Base
 | 
			
		||||
     */
 | 
			
		||||
    protected function _initialize()
 | 
			
		||||
    {
 | 
			
		||||
        $this->transactionCheck();
 | 
			
		||||
 | 
			
		||||
        $this->model = new OrderModel;
 | 
			
		||||
        parent::_initialize();
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										245
									
								
								application/api/controller/school/newactivity/SettleLog.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										245
									
								
								application/api/controller/school/newactivity/SettleLog.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,245 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace app\api\controller\school\newactivity;
 | 
			
		||||
 | 
			
		||||
use app\api\controller\school\Base;
 | 
			
		||||
 | 
			
		||||
use app\common\model\school\activity\order\SettleLog as SettleLogModel;
 | 
			
		||||
use app\common\model\user\withdrawal\Userwithdrawal;
 | 
			
		||||
use app\common\model\user\withdrawal\UserwithdrawalLog;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用户端:结算记录相关接口
 | 
			
		||||
 */
 | 
			
		||||
class SettleLog  extends Base
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    protected $noNeedLogin = [];
 | 
			
		||||
    protected $noNeedRight = '*';
 | 
			
		||||
    /**
 | 
			
		||||
     * 初始化操作
 | 
			
		||||
     * @access protected
 | 
			
		||||
     */
 | 
			
		||||
    protected function _initialize()
 | 
			
		||||
    {
 | 
			
		||||
        $this->transactionCheck();
 | 
			
		||||
 | 
			
		||||
        $this->model = new SettleLogModel;
 | 
			
		||||
        parent::_initialize();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $this->setUrlLock();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ApiTitle( 结算记录接口(收益明细))
 | 
			
		||||
     * @ApiSummary(我的结算记录接口(收益明细))
 | 
			
		||||
     * @ApiMethod(GET)
 | 
			
		||||
     * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
 | 
			
		||||
     * @ApiParams(name = "page", type = "string",required=true,description = "页数")
 | 
			
		||||
     * @ApiParams(name = "limit", type = "string",required=true,description = "条数")
 | 
			
		||||
     * @ApiParams(name = "status", type = "string",required=false,description = "结算状态:1=冻结中,2=待结算,3=已结算")
 | 
			
		||||
     * @ApiParams(name = "activity_id", type = "int",required=false,description = "活动id")
 | 
			
		||||
     * @ApiReturn({
 | 
			
		||||
     *
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function settle_log()
 | 
			
		||||
    {
 | 
			
		||||
        $user_id = 0;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
        $page  =  $this->request->get('page/d', 0); //页数
 | 
			
		||||
        $limit =  $this->request->get('limit/d', 0); //条数
 | 
			
		||||
        $keywords =  $this->request->get('keywords/s', ''); //搜索关键字
 | 
			
		||||
        $status =  $this->request->get('status/s', ''); //搜索关键字
 | 
			
		||||
        $server_status =  $this->request->get('server_status/s', ''); //搜索关键字
 | 
			
		||||
        $params = [];
 | 
			
		||||
//        $params["auth_status"] =  $this->request->get('auth_status/s', ''); //搜索关键字
 | 
			
		||||
 | 
			
		||||
        $activity_id =  $this->request->get('activity_id/s', ''); //搜索关键字
 | 
			
		||||
 | 
			
		||||
        $has_evaluate =  $this->request->get('has_evaluate/d', 0); //搜索关键字
 | 
			
		||||
//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单
 | 
			
		||||
 | 
			
		||||
        try{
 | 
			
		||||
            //当前申请状态
 | 
			
		||||
            $res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$activity_id,$params);
 | 
			
		||||
//            if($user_id =='670153'){
 | 
			
		||||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
			
		||||
//            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
 | 
			
		||||
            $this->error($e->getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        $this->success('查询成功', $res);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ApiTitle( 我的提现记录)
 | 
			
		||||
     * @ApiSummary(我的提现记录列表接口)
 | 
			
		||||
     * @ApiMethod(GET)
 | 
			
		||||
     * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
 | 
			
		||||
     * @ApiParams(name = "page", type = "string",required=true,description = "页数")
 | 
			
		||||
     * @ApiParams(name = "limit", type = "string",required=true,description = "条数")
 | 
			
		||||
     * @ApiParams(name = "status", type = "string",required=false,description = "提现申请状态:1=待审核,2=审核通过,3=审核不通过")
 | 
			
		||||
     * @ApiParams(name = "withdrawal_status", type = "string",required=false,description = "打款状态:1=未打款,2=打款中,3=已打款")
 | 
			
		||||
     * @ApiReturn({
 | 
			
		||||
     *
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function withdrawal_log()
 | 
			
		||||
    {
 | 
			
		||||
        $user_id = 0;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
        $page  =  $this->request->get('page/d', 0); //页数
 | 
			
		||||
        $limit =  $this->request->get('limit/d', 0); //条数
 | 
			
		||||
        $keywords =  $this->request->get('keywords/s', ''); //搜索关键字
 | 
			
		||||
        $status =  $this->request->get('status/s', ''); //搜索关键字
 | 
			
		||||
        $withdrawal_status =  $this->request->get('withdrawal_status/s', ''); //搜索关键字
 | 
			
		||||
        $params = [];
 | 
			
		||||
//        $params["auth_status"] =  $this->request->get('auth_status/s', ''); //搜索关键字
 | 
			
		||||
 | 
			
		||||
//        $activity_id =  $this->request->get('activity_id/s', ''); //搜索关键字
 | 
			
		||||
//
 | 
			
		||||
//        $has_evaluate =  $this->request->get('has_evaluate/d', 0); //搜索关键字
 | 
			
		||||
//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单
 | 
			
		||||
 | 
			
		||||
        try{
 | 
			
		||||
            //当前申请状态
 | 
			
		||||
            $res = UserwithdrawalLog::allList($user_id,$page, $limit,$keywords,$status,$withdrawal_status,$params);
 | 
			
		||||
//            if($user_id =='670153'){
 | 
			
		||||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
			
		||||
//            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
 | 
			
		||||
            $this->error($e->getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        $this->success('查询成功', $res);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ApiTitle( 我的提现银行卡信息(未绑数据为null))
 | 
			
		||||
     * @ApiSummary(我的提现银行卡信息)
 | 
			
		||||
     * @ApiMethod(GET)
 | 
			
		||||
     * @ApiReturn({
 | 
			
		||||
     *
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function detail(){
 | 
			
		||||
        $user_id = 0;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
 | 
			
		||||
//        if(empty($id)){
 | 
			
		||||
//            $this->error(__('缺少必要参数'));
 | 
			
		||||
//        }
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            $res =  (new Userwithdrawal)->detail($user_id);
 | 
			
		||||
        } catch (\Exception $e){
 | 
			
		||||
//            Log::log($e->getMessage());
 | 
			
		||||
            $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
 | 
			
		||||
        }
 | 
			
		||||
        $this->success('获取成功', $res);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ApiTitle( 更新或保存提现银行卡)
 | 
			
		||||
     * @ApiSummary(更新或保存提现银行卡)
 | 
			
		||||
     * @ApiMethod(POST)
 | 
			
		||||
     * @ApiParams(name = "name", type = "string",required=true,description = "转账账户名")
 | 
			
		||||
     * @ApiParams(name = "bank_name", type = "string",required=true,description = "开户行名称(具体到支行)")
 | 
			
		||||
     * @ApiParams(name = "bank_user_name", type = "string",required=true,description = "银行账户号")
 | 
			
		||||
     * @ApiParams(name = "id_number", type = "string",required=true,description = "身份证号")
 | 
			
		||||
     * @ApiReturn({
 | 
			
		||||
     *
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function save()
 | 
			
		||||
    {
 | 
			
		||||
        $user_id = 0;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
        $params =[];
 | 
			
		||||
        $params["name"] = $this->request->post('name/s', ''); //页数
 | 
			
		||||
        $params["bank_name"] =  $this->request->post('bank_name/s', ''); //条数
 | 
			
		||||
        $params["bank_user_name"] =  $this->request->post('bank_user_name/s', ''); //搜索关键字
 | 
			
		||||
        $params["id_number"] =  $this->request->post('id_number/s', ''); //搜索关键字
 | 
			
		||||
 | 
			
		||||
        $params = [];
 | 
			
		||||
//        $params["auth_status"] =  $this->request->get('auth_status/s', ''); //搜索关键字
 | 
			
		||||
 | 
			
		||||
//        $activity_id =  $this->request->get('activity_id/s', ''); //搜索关键字
 | 
			
		||||
//
 | 
			
		||||
//        $has_evaluate =  $this->request->get('has_evaluate/d', 0); //搜索关键字
 | 
			
		||||
//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单
 | 
			
		||||
 | 
			
		||||
        try{
 | 
			
		||||
            //当前申请状态
 | 
			
		||||
            $res = (new Userwithdrawal)->addOrupdateWithdrawal($user_id,$params,true);
 | 
			
		||||
//            if($user_id =='670153'){
 | 
			
		||||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
			
		||||
//            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
 | 
			
		||||
            $this->error($e->getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        $this->success('查询成功', $res);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ApiTitle(申请银行卡提现)
 | 
			
		||||
     * @ApiSummary(申请银行卡提现)
 | 
			
		||||
     * @ApiMethod(POST)
 | 
			
		||||
     * @ApiReturn({
 | 
			
		||||
     *
 | 
			
		||||
     *})
 | 
			
		||||
     */
 | 
			
		||||
    public function withdrawal()
 | 
			
		||||
    {
 | 
			
		||||
        $user_id = 0;
 | 
			
		||||
        $user = $this->auth->getUser();//登录用户
 | 
			
		||||
        if($user)$user_id = $user['id'];
 | 
			
		||||
 | 
			
		||||
        $this->model = new UserwithdrawalLog;
 | 
			
		||||
        $this->setUrlLock();
 | 
			
		||||
        try{
 | 
			
		||||
            //当前申请状态
 | 
			
		||||
            $res = $this->model->initiateWithdrawal($user_id,"bank",true);
 | 
			
		||||
//            if($user_id =='670153'){
 | 
			
		||||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
			
		||||
//            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
            $this->error($e->getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        $this->success('查询成功', $res);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -14,6 +14,38 @@ class Base extends Api
 | 
			
		||||
    protected $vaild_activity_ids = [];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    protected function transactionCheck()
 | 
			
		||||
    {
 | 
			
		||||
        // 得到活动交易关闭时间段列表
 | 
			
		||||
        $activity_close_times = config("site.activity_close_time") ?: [];
 | 
			
		||||
        foreach ($activity_close_times as $key => $value) {
 | 
			
		||||
            // 解析时间区间
 | 
			
		||||
            $time_arr = explode("-", $value);
 | 
			
		||||
            $start_time = trim($time_arr[0]);
 | 
			
		||||
            $end_time = trim($time_arr[1]);
 | 
			
		||||
 | 
			
		||||
            // 当前时间
 | 
			
		||||
            $current_time = date("H:i");
 | 
			
		||||
 | 
			
		||||
            // 跨天时间段的处理
 | 
			
		||||
            if ($start_time > $end_time) {
 | 
			
		||||
                // 如果当前时间大于等于开始时间 或者 小于等于结束时间,则认为在范围内
 | 
			
		||||
                if ($current_time >= $start_time || $current_time <= $end_time) {
 | 
			
		||||
                    $this->error("活动交易已关闭进入结算周期,期间您无法交易!");
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                // 普通时间段的处理
 | 
			
		||||
                if ($current_time >= $start_time && $current_time <= $end_time) {
 | 
			
		||||
                    $this->error("活动交易已关闭进入结算周期,期间您无法交易!");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 初始化操作
 | 
			
		||||
     * @access protected
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ class Order extends Base
 | 
			
		||||
     */
 | 
			
		||||
    protected function _initialize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $this->transactionCheck();
 | 
			
		||||
        $this->model = new OrderModel;
 | 
			
		||||
        parent::_initialize();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -316,6 +316,30 @@ $newactivityOrderHooks = [
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//提现事件钩子
 | 
			
		||||
$withdrawalHooks = [
 | 
			
		||||
    // 订单创建
 | 
			
		||||
    'user_withdrawal_auth_need_after' => [        // 体现打款审核提交
 | 
			
		||||
        'app\\common\\listener\\withdrawal\\WithdrawalHook'
 | 
			
		||||
    ],
 | 
			
		||||
    'user_withdrawal_auth_success_after' => [        // 体现打款审核通过后
 | 
			
		||||
        'app\\common\\listener\\withdrawal\\WithdrawalHook'
 | 
			
		||||
    ],
 | 
			
		||||
    'user_withdrawal_auth_fail_after' => [        // 体现打款审核失败后
 | 
			
		||||
        'app\\common\\listener\\withdrawal\\WithdrawalHook'
 | 
			
		||||
    ],
 | 
			
		||||
    'user_withdrawal_success_after' => [        // 体现打款成功
 | 
			
		||||
        'app\\common\\listener\\withdrawal\\WithdrawalHook'
 | 
			
		||||
    ],
 | 
			
		||||
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
//if (file_exists(ROOT_PATH . 'addons/shopro/listener/commission')) {
 | 
			
		||||
//  $defaultHooks = array_merge_recursive($defaultHooks, $commissionHooks);
 | 
			
		||||
@ -334,6 +358,12 @@ $defaultHooks = array_merge_recursive($defaultHooks, $helpHooks);
 | 
			
		||||
$defaultHooks = array_merge_recursive($defaultHooks, $newactivityHooks);
 | 
			
		||||
$defaultHooks = array_merge_recursive($defaultHooks, $newactivityOrderHooks);
 | 
			
		||||
 | 
			
		||||
$defaultHooks = array_merge_recursive($defaultHooks, $withdrawalHooks);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -50,13 +50,15 @@ class ActivityHook
 | 
			
		||||
            //课程推送给老师
 | 
			
		||||
 | 
			
		||||
            $mini_type = "activity_apply";
 | 
			
		||||
 | 
			
		||||
            $to_id = $user_id;
 | 
			
		||||
        $system_user_id = config("site.system_user_id");//系统用户
 | 
			
		||||
            $to_id = $system_user_id;
 | 
			
		||||
            $status ="activity";
 | 
			
		||||
 | 
			
		||||
            $params=[
 | 
			
		||||
                "event"=>"new_activity_auth_need_after",
 | 
			
		||||
                "activity_id"=>$activity["id"],
 | 
			
		||||
                "title"=>$activity["title"],
 | 
			
		||||
                "images"=>$activity["images"],
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -98,11 +100,13 @@ class ActivityHook
 | 
			
		||||
            $user = User::where("id",$user_id)->find();
 | 
			
		||||
            //课程推送给老师
 | 
			
		||||
            $mini_type = "activity_apply";
 | 
			
		||||
            $to_id = $system_user_id;
 | 
			
		||||
            $to_id = $user_id;
 | 
			
		||||
            $status ="activity";
 | 
			
		||||
            $params=[
 | 
			
		||||
                "event"=>"new_activity_auth_success_after",
 | 
			
		||||
                "activity_id"=>$activity["id"],
 | 
			
		||||
                "title"=>$activity["title"],
 | 
			
		||||
                "images"=>$activity["images"],
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            $param = [
 | 
			
		||||
@ -142,11 +146,13 @@ class ActivityHook
 | 
			
		||||
        $user = User::where("id",$user_id)->find();
 | 
			
		||||
//课程推送给老师
 | 
			
		||||
        $mini_type = "activity_apply";
 | 
			
		||||
        $to_id = $system_user_id;
 | 
			
		||||
        $to_id = $user_id;
 | 
			
		||||
        $status ="activity";
 | 
			
		||||
        $params=[
 | 
			
		||||
                "event"=>"new_activity_auth_fail_after",
 | 
			
		||||
                "activity_id"=>$activity["id"],
 | 
			
		||||
            "title"=>$activity["title"],
 | 
			
		||||
            "images"=>$activity["images"],
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            $param = [
 | 
			
		||||
@ -164,7 +170,7 @@ class ActivityHook
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            //发给用户
 | 
			
		||||
            (new MessageConfig)
 | 
			
		||||
            (new MessageConfig())
 | 
			
		||||
                ->setTemplate($params["event"])
 | 
			
		||||
                ->setTemplateData($param)
 | 
			
		||||
                ->setToUid($to_id)
 | 
			
		||||
@ -194,6 +200,10 @@ class ActivityHook
 | 
			
		||||
        $params=[
 | 
			
		||||
            "event"=>"new_activity_cancel_success_after",
 | 
			
		||||
            "activity_id"=>$activity["id"],
 | 
			
		||||
            "title"=>$activity["title"],
 | 
			
		||||
            "images"=>$activity["images"],
 | 
			
		||||
            //活动名
 | 
			
		||||
            //活动头像
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $param = [
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@
 | 
			
		||||
namespace app\common\listener\activity;
 | 
			
		||||
 | 
			
		||||
use app\common\model\school\activity\order\Order;
 | 
			
		||||
use app\common\model\school\MessageConfig;
 | 
			
		||||
 | 
			
		||||
class OrderHook
 | 
			
		||||
{
 | 
			
		||||
@ -33,6 +34,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -52,7 +55,7 @@ class OrderHook
 | 
			
		||||
            "sign_end_time" =>   date("Y-m-d H:i",$detail["sign_end_time"]),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        (new MessageConfig)
 | 
			
		||||
        (new MessageConfig())
 | 
			
		||||
            ->setTemplate($params["event"])
 | 
			
		||||
            ->setTemplateData($param)
 | 
			
		||||
            ->setToUid($to_id)
 | 
			
		||||
@ -87,6 +90,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -148,6 +153,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -204,6 +211,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -265,6 +274,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -316,6 +327,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -380,6 +393,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
@ -433,6 +448,8 @@ class OrderHook
 | 
			
		||||
            "order_id"=>$order["id"],
 | 
			
		||||
            "order_no"=>$order["order_no"],
 | 
			
		||||
            "activity_id"=>$order["activity_id"],
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
            "images"=>$detail["images"],
 | 
			
		||||
        ];
 | 
			
		||||
        $param = [
 | 
			
		||||
            "title"=>$detail["title"],
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										185
									
								
								application/common/listener/withdrawal/WithdrawalHook.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										185
									
								
								application/common/listener/withdrawal/WithdrawalHook.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,185 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace app\common\listener\withdrawal;
 | 
			
		||||
 | 
			
		||||
use app\common\model\school\MessageConfig;
 | 
			
		||||
use app\common\model\User;
 | 
			
		||||
 | 
			
		||||
class WithdrawalHook
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    // 体现打款审核提交
 | 
			
		||||
    public function userWithdrawalAuthNeedAfter(&$params)
 | 
			
		||||
    {
 | 
			
		||||
        ["userwithdrawalLog"=>$userwithdrawalLog] = $params;
 | 
			
		||||
 | 
			
		||||
        $user = User::where("id",$userwithdrawalLog["user_id"])->find();
 | 
			
		||||
 | 
			
		||||
        $mini_type = "user_auth";
 | 
			
		||||
        $to_id = $userwithdrawalLog["user_id"];
 | 
			
		||||
        $status ="system";
 | 
			
		||||
        $params=[
 | 
			
		||||
            "event"=>"user_withdrawal_auth_need_after",
 | 
			
		||||
            "withdrawal_log_id"=>$userwithdrawalLog["id"],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $param = [
 | 
			
		||||
            "price" => $userwithdrawalLog['price'],
 | 
			
		||||
            "fee_price" => $userwithdrawalLog['fee_price'],
 | 
			
		||||
            "real_price" => $userwithdrawalLog['real_price'],
 | 
			
		||||
            "reason" => $userwithdrawalLog['reason'],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            "name" => $userwithdrawalLog['name'],
 | 
			
		||||
            "bank_name" => $userwithdrawalLog['bank_name'],
 | 
			
		||||
            "bank_user_name" => $userwithdrawalLog['bank_user_name'],
 | 
			
		||||
            "id_number" => $userwithdrawalLog['id_number'],
 | 
			
		||||
 | 
			
		||||
            "realname"=> $user["realname"] ,
 | 
			
		||||
            "nickname"=> $user["nickname"] ,
 | 
			
		||||
            "mobile"=> $user["mobile"] ,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        //发给用户
 | 
			
		||||
        (new MessageConfig)
 | 
			
		||||
            ->setTemplate($params["event"])
 | 
			
		||||
            ->setTemplateData($param)
 | 
			
		||||
            ->setToUid($to_id)
 | 
			
		||||
            ->setMessageStatus($status)
 | 
			
		||||
            ->setMessageMiniType($mini_type)
 | 
			
		||||
            ->setMessageParams($params)
 | 
			
		||||
            ->sendMessage();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 体现打款审核通过后
 | 
			
		||||
    public function userWithdrawalAuthSuccessAfter(&$params)
 | 
			
		||||
    {
 | 
			
		||||
        ["userwithdrawalLog"=>$userwithdrawalLog] = $params;
 | 
			
		||||
 | 
			
		||||
        $user = User::where("id",$userwithdrawalLog["user_id"])->find();
 | 
			
		||||
 | 
			
		||||
        $mini_type = "user_auth";
 | 
			
		||||
        $to_id = $userwithdrawalLog["user_id"];
 | 
			
		||||
        $status ="system";
 | 
			
		||||
        $params=[
 | 
			
		||||
            "event"=>"user_withdrawal_auth_success_after",
 | 
			
		||||
            "withdrawal_log_id"=>$userwithdrawalLog["id"],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $param = [
 | 
			
		||||
            "price" => $userwithdrawalLog['price'],
 | 
			
		||||
            "fee_price" => $userwithdrawalLog['fee_price'],
 | 
			
		||||
            "real_price" => $userwithdrawalLog['real_price'],
 | 
			
		||||
            "reason" => $userwithdrawalLog['reason'],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            "name" => $userwithdrawalLog['name'],
 | 
			
		||||
            "bank_name" => $userwithdrawalLog['bank_name'],
 | 
			
		||||
            "bank_user_name" => $userwithdrawalLog['bank_user_name'],
 | 
			
		||||
            "id_number" => $userwithdrawalLog['id_number'],
 | 
			
		||||
 | 
			
		||||
            "realname"=> $user["realname"] ,
 | 
			
		||||
            "nickname"=> $user["nickname"] ,
 | 
			
		||||
            "mobile"=> $user["mobile"] ,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        //发给用户
 | 
			
		||||
        (new MessageConfig)
 | 
			
		||||
            ->setTemplate($params["event"])
 | 
			
		||||
            ->setTemplateData($param)
 | 
			
		||||
            ->setToUid($to_id)
 | 
			
		||||
            ->setMessageStatus($status)
 | 
			
		||||
            ->setMessageMiniType($mini_type)
 | 
			
		||||
            ->setMessageParams($params)
 | 
			
		||||
            ->sendMessage();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 体现打款审核失败后
 | 
			
		||||
    public function userWithdrawalAuthFailAfter(&$params)
 | 
			
		||||
    {
 | 
			
		||||
        ["userwithdrawalLog"=>$userwithdrawalLog] = $params;
 | 
			
		||||
 | 
			
		||||
        $user = User::where("id",$userwithdrawalLog["user_id"])->find();
 | 
			
		||||
 | 
			
		||||
        $mini_type = "user_auth";
 | 
			
		||||
        $to_id = $userwithdrawalLog["user_id"];
 | 
			
		||||
        $status ="system";
 | 
			
		||||
        $params=[
 | 
			
		||||
            "event"=>"user_withdrawal_auth_fail_after",
 | 
			
		||||
            "withdrawal_log_id"=>$userwithdrawalLog["id"],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $param = [
 | 
			
		||||
            "price" => $userwithdrawalLog['price'],
 | 
			
		||||
            "fee_price" => $userwithdrawalLog['fee_price'],
 | 
			
		||||
            "real_price" => $userwithdrawalLog['real_price'],
 | 
			
		||||
            "reason" => $userwithdrawalLog['reason'],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            "name" => $userwithdrawalLog['name'],
 | 
			
		||||
            "bank_name" => $userwithdrawalLog['bank_name'],
 | 
			
		||||
            "bank_user_name" => $userwithdrawalLog['bank_user_name'],
 | 
			
		||||
            "id_number" => $userwithdrawalLog['id_number'],
 | 
			
		||||
 | 
			
		||||
            "realname"=> $user["realname"] ,
 | 
			
		||||
            "nickname"=> $user["nickname"] ,
 | 
			
		||||
            "mobile"=> $user["mobile"] ,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        //发给用户
 | 
			
		||||
        (new MessageConfig)
 | 
			
		||||
            ->setTemplate($params["event"])
 | 
			
		||||
            ->setTemplateData($param)
 | 
			
		||||
            ->setToUid($to_id)
 | 
			
		||||
            ->setMessageStatus($status)
 | 
			
		||||
            ->setMessageMiniType($mini_type)
 | 
			
		||||
            ->setMessageParams($params)
 | 
			
		||||
            ->sendMessage();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 体现打款成功
 | 
			
		||||
    public function userWithdrawalSuccessAfter(&$params)
 | 
			
		||||
    {
 | 
			
		||||
        ["userwithdrawalLog"=>$userwithdrawalLog] = $params;
 | 
			
		||||
 | 
			
		||||
        $user = User::where("id",$userwithdrawalLog["user_id"])->find();
 | 
			
		||||
 | 
			
		||||
        $mini_type = "user_auth";
 | 
			
		||||
        $to_id = $userwithdrawalLog["user_id"];
 | 
			
		||||
        $status ="system";
 | 
			
		||||
        $params=[
 | 
			
		||||
            "event"=>"user_withdrawal_success_after",
 | 
			
		||||
            "withdrawal_log_id"=>$userwithdrawalLog["id"],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $param = [
 | 
			
		||||
            "price" => $userwithdrawalLog['price'],
 | 
			
		||||
            "fee_price" => $userwithdrawalLog['fee_price'],
 | 
			
		||||
            "real_price" => $userwithdrawalLog['real_price'],
 | 
			
		||||
            "reason" => $userwithdrawalLog['reason'],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            "name" => $userwithdrawalLog['name'],
 | 
			
		||||
            "bank_name" => $userwithdrawalLog['bank_name'],
 | 
			
		||||
            "bank_user_name" => $userwithdrawalLog['bank_user_name'],
 | 
			
		||||
            "id_number" => $userwithdrawalLog['id_number'],
 | 
			
		||||
 | 
			
		||||
            "realname"=> $user["realname"] ,
 | 
			
		||||
            "nickname"=> $user["nickname"] ,
 | 
			
		||||
            "mobile"=> $user["mobile"] ,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        //发给用户
 | 
			
		||||
        (new MessageConfig)
 | 
			
		||||
            ->setTemplate($params["event"])
 | 
			
		||||
            ->setTemplateData($param)
 | 
			
		||||
            ->setToUid($to_id)
 | 
			
		||||
            ->setMessageStatus($status)
 | 
			
		||||
            ->setMessageMiniType($mini_type)
 | 
			
		||||
            ->setMessageParams($params)
 | 
			
		||||
            ->sendMessage();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -409,4 +409,6 @@ class User extends BaseModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -980,6 +980,9 @@ class Activity extends BaseModel
 | 
			
		||||
 | 
			
		||||
        $self['join_info'] = self::getJoininfo($id,$self["stock"],10);
 | 
			
		||||
 | 
			
		||||
        //退款政策
 | 
			
		||||
        $self['refund_info'] = Refund::where("id",$self["refund_id"])->find();
 | 
			
		||||
 | 
			
		||||
        return $self;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1140,6 +1143,19 @@ class Activity extends BaseModel
 | 
			
		||||
            if($params){
 | 
			
		||||
                $res = $row->allowField(true)->save($params);
 | 
			
		||||
            }
 | 
			
		||||
            //如果活动状态是已结束,则完成所有未核销或者未核销完的订单
 | 
			
		||||
            //if(in_array($order["status"],["2",'3']) && (in_array($order["server_status"],['0'])) && !$order['finishtime']){
 | 
			
		||||
            if($row["status"]=='5'){
 | 
			
		||||
                $order_list  = Order::where("status" ,"in",["2","3"])->where(["activity_id"=>$id,"server_status"=>"0"])->select();
 | 
			
		||||
                foreach ($order_list as $order){
 | 
			
		||||
                    //执行订单完成
 | 
			
		||||
                    Order::updateFinish($order->order_no);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //将课程信息和课时信息同步到所有已下单的订单信息中
 | 
			
		||||
            self::orderInfoSync($id);
 | 
			
		||||
@ -1400,5 +1416,14 @@ class Activity extends BaseModel
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function getActivityInfo($user_id)
 | 
			
		||||
    {
 | 
			
		||||
        //我参与的活动数量
 | 
			
		||||
        $join_num = Order::where("user_id",$user_id)->where("status","in",["2","3","9"])->count("activity_id");
 | 
			
		||||
 | 
			
		||||
        //我发布的活动数量
 | 
			
		||||
        $release_num = self::where("user_id",$user_id)->where("status","not in",["-1"])->count();
 | 
			
		||||
       return compact("join_num","release_num");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -597,7 +597,7 @@ class Order extends BaseModel
 | 
			
		||||
        $refund = Refund::get($activity_info["refund_id"]);
 | 
			
		||||
        if($refund){
 | 
			
		||||
            $activity_info["refund_scale_json"]= $refund["refund_scale_json"];
 | 
			
		||||
            $activity_info["refund_status"]= $refund["refund_status"];
 | 
			
		||||
            $activity_info["refund_status"]= $refund["status"];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1013,7 +1013,7 @@ class Order extends BaseModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //将课程信息和课时信息同步到所有已下单的订单信息中
 | 
			
		||||
        Activity::update_classes($order["activity_id"]);
 | 
			
		||||
        (new Activity)->update_classes($order["activity_id"]);
 | 
			
		||||
 | 
			
		||||
        //如果有评价执行评价更新
 | 
			
		||||
        return $order;
 | 
			
		||||
 | 
			
		||||
@ -111,6 +111,18 @@ class SettleLog extends BaseModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function activity()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function detail()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo(OrderDetail::class, 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 检测订单结算
 | 
			
		||||
@ -130,7 +142,7 @@ class SettleLog extends BaseModel
 | 
			
		||||
                ->select();
 | 
			
		||||
            foreach ($orders as $order){
 | 
			
		||||
                //剩余金额大于手续费的订单,并且未插入此结算单的
 | 
			
		||||
                $sub_refundprice = bcsub($order["sub_refundprice"],$order["fee_price"]);
 | 
			
		||||
                $sub_refundprice = bcsub($order["sub_refundprice"],$order["fee_price"],2);
 | 
			
		||||
                if($sub_refundprice > 0){
 | 
			
		||||
                   $log = self::where("activity_order_id",$order["id"])->where("status","not in",["-1"])->find();
 | 
			
		||||
                   if(!$log){
 | 
			
		||||
@ -221,7 +233,9 @@ class SettleLog extends BaseModel
 | 
			
		||||
            "sub_refundprice" =>$order->sub_refundprice,
 | 
			
		||||
            "fee_scale" => $order->fee_scale,
 | 
			
		||||
            "fee_price" => $order->fee_price,
 | 
			
		||||
            "settle_price" => bcsub($order->sub_refundprice,$order->fee_price,2)
 | 
			
		||||
            "settle_price" => bcsub($order->sub_refundprice,$order->fee_price,2),
 | 
			
		||||
            "activity_id" => $order->activity_id,
 | 
			
		||||
            "activity_order_detail_id" => $detail->id,
 | 
			
		||||
        ];
 | 
			
		||||
//判断逻辑
 | 
			
		||||
        if($trans){
 | 
			
		||||
@ -362,4 +376,137 @@ class SettleLog extends BaseModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 获取用户结算信息
 | 
			
		||||
     * @param $user_id
 | 
			
		||||
     */
 | 
			
		||||
    public static function getUserSettleInfo($user_id = 0)
 | 
			
		||||
    {
 | 
			
		||||
        //统计未入账未提现金额
 | 
			
		||||
        $expected_incoming_amount = 0.00;
 | 
			
		||||
 | 
			
		||||
        $orders = Order::where("payprice",">",0) //支付单
 | 
			
		||||
        ->where("pay_type",'wechat')  //微信支付
 | 
			
		||||
        ->where("sub_refundprice",">",0)  //剩余未退大于0
 | 
			
		||||
        ->where("user_id",$user_id) //当前活动
 | 
			
		||||
        ->where("status","in",["-3","2","3","9","6"])
 | 
			
		||||
        ->field("sub_refundprice,fee_price")
 | 
			
		||||
            ->select();
 | 
			
		||||
        foreach ($orders as $order){
 | 
			
		||||
            //剩余金额大于手续费的订单,并且未插入此结算单的
 | 
			
		||||
            $sub_refundprice = bcsub($order["sub_refundprice"],$order["fee_price"],2);
 | 
			
		||||
            if($sub_refundprice > 0){
 | 
			
		||||
                $expected_incoming_amount += $sub_refundprice;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        //统计已入账待提现金额
 | 
			
		||||
        $settled_amount = self::where("to_user_id",$user_id)->where("status",'2')->sum("settle_price");
 | 
			
		||||
        //统计累计真实收益金额
 | 
			
		||||
        $accumulated_incoming_amount = self::where("to_user_id",$user_id)->where("status","in",['2',"3"])->sum("settle_price");
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            "expected_incoming_amount" => $expected_incoming_amount,
 | 
			
		||||
            "settled_amount" => $settled_amount,
 | 
			
		||||
            "accumulated_incoming_amount" => $accumulated_incoming_amount,
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**得到基础条件
 | 
			
		||||
     * @param $status
 | 
			
		||||
     * @param null $model
 | 
			
		||||
     * @param string $alisa
 | 
			
		||||
     */
 | 
			
		||||
    public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        if (!$model) {
 | 
			
		||||
            $model = new static;
 | 
			
		||||
            if ($alisa&&!$with) $model = $model->alias($alisa);
 | 
			
		||||
        }
 | 
			
		||||
        if ($alisa) $alisa = $alisa . '.';
 | 
			
		||||
        $tableFields = (new static)->getTableFields();
 | 
			
		||||
        foreach ($tableFields as $fields)
 | 
			
		||||
        {
 | 
			
		||||
            if(in_array($fields, ['status','activity_id','user_id','activity_order_detail_id']))continue;
 | 
			
		||||
//            if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
 | 
			
		||||
 | 
			
		||||
            if (isset($whereData[$fields]) && $whereData[$fields]){
 | 
			
		||||
                if(is_array($whereData[$fields])){
 | 
			
		||||
                    $model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
 | 
			
		||||
                }else{
 | 
			
		||||
                    $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
 | 
			
		||||
        if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if (isset($whereData['keywords'])&&$whereData['keywords']){
 | 
			
		||||
            $model = $model->where("{$alisa}order_no|{$alisa}pay_no|user.nickname|user.realname|user.mobile|detail.title|detail.address|detail.address_detail", 'LIKE', "%{$whereData['keywords']}%" );
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($whereData['time'])&&$whereData['time']){
 | 
			
		||||
 | 
			
		||||
            $model = $model->time(["{$alisa}createtime",$whereData['time']]);
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}to_user_id", '=', $whereData['user_id']);
 | 
			
		||||
 | 
			
		||||
        if (isset($whereData['activity_ids']) && $whereData['activity_ids']) $model = $model->where("{$alisa}activity_id", 'in', $whereData['activity_ids']);
 | 
			
		||||
        if (isset($whereData['activity_id']) && $whereData['activity_id']) $model = $model->where("{$alisa}activity_id", 'in', $whereData['activity_id']);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if (isset($whereData['activity_order_detail_id']) && $whereData['activity_order_detail_id']) $model = $model->where("{$alisa}activity_order_detail_id", 'in', $whereData['activity_order_detail_id']);
 | 
			
		||||
 | 
			
		||||
//        if (isset($whereData['has_evaluate'])&&$whereData['has_evaluate']){
 | 
			
		||||
//            //1查已评价 2查未评价
 | 
			
		||||
//            if($whereData['has_evaluate'] == 1){
 | 
			
		||||
//                //1查已评价
 | 
			
		||||
//                $model = $model->where("{$alisa}classes_evaluate_id", '<>', 0);
 | 
			
		||||
//            }else{
 | 
			
		||||
//                //2查未评价
 | 
			
		||||
//                $model = $model->whereExists(function ($query) use ($alisa) {
 | 
			
		||||
//                    $order_table_name = (new \app\common\model\school\classes\hourorder\Order())->getQuery()->getTable();
 | 
			
		||||
//                    $query->table($order_table_name)->where($order_table_name . '.classes_order_id=' . $alisa . 'id')->where('status', '=', '3');
 | 
			
		||||
//                })->where("{$alisa}classes_evaluate_id", '=', 0);
 | 
			
		||||
//
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
 | 
			
		||||
        return $model;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static function allList($user_id,$page, $limit,$keywords,$status,$activity_id=[],$params=[]){
 | 
			
		||||
        $with_field = [
 | 
			
		||||
            'touser'=>['nickname','mobile','avatar','realname'],
 | 
			
		||||
            'payuser'=>['nickname','mobile','avatar','realname'],
 | 
			
		||||
            'base'=>['*'],
 | 
			
		||||
            'detail'=>['*'],
 | 
			
		||||
        ];
 | 
			
		||||
        $alisa = (new self)->getWithAlisaName();
 | 
			
		||||
        $sort = "{$alisa}.id desc";
 | 
			
		||||
        $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,"activity_id"=>$activity_id];
 | 
			
		||||
//        if($type)$serch_where['type'] = $type;
 | 
			
		||||
        return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,10 +2,11 @@
 | 
			
		||||
 | 
			
		||||
namespace app\common\model\user\withdrawal;
 | 
			
		||||
 | 
			
		||||
use app\common\model\BaseModel;
 | 
			
		||||
use think\Model;
 | 
			
		||||
use traits\model\SoftDelete;
 | 
			
		||||
 | 
			
		||||
class Userwithdrawal extends Model
 | 
			
		||||
class Userwithdrawal extends BaseModel
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    use SoftDelete;
 | 
			
		||||
@ -41,4 +42,87 @@ class Userwithdrawal extends Model
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function detail($user_id)
 | 
			
		||||
    {
 | 
			
		||||
        $withdrawal = self::where('user_id',$user_id)->find();;
 | 
			
		||||
        return compact('withdrawal');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 添加或修改提现信息
 | 
			
		||||
     * @param $user_id
 | 
			
		||||
     * @param $params
 | 
			
		||||
     * @param $trans
 | 
			
		||||
     * @return true
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function addOrupdateWithdrawal($user_id,$params,$trans=false){
 | 
			
		||||
 | 
			
		||||
        //表结构如下:
 | 
			
		||||
        //CREATE TABLE `dyqc_user_withdrawal` (
 | 
			
		||||
        //  `id` int(11) NOT NULL AUTO_INCREMENT,
 | 
			
		||||
        //  `user_id` int(11) NOT NULL COMMENT '提现用户',
 | 
			
		||||
        //  `name` varchar(255) NOT NULL COMMENT '转账账户名',
 | 
			
		||||
        //  `bank_name` varchar(255) NOT NULL COMMENT '开户行名称(具体到支行)',
 | 
			
		||||
        //  `bank_user_name` varchar(255) NOT NULL COMMENT '银行账户号',
 | 
			
		||||
        //  `id_number` varchar(255) NOT NULL COMMENT '身份证号',
 | 
			
		||||
        //  `createtime` bigint(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
 | 
			
		||||
        //  `updatetime` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',
 | 
			
		||||
        //  `deletetime` bigint(11) unsigned DEFAULT NULL COMMENT '删除时间',
 | 
			
		||||
        //  PRIMARY KEY (`id`)
 | 
			
		||||
        //) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户银行卡绑定';
 | 
			
		||||
        //这里应对基础提交信息做验证:开户行名称bank_name,转账账户名name,银行账户号bank_user_name,身份证号id_number
 | 
			
		||||
        //以下对每个字段做验证,如果验证不通过,则抛出异常
 | 
			
		||||
 | 
			
		||||
        $rule =  [
 | 
			
		||||
            'bank_name'=>'require',
 | 
			
		||||
            'name'=>'require',
 | 
			
		||||
            'bank_user_name'=>'require',
 | 
			
		||||
            'id_number'=>'require',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $rule_msg = [
 | 
			
		||||
            'bank_name.require'=>'开户行名称不能为空',
 | 
			
		||||
            'name.require'=>'转账账户名不能为空',
 | 
			
		||||
            'bank_user_name.require'=>'银行账户号不能为空',
 | 
			
		||||
            'id_number.require'=>'身份证号不能为空',
 | 
			
		||||
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        self::check($params,$rule,$rule_msg);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//判断逻辑
 | 
			
		||||
        if($trans){
 | 
			
		||||
            self::beginTrans();
 | 
			
		||||
        }
 | 
			
		||||
        $res = true;
 | 
			
		||||
        try{
 | 
			
		||||
            //此接口需要给用户添加银行卡信息,如果用户没绑过,则添加,如果用户已经绑定过,则修改
 | 
			
		||||
            $userWithdrawal = self::where('user_id',$user_id)->find();
 | 
			
		||||
            if($userWithdrawal){
 | 
			
		||||
                $userWithdrawal->save($params);
 | 
			
		||||
            }else{
 | 
			
		||||
                $userWithdrawal = new self();
 | 
			
		||||
                $userWithdrawal->save($params);
 | 
			
		||||
            }
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::commitTrans();
 | 
			
		||||
            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::rollbackTrans();
 | 
			
		||||
            }
 | 
			
		||||
            throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
 | 
			
		||||
        }
 | 
			
		||||
        return $userWithdrawal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,10 +2,13 @@
 | 
			
		||||
 | 
			
		||||
namespace app\common\model\user\withdrawal;
 | 
			
		||||
 | 
			
		||||
use app\common\model\BaseModel;
 | 
			
		||||
use app\common\model\school\activity\order\SettleLog;
 | 
			
		||||
use app\common\model\User;
 | 
			
		||||
use think\Model;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UserwithdrawalLog extends Model
 | 
			
		||||
class UserwithdrawalLog extends BaseModel
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
@ -102,4 +105,281 @@ class UserwithdrawalLog extends Model
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**得到基础条件
 | 
			
		||||
     * @param $status
 | 
			
		||||
     * @param null $model
 | 
			
		||||
     * @param string $alisa
 | 
			
		||||
     */
 | 
			
		||||
    public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        if (!$model) {
 | 
			
		||||
            $model = new static;
 | 
			
		||||
            if ($alisa&&!$with) $model = $model->alias($alisa);
 | 
			
		||||
        }
 | 
			
		||||
        if ($alisa) $alisa = $alisa . '.';
 | 
			
		||||
        $tableFields = (new static)->getTableFields();
 | 
			
		||||
        foreach ($tableFields as $fields)
 | 
			
		||||
        {
 | 
			
		||||
            if(in_array($fields, ['status',"withdrawal_status",'user_id']))continue;
 | 
			
		||||
//            if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
 | 
			
		||||
 | 
			
		||||
            if (isset($whereData[$fields]) && $whereData[$fields]){
 | 
			
		||||
                if(is_array($whereData[$fields])){
 | 
			
		||||
                    $model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
 | 
			
		||||
                }else{
 | 
			
		||||
                    $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
 | 
			
		||||
        if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
 | 
			
		||||
 | 
			
		||||
        if (isset($whereData['withdrawal_status']) && $whereData['withdrawal_status']!=="") $model = $model->where("{$alisa}withdrawal_status", 'in', $whereData['withdrawal_status']);
 | 
			
		||||
        if (isset($whereData['not_withdrawal_status'])&&  $whereData['not_withdrawal_status']!=="") $model = $model->where("{$alisa}withdrawal_status", 'not in', $whereData['not_withdrawal_status']);
 | 
			
		||||
 | 
			
		||||
        if (isset($whereData['keywords'])&&$whereData['keywords']){
 | 
			
		||||
            $model = $model->where("{$alisa}reason|{$alisa}bank_name|{$alisa}bank_user_name|user.nickname|user.realname|user.mobile", 'LIKE', "%{$whereData['keywords']}%" );
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($whereData['time'])&&$whereData['time']){
 | 
			
		||||
 | 
			
		||||
            $model = $model->time(["{$alisa}createtime",$whereData['time']]);
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return $model;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static function allList($user_id,$page, $limit,$keywords,$status,$withdrawal_status="",$params=[]){
 | 
			
		||||
        $with_field = [
 | 
			
		||||
            'user'=>['nickname','mobile','avatar','realname'],
 | 
			
		||||
            'base'=>['*'],
 | 
			
		||||
        ];
 | 
			
		||||
        $alisa = (new self)->getWithAlisaName();
 | 
			
		||||
        $sort = "{$alisa}.id desc";
 | 
			
		||||
        $serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,"withdrawal_status"=>$withdrawal_status];
 | 
			
		||||
//        if($type)$serch_where['type'] = $type;
 | 
			
		||||
        return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 对近期结算金额发起提现申请
 | 
			
		||||
     * @param $user_id
 | 
			
		||||
     * @param $trans
 | 
			
		||||
     * @return true
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function initiateWithdrawal($user_id,$type="bank",$trans=false){
 | 
			
		||||
 | 
			
		||||
         //判断逻辑
 | 
			
		||||
        if($trans){
 | 
			
		||||
            self::beginTrans();
 | 
			
		||||
        }
 | 
			
		||||
        try{
 | 
			
		||||
 | 
			
		||||
            //实际可提现金额
 | 
			
		||||
            $user_info = User::get($user_id);
 | 
			
		||||
            if(!$user_info) throw new \Exception(__('User not exist'));
 | 
			
		||||
            //统计已入账待提现金额
 | 
			
		||||
            $real_price = SettleLog::where("to_user_id",$user_id)->where("status",'2')->lock(true)->sum("settle_price");
 | 
			
		||||
            //小于0.01 不提现
 | 
			
		||||
            if($real_price<0.01)throw new \Exception("无可提现金额");
 | 
			
		||||
            //计算被扣除的手续费
 | 
			
		||||
            $fee_price = SettleLog::where("to_user_id",$user_id)->where("status",'2')->lock(true)->sum("fee_price");
 | 
			
		||||
            //提现额 = 实际可提现金额 + 手续费
 | 
			
		||||
            $price = bcadd($real_price,$fee_price,2);
 | 
			
		||||
            $status = '1';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //查询是否有提现银行卡信息
 | 
			
		||||
            $userWithdrawal = Userwithdrawal::where('user_id',$user_id)->find();
 | 
			
		||||
            if(!$userWithdrawal) throw new \Exception("请先去绑定提现银行卡");
 | 
			
		||||
            //组装提交数据
 | 
			
		||||
            $data = [
 | 
			
		||||
                'user_id'=>$user_id,
 | 
			
		||||
                'price'=>$price,
 | 
			
		||||
                "fee_price" => $fee_price,
 | 
			
		||||
                'real_price' => $real_price,
 | 
			
		||||
                'type'=>$type,
 | 
			
		||||
                'status'=>$status,
 | 
			
		||||
                'withdrawal_status'=>'1',
 | 
			
		||||
                'name'=>$userWithdrawal['name' ],
 | 
			
		||||
                'bank_name'=>$userWithdrawal['bank_name' ],
 | 
			
		||||
                'bank_user_name'=>$userWithdrawal['bank_user_name' ],
 | 
			
		||||
                'id_number'=>$userWithdrawal['id_number' ],
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //插入提现数据
 | 
			
		||||
            $res = self::create($data);
 | 
			
		||||
 | 
			
		||||
            //更新结算记录
 | 
			
		||||
            SettleLog::where("to_user_id",$user_id)
 | 
			
		||||
                ->where("status",'2')
 | 
			
		||||
                ->update([
 | 
			
		||||
                    'status'=>'3',
 | 
			
		||||
                    'withdrawal_log_id'=>$res['id'],
 | 
			
		||||
                    'settletime'=>time(),
 | 
			
		||||
                ]);
 | 
			
		||||
 | 
			
		||||
            //调用体现申请事件
 | 
			
		||||
            $userwithdrawalLog = self::where('id',$res['id'])->find();
 | 
			
		||||
 | 
			
		||||
            $data = ['userwithdrawalLog' =>$userwithdrawalLog];
 | 
			
		||||
            \think\Hook::listen('user_withdrawal_auth_need_after', $data);
 | 
			
		||||
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::commitTrans();
 | 
			
		||||
            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::rollbackTrans();
 | 
			
		||||
            }
 | 
			
		||||
            throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
 | 
			
		||||
        }
 | 
			
		||||
        return $res;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 提现审核
 | 
			
		||||
     * @param $id
 | 
			
		||||
     * @param $status 状态:1=待审核,2=审核通过,3=审核不通过
 | 
			
		||||
     * @param $reason 审核不通过原因
 | 
			
		||||
     * @param $trans
 | 
			
		||||
     * @return true
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function withdrawalReview($id,$status,$reason="",$trans=false){
 | 
			
		||||
 | 
			
		||||
        //找到需要审核的提现记录
 | 
			
		||||
        $userwithdrawalLog = self::where('id',$id)->where('status',"=",'1')->find();
 | 
			
		||||
        if(!$userwithdrawalLog) throw new \Exception("提现记录不存在");
 | 
			
		||||
        if($userwithdrawalLog['status']!='1') throw new \Exception("已经审核的提现记录不能再审核");
 | 
			
		||||
 | 
			
		||||
        if(!in_array($status,['2','3'])) throw new \Exception("审核状态错误");
 | 
			
		||||
        //不通过需要理由
 | 
			
		||||
        if($status=='3' && !$reason) throw new \Exception("审核不通过原因不能为空");
 | 
			
		||||
//判断逻辑
 | 
			
		||||
        if($trans){
 | 
			
		||||
            self::beginTrans();
 | 
			
		||||
        }
 | 
			
		||||
        $res = true;
 | 
			
		||||
        try{
 | 
			
		||||
 | 
			
		||||
            if($status=='2'){
 | 
			
		||||
                //审核通过
 | 
			
		||||
                //更新状态
 | 
			
		||||
                $userwithdrawalLog["status"] = '2';
 | 
			
		||||
                $userwithdrawalLog["withdrawal_status"] = '2';
 | 
			
		||||
                $userwithdrawalLog["examinetime"] = time();
 | 
			
		||||
                $userwithdrawalLog->save();
 | 
			
		||||
                //调用事件
 | 
			
		||||
 | 
			
		||||
                $data = ['userwithdrawalLog' =>$userwithdrawalLog];
 | 
			
		||||
                \think\Hook::listen('user_withdrawal_auth_success_after', $data);
 | 
			
		||||
 | 
			
		||||
            }else{
 | 
			
		||||
                //审核不通过
 | 
			
		||||
                //更新状态
 | 
			
		||||
                $userwithdrawalLog["status"] = '3';
 | 
			
		||||
                $userwithdrawalLog["reason"] = $reason;
 | 
			
		||||
                $userwithdrawalLog["examinetime"] = time();
 | 
			
		||||
                $userwithdrawalLog->save();
 | 
			
		||||
                //更新结算记录,回退结算状态
 | 
			
		||||
                SettleLog::where('withdrawal_log_id',$id)->update([
 | 
			
		||||
                    'status'=>'2',
 | 
			
		||||
                    'withdrawal_log_id'=>0,
 | 
			
		||||
                    'settletime'=>null,
 | 
			
		||||
                ]);
 | 
			
		||||
                //调用事件
 | 
			
		||||
                $data = ['userwithdrawalLog' =>$userwithdrawalLog];
 | 
			
		||||
                \think\Hook::listen('user_withdrawal_auth_fail_after', $data);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::commitTrans();
 | 
			
		||||
            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::rollbackTrans();
 | 
			
		||||
            }
 | 
			
		||||
            throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
 | 
			
		||||
        }
 | 
			
		||||
        return $userwithdrawalLog;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 设置已打款
 | 
			
		||||
     * @param $id
 | 
			
		||||
     * @param $remark 打款备注
 | 
			
		||||
     * @param $trans
 | 
			
		||||
     * @return true
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function paidAlready($id,$remark="",$trans=false){
 | 
			
		||||
 | 
			
		||||
        //找到需要审核的提现记录
 | 
			
		||||
        $userwithdrawalLog = self::where('id',$id)
 | 
			
		||||
            ->where('status',"=",'2')
 | 
			
		||||
            ->where('withdrawal_status',"=",'2')
 | 
			
		||||
            ->find();
 | 
			
		||||
        if(!$userwithdrawalLog) throw new \Exception("提现记录不存在");
 | 
			
		||||
        if($userwithdrawalLog['status']!='2') throw new \Exception("审核通过的订单才能标记打款");
 | 
			
		||||
//判断逻辑
 | 
			
		||||
        if($trans){
 | 
			
		||||
            self::beginTrans();
 | 
			
		||||
        }
 | 
			
		||||
        $res = true;
 | 
			
		||||
        try{
 | 
			
		||||
                //更新状态
 | 
			
		||||
                $userwithdrawalLog["withdrawal_status"] = '3';
 | 
			
		||||
                $userwithdrawalLog["paytime"] = time();
 | 
			
		||||
                $userwithdrawalLog["remark"] = $remark;
 | 
			
		||||
                $userwithdrawalLog->save();
 | 
			
		||||
                //调用事件
 | 
			
		||||
                $data = ['userwithdrawalLog' =>$userwithdrawalLog];
 | 
			
		||||
                \think\Hook::listen('user_withdrawal_success_after', $data);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::commitTrans();
 | 
			
		||||
            }
 | 
			
		||||
        }catch (\Exception $e){
 | 
			
		||||
            if($trans){
 | 
			
		||||
                self::rollbackTrans();
 | 
			
		||||
            }
 | 
			
		||||
            throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
 | 
			
		||||
        }
 | 
			
		||||
        return $userwithdrawalLog;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -9,8 +9,8 @@ return [
 | 
			
		||||
    /**
 | 
			
		||||
     * CDN地址
 | 
			
		||||
     */
 | 
			
		||||
    'cdnurl'    => 'https://testy1.hschool.com.cn',
 | 
			
		||||
//    'cdnurl'    => '',
 | 
			
		||||
//    'cdnurl'    => 'https://testy1.hschool.com.cn',
 | 
			
		||||
'cdnurl'    => '',
 | 
			
		||||
    /**
 | 
			
		||||
     * 文件保存格式
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user