发布端:订单列表,详情,数量统计
用户端:订单列表,详情,数量统计,预下单计算接口,退款策略接口,下单接口,支付接口(进行中)
This commit is contained in:
parent
17c0cbe716
commit
978b5ec335
@ -22,7 +22,7 @@ class Refund extends Backend
|
|||||||
{
|
{
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->model = new \app\admin\model\school\activity\Refund;
|
$this->model = new \app\admin\model\school\activity\Refund;
|
||||||
|
$this->view->assign("statusList", $this->model->getStatusList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ return [
|
|||||||
'Title' => '标题',
|
'Title' => '标题',
|
||||||
'Images' => '轮播图',
|
'Images' => '轮播图',
|
||||||
'Address_city' => '城市选择',
|
'Address_city' => '城市选择',
|
||||||
'Cate_ids' => '平台分类ids',
|
'Cate_ids' => '平台分类(标签)',
|
||||||
'Province' => '省编号',
|
'Province' => '省编号',
|
||||||
'City' => '市编号',
|
'City' => '市编号',
|
||||||
'District' => '县区编号',
|
'District' => '县区编号',
|
||||||
@ -53,8 +53,8 @@ return [
|
|||||||
'Add_type 2' => '总后台',
|
'Add_type 2' => '总后台',
|
||||||
'Add_id' => '添加人id',
|
'Add_id' => '添加人id',
|
||||||
'Feel' => '是否免费',
|
'Feel' => '是否免费',
|
||||||
'Feel 0' => '否',
|
'Feel 0' => '付费活动',
|
||||||
'Feel 1' => '是',
|
'Feel 1' => '免费活动',
|
||||||
'Sign_num' => '总已报名人数',
|
'Sign_num' => '总已报名人数',
|
||||||
'Verification_num' => '总已核销人数',
|
'Verification_num' => '总已核销人数',
|
||||||
'Collect' => '实际收藏量',
|
'Collect' => '实际收藏量',
|
||||||
|
@ -3,8 +3,20 @@
|
|||||||
return [
|
return [
|
||||||
'Title' => '策略标题',
|
'Title' => '策略标题',
|
||||||
'Desc' => '策略说明',
|
'Desc' => '策略说明',
|
||||||
'Refund_hour' => '退款小时',
|
'Status' => '状态',
|
||||||
'Refund_scale_json' => '退款比例',
|
'Status 1' => '不退款',
|
||||||
|
'Set status to 1' => '设为不退款',
|
||||||
|
'Status 3' => '开始前退',
|
||||||
|
'Set status to 3' => '设为开始前退',
|
||||||
|
'Status 5' => '随时退',
|
||||||
|
'Set status to 5' => '设为随时退',
|
||||||
|
'Status 7' => '前12小时退',
|
||||||
|
'Set status to 7' => '设为前12小时退',
|
||||||
|
'Status 9' => '前24小时退',
|
||||||
|
'Set status to 9' => '设为前24小时退',
|
||||||
|
'Status 11' => '前48小时退',
|
||||||
|
'Set status to 11' => '设为前48小时退',
|
||||||
|
'Refund_scale_json' => '额外参数',
|
||||||
'Weigh' => '权重',
|
'Weigh' => '权重',
|
||||||
'Createtime' => '创建时间',
|
'Createtime' => '创建时间',
|
||||||
'Updatetime' => '修改时间',
|
'Updatetime' => '修改时间',
|
||||||
|
@ -25,7 +25,7 @@ class Refund extends Model
|
|||||||
|
|
||||||
// 追加属性
|
// 追加属性
|
||||||
protected $append = [
|
protected $append = [
|
||||||
|
'status_text'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -40,9 +40,18 @@ class Refund extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getStatusList()
|
||||||
|
{
|
||||||
|
return ['1' => __('Status 1'), '3' => __('Status 3'), '5' => __('Status 5'), '7' => __('Status 7'), '9' => __('Status 9'), '11' => __('Status 11')];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getStatusTextAttr($value, $data)
|
||||||
|
{
|
||||||
|
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||||
|
$list = $this->getStatusList();
|
||||||
|
return isset($list[$value]) ? $list[$value] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,9 +13,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_hour')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<input id="c-refund_hour" class="form-control" name="row[refund_hour]" type="number">
|
|
||||||
|
<div class="radio">
|
||||||
|
{foreach name="statusList" item="vo"}
|
||||||
|
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
|
||||||
|
{/foreach}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -13,9 +13,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_hour')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<input id="c-refund_hour" class="form-control" name="row[refund_hour]" type="number" value="{$row.refund_hour|htmlentities}">
|
|
||||||
|
<div class="radio">
|
||||||
|
{foreach name="statusList" item="vo"}
|
||||||
|
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
|
||||||
|
{/foreach}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<div class="panel panel-default panel-intro">
|
<div class="panel panel-default panel-intro">
|
||||||
{:build_heading()}
|
|
||||||
|
<div class="panel-heading">
|
||||||
|
{:build_heading(null,FALSE)}
|
||||||
|
<ul class="nav nav-tabs" data-field="status">
|
||||||
|
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
|
||||||
|
{foreach name="statusList" item="vo"}
|
||||||
|
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div id="myTabContent" class="tab-content">
|
<div id="myTabContent" class="tab-content">
|
||||||
@ -12,7 +22,14 @@
|
|||||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('school/activity/refund/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('school/activity/refund/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="dropdown btn-group {:$auth->check('school/activity/refund/multi')?'':'hide'}">
|
||||||
|
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
|
||||||
|
<ul class="dropdown-menu text-left" role="menu">
|
||||||
|
{foreach name="statusList" item="vo"}
|
||||||
|
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('school/activity/refund/recyclebin')?'':'hide'}" href="school/activity/refund/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
|
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('school/activity/refund/recyclebin')?'':'hide'}" href="school/activity/refund/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -99,6 +99,8 @@ class Index extends Api
|
|||||||
"site_timezone"=>config('site.timezone'),
|
"site_timezone"=>config('site.timezone'),
|
||||||
"wx_miniapp_version"=>config("site.wx_miniapp_version"),
|
"wx_miniapp_version"=>config("site.wx_miniapp_version"),
|
||||||
"activity_withdrawal_scale" => config("site.activity_withdrawal_scale"),
|
"activity_withdrawal_scale" => config("site.activity_withdrawal_scale"),
|
||||||
|
"unpaid_activity_cancel_time"=> config("site.unpaid_activity_cancel_time"),
|
||||||
|
"unpaid_activity_expire_time"=> config("site.unpaid_activity_expire_time"),
|
||||||
];
|
];
|
||||||
$customer_service = [
|
$customer_service = [
|
||||||
"image"=>cdnurl(config('site.customer_service_image'),true),
|
"image"=>cdnurl(config('site.customer_service_image'),true),
|
||||||
|
@ -7,7 +7,7 @@ use app\common\model\school\classes\activity\order\Order as OrderModel;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户端:活动订单接口
|
* 用户端:活动订单接口(已废弃)
|
||||||
*/
|
*/
|
||||||
class Order extends Base
|
class Order extends Base
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ use Exception;
|
|||||||
use think\Log;
|
use think\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动支付接口
|
* 活动支付接口(已废弃)
|
||||||
*/
|
*/
|
||||||
class Pay extends Base
|
class Pay extends Base
|
||||||
{
|
{
|
||||||
|
140
application/api/controller/school/newactivity/Order.php
Normal file
140
application/api/controller/school/newactivity/Order.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\school\newactivity;
|
||||||
|
|
||||||
|
use app\api\controller\school\Base;
|
||||||
|
use app\common\model\school\activity\order\Order as OrderModel;
|
||||||
|
/**
|
||||||
|
* 用户端:新活动订单接口
|
||||||
|
*/
|
||||||
|
class Order extends Base
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $noNeedLogin = [];
|
||||||
|
protected $noNeedRight = '*';
|
||||||
|
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化操作
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected function _initialize()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->model = new OrderModel;
|
||||||
|
parent::_initialize();
|
||||||
|
|
||||||
|
|
||||||
|
$this->setUrlLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiTitle( 我的活动订单详情)
|
||||||
|
* @ApiSummary(我的活动订单详情)
|
||||||
|
* @ApiMethod(GET)
|
||||||
|
* @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function detail(){
|
||||||
|
$id = $this->request->get('id/d','');
|
||||||
|
|
||||||
|
if(empty($id)){
|
||||||
|
$this->error(__('缺少必要参数'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$res = OrderModel::getDetail($id);
|
||||||
|
} catch (\Exception $e){
|
||||||
|
// Log::log($e->getMessage());
|
||||||
|
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
|
||||||
|
}
|
||||||
|
$this->success('获取成功', ['detail' => $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 = "订单状态:-3=已取消,0=待支付,2=已报名,3=核销中,4=售后中,5=退款结算中,6=已退款,9=已完成")
|
||||||
|
* @ApiParams(name = "server_status", type = "string",required=false,description = "售后订单状态:0=正常,3=售后中,6=售后完成")
|
||||||
|
* @ApiParams(name = "auth_status", type = "string",required=false,description = "售后结果状态:0=待审核,1=同意退款,2=拒绝退款")
|
||||||
|
* @ApiParams(name = "activity_id", type = "int",required=false,description = "活动id")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function order_list()
|
||||||
|
{
|
||||||
|
$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,$has_evaluate,$server_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( 我的活动订单数量接口)
|
||||||
|
* @ApiSummary(返回订单各个数量)
|
||||||
|
* @ApiMethod(GET)
|
||||||
|
* @ApiParams(name = "activity_id", type = "int",required=false,description = "活动id(非必填)")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function order_count(){
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
|
|
||||||
|
$activity_id = $this->request->get('activity_id/s', ''); //搜索关键字
|
||||||
|
try{
|
||||||
|
$res = $this->model::orderCount($user_id,$activity_id);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
$this->success('查询成功', $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
43
application/api/controller/school/newworker/Base.php
Normal file
43
application/api/controller/school/newworker/Base.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\school\newworker;
|
||||||
|
|
||||||
|
use app\common\controller\Api;
|
||||||
|
use app\common\model\school\activity\Activity;
|
||||||
|
use app\common\model\school\classes\Teacher;
|
||||||
|
use app\common\model\school\classes\Verification;
|
||||||
|
|
||||||
|
class Base extends Api
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $activity_ids = [];
|
||||||
|
protected $vaild_activity_ids = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化操作
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected function _initialize()
|
||||||
|
{
|
||||||
|
parent::_initialize();
|
||||||
|
// 判断员工权限
|
||||||
|
$this->check_worker_auth();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function check_worker_auth(){
|
||||||
|
//判断登录用户是否是员工
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
|
if(!$user_id)$this->error("请登录后再访问该接口!",['errcode'=>30002], 401);
|
||||||
|
|
||||||
|
$this->activity_ids = (new Activity())->getActivityAuthIds($user_id);
|
||||||
|
$this->vaild_activity_ids = (new Activity())->getActivityAuthIds($user_id,true);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
135
application/api/controller/school/newworker/activity/Order.php
Normal file
135
application/api/controller/school/newworker/activity/Order.php
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\school\newworker\activity;
|
||||||
|
|
||||||
|
use app\api\controller\school\newworker\Base;
|
||||||
|
|
||||||
|
use app\common\model\school\activity\order\Order as OrderModel;
|
||||||
|
/**
|
||||||
|
* 员工端:活动订单管理接口
|
||||||
|
*/
|
||||||
|
class Order extends Base
|
||||||
|
{
|
||||||
|
protected $noNeedLogin = [];
|
||||||
|
protected $noNeedRight = '*';
|
||||||
|
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化操作
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected function _initialize()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->model = new OrderModel;
|
||||||
|
parent::_initialize();
|
||||||
|
|
||||||
|
//判断登录用户是否是员工
|
||||||
|
$this->setUrlLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiTitle( 用户活动订单详情)
|
||||||
|
* @ApiSummary(用户活动订单详情)
|
||||||
|
* @ApiMethod(GET)
|
||||||
|
* @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function detail(){
|
||||||
|
$id = $this->request->get('id/s','');
|
||||||
|
|
||||||
|
if(empty($id)){
|
||||||
|
$this->error(__('缺少必要参数'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$res = OrderModel::getDetail($id,$this->activity_ids);
|
||||||
|
if(!$res)throw new \Exception('您无操作权限!',40003);
|
||||||
|
} catch (\Exception $e){
|
||||||
|
// Log::log($e->getMessage());
|
||||||
|
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
|
||||||
|
}
|
||||||
|
$this->success('获取成功', ['detail' => $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 = "订单状态:-3=已取消,0=待支付,2=已报名,3=核销中,4=售后中,5=退款结算中,6=已退款,9=已完成")
|
||||||
|
* @ApiParams(name = "server_status", type = "string",required=false,description = "售后订单状态:0=正常,3=售后中,6=售后完成")
|
||||||
|
* @ApiParams(name = "auth_status", type = "string",required=false,description = "售后结果状态:0=待审核,1=同意退款,2=拒绝退款")
|
||||||
|
* @ApiParams(name = "activity_id", type = "int",required=false,description = "活动id")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function order_list()
|
||||||
|
{
|
||||||
|
$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', ''); //搜索关键字
|
||||||
|
$params =[];
|
||||||
|
$params["auth_status"] = $this->request->get('auth_status/s', ''); //搜索关键字
|
||||||
|
$server_status = $this->request->get('server_status/s', ''); //搜索关键字
|
||||||
|
$activity_id = $this->request->get('activity_id/s', ''); //搜索关键字
|
||||||
|
|
||||||
|
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
||||||
|
|
||||||
|
|
||||||
|
try{
|
||||||
|
//当前申请状态
|
||||||
|
$res = $this->model::workList($user_id,$page, $limit,$keywords,$status,$activity_id,$this->activity_ids,0,$server_status,$params);
|
||||||
|
// var_dump($this->model->getLastSql());
|
||||||
|
}catch (\Exception $e){
|
||||||
|
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
$this->success('查询成功', $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiTitle( 用户订单数量接口)
|
||||||
|
* @ApiSummary(返回订单各个数量)
|
||||||
|
* @ApiMethod(GET)
|
||||||
|
* @ApiParams(name = "activity_id", type = "int",required=false,description = "活动id")
|
||||||
|
* @ApiReturn({
|
||||||
|
*
|
||||||
|
*})
|
||||||
|
*/
|
||||||
|
public function order_count(){
|
||||||
|
$user_id = 0;
|
||||||
|
$user = $this->auth->getUser();//登录用户
|
||||||
|
if($user)$user_id = $user['id'];
|
||||||
|
$activity_id = $this->request->get('activity_id/s', ''); //搜索关键字
|
||||||
|
try{
|
||||||
|
$res = $this->model::workCount($activity_id,$this->activity_ids);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
$this->success('查询成功', $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -8,7 +8,7 @@ use app\common\model\school\classes\activity\order\Order as OrderModel;
|
|||||||
use app\common\model\school\classes\Teacher as Teachermodel;
|
use app\common\model\school\classes\Teacher as Teachermodel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工端:课程活动订单管理接口
|
* (已废弃)员工端:课程活动订单管理接口
|
||||||
*/
|
*/
|
||||||
class Order extends Base
|
class Order extends Base
|
||||||
{
|
{
|
||||||
|
@ -271,6 +271,41 @@ $newactivityHooks = [
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$newactivityOrderHooks = [
|
||||||
|
// 订单创建
|
||||||
|
'activity_order_create_before' => [ // 订单创建前
|
||||||
|
'app\\common\\listener\\activity\\OrderHook'
|
||||||
|
],
|
||||||
|
'activity_order_create_after' => [ // 订单创建后
|
||||||
|
'app\\common\\listener\\activity\\OrderHook'
|
||||||
|
],
|
||||||
|
'activity_order_payed_after' => [ // 订单支付成功
|
||||||
|
'app\\common\\listener\\activity\\OrderHook'
|
||||||
|
],
|
||||||
|
// 'classes_activity_order_cancel_after' => [ // 订单取消后
|
||||||
|
// 'app\\common\\listener\\activityorder\\OrderHook'
|
||||||
|
// ],
|
||||||
|
// 'classes_activity_order_auth_success_after' => [ // 订单审核通过后
|
||||||
|
// 'app\\common\\listener\\activityorder\\OrderHook'
|
||||||
|
// ],
|
||||||
|
// 'classes_activity_order_auth_fail_after' => [ // 订单审核失败后
|
||||||
|
// 'app\\common\\listener\\activityorder\\OrderHook'
|
||||||
|
// ],
|
||||||
|
//
|
||||||
|
// 'classes_activity_order_refund_success_after'=> [ // 订单审核失败后退款成功
|
||||||
|
// 'app\\common\\listener\\activityorder\\OrderHook'
|
||||||
|
// ],
|
||||||
|
// 'classes_activity_order_refund_fail_after'=> [ // 订单审核失败后退款成功
|
||||||
|
// 'app\\common\\listener\\activityorder\\OrderHook'
|
||||||
|
// ],
|
||||||
|
// 'classes_activity_order_finish_after' => [ // 订单完成后
|
||||||
|
// 'app\\common\\listener\\activityorder\\OrderHook'
|
||||||
|
// ],
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//if (file_exists(ROOT_PATH . 'addons/shopro/listener/commission')) {
|
//if (file_exists(ROOT_PATH . 'addons/shopro/listener/commission')) {
|
||||||
// $defaultHooks = array_merge_recursive($defaultHooks, $commissionHooks);
|
// $defaultHooks = array_merge_recursive($defaultHooks, $commissionHooks);
|
||||||
@ -287,6 +322,7 @@ $defaultHooks = array_merge_recursive($defaultHooks, $helpHooks);
|
|||||||
|
|
||||||
|
|
||||||
$defaultHooks = array_merge_recursive($defaultHooks, $newactivityHooks);
|
$defaultHooks = array_merge_recursive($defaultHooks, $newactivityHooks);
|
||||||
|
$defaultHooks = array_merge_recursive($defaultHooks, $newactivityOrderHooks);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
137
application/common/listener/activity/OrderHook.php
Normal file
137
application/common/listener/activity/OrderHook.php
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\listener\activity;
|
||||||
|
|
||||||
|
use app\common\model\school\activity\order\Order;
|
||||||
|
|
||||||
|
class OrderHook
|
||||||
|
{
|
||||||
|
|
||||||
|
// 订单创建成功前(订单计算)
|
||||||
|
|
||||||
|
public function activityOrderCreateBefore(&$params)
|
||||||
|
{
|
||||||
|
['user_id'=>$user_id, 'activity_id'=>$activity_id,'num'=>$num,'param'=>$param, 'order_no'=>$order_no, 'price_info'=>$price_info] = $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 订单创建成功后
|
||||||
|
public function activityOrderCreateAfter(&$params)
|
||||||
|
{
|
||||||
|
["order"=>$order] = $params;
|
||||||
|
|
||||||
|
$order = Order::where("id" , $order["id"])->find();
|
||||||
|
|
||||||
|
$detail = $order->detail;
|
||||||
|
$user = $order->user;
|
||||||
|
//记录订单日志
|
||||||
|
$mini_type = "activity_order";
|
||||||
|
$to_id = $order["user_id"];
|
||||||
|
$status ="activity";
|
||||||
|
$params=[
|
||||||
|
"event"=>"activity_order_create_after",
|
||||||
|
"order_id"=>$order["id"],
|
||||||
|
"order_no"=>$order["order_no"],
|
||||||
|
"activity_id"=>$order["activity_id"],
|
||||||
|
];
|
||||||
|
$param = [
|
||||||
|
"title"=>$detail["title"],
|
||||||
|
"order_no" => $order["order_no"],
|
||||||
|
"nickname" => $user["nickname"],
|
||||||
|
"realname" => $user["realname"],
|
||||||
|
"mobile" => $user["mobile"],
|
||||||
|
"price" => $order["totalprice"],
|
||||||
|
"payprice" => $order["payprice"],
|
||||||
|
"real_refundprice" => $order["real_refundprice"],
|
||||||
|
"sub_refundprice" => $order["sub_refundprice"],
|
||||||
|
"reason" => $order["reason"],
|
||||||
|
"address"=>$detail["address"]."(".$detail["address_detail"].")",
|
||||||
|
"start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
|
||||||
|
"end_time" => date("Y-m-d H:i",$detail["end_time"]),
|
||||||
|
"sign_start_time" => date("Y-m-d H:i",$detail["sign_start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
|
||||||
|
"sign_end_time" => date("Y-m-d H:i",$detail["sign_end_time"]),
|
||||||
|
];
|
||||||
|
|
||||||
|
(new MessageConfig)
|
||||||
|
->setTemplate($params["event"])
|
||||||
|
->setTemplateData($param)
|
||||||
|
->setToUid($to_id)
|
||||||
|
->setMessageStatus($status)
|
||||||
|
->setMessageMiniType($mini_type)
|
||||||
|
->setMessageParams($params)
|
||||||
|
->sendMessage();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 订单支付成功后
|
||||||
|
public function activityOrderPayedAfter(&$params)
|
||||||
|
{
|
||||||
|
["order"=>$order] = $params;
|
||||||
|
|
||||||
|
$order = Order::where("id" , $order["id"])->find();
|
||||||
|
$detail = $order->detail;
|
||||||
|
$user = $order->user;
|
||||||
|
|
||||||
|
//记录订单日志
|
||||||
|
$mini_type = "activity_order";
|
||||||
|
$to_id = $order["user_id"];
|
||||||
|
$status ="activity";
|
||||||
|
$params=[
|
||||||
|
"event"=>"activity_order_payed_after",
|
||||||
|
"order_id"=>$order["id"],
|
||||||
|
"order_no"=>$order["order_no"],
|
||||||
|
"activity_id"=>$order["activity_id"],
|
||||||
|
];
|
||||||
|
$param = [
|
||||||
|
"title"=>$detail["title"],
|
||||||
|
"order_no" => $order["order_no"],
|
||||||
|
"nickname" => $user["nickname"],
|
||||||
|
"realname" => $user["realname"],
|
||||||
|
"mobile" => $user["mobile"],
|
||||||
|
"price" => $order["totalprice"],
|
||||||
|
"payprice" => $order["payprice"],
|
||||||
|
"real_refundprice" => $order["real_refundprice"],
|
||||||
|
"sub_refundprice" => $order["sub_refundprice"],
|
||||||
|
"reason" => $order["reason"],
|
||||||
|
"address"=>$detail["address"]."(".$detail["address_detail"].")",
|
||||||
|
"start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
|
||||||
|
"end_time" => date("Y-m-d H:i",$detail["end_time"]),
|
||||||
|
"sign_start_time" => date("Y-m-d H:i",$detail["sign_start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
|
||||||
|
"sign_end_time" => date("Y-m-d H:i",$detail["sign_end_time"]),
|
||||||
|
];
|
||||||
|
|
||||||
|
//发用户
|
||||||
|
(new MessageConfig)
|
||||||
|
->setTemplate($params["event"]."_user")
|
||||||
|
->setTemplateData($param)
|
||||||
|
->setToUid($to_id)
|
||||||
|
->setMessageStatus($status)
|
||||||
|
->setMessageMiniType($mini_type)
|
||||||
|
->setMessageParams($params)
|
||||||
|
->sendMessage();
|
||||||
|
//发所有核销员
|
||||||
|
|
||||||
|
(new MessageConfig)
|
||||||
|
->setTemplate($params["event"]."_verification")
|
||||||
|
->setTemplateData($param)
|
||||||
|
->setToUid($detail["user_id"])
|
||||||
|
->setMessageStatus($status)
|
||||||
|
->setMessageMiniType($mini_type)
|
||||||
|
->setMessageParams($params)
|
||||||
|
->sendMessage();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ namespace app\common\model\school\activity;
|
|||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\school\activity\order\Order;
|
use app\common\model\school\activity\order\Order;
|
||||||
|
use app\common\model\school\activity\order\OrderCode;
|
||||||
use app\common\model\school\classes\Collect;
|
use app\common\model\school\classes\Collect;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
@ -294,13 +295,19 @@ class Activity extends BaseModel
|
|||||||
return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function activitySale($activity_id,$add_num=0)
|
||||||
|
{
|
||||||
|
return Order::where("activity_id",$activity_id)->where("status","not in",["-3","5","6"])->sum("num") + $add_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 更新或新增后判断
|
/** 更新或新增后判断
|
||||||
* @param $classes_activity_id
|
* @param $classes_activity_id
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function update_classes($classes_activity_id){
|
public function update_classes($classes_activity_id){
|
||||||
|
$this->updateStatus($classes_activity_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -607,6 +614,7 @@ class Activity extends BaseModel
|
|||||||
//前台提交
|
//前台提交
|
||||||
$params["auth_status"] = 0;
|
$params["auth_status"] = 0;
|
||||||
}
|
}
|
||||||
|
$params["fee_scale"] = config("site.activity_withdrawal_scale");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1112,10 +1120,20 @@ class Activity extends BaseModel
|
|||||||
$params["status"] = '5';
|
$params["status"] = '5';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//更新销量
|
||||||
|
$params["sale"] = self::activitySale($id);
|
||||||
|
//统计课程总报名和总核销
|
||||||
|
$params["sign_num"] = Order::where("activity_id",$id)->where("status","not in",["-3","5","6"])->sum("num");
|
||||||
|
$params["verification_num"] = OrderCode::where("activity_id",$id)->where("status","=","6")->count();
|
||||||
|
//设置课程收藏
|
||||||
|
$params["collect"] = Collect::where("classes_activity_id",$id)->count();
|
||||||
if($params){
|
if($params){
|
||||||
$res = $row->allowField(true)->save($params);
|
$res = $row->allowField(true)->save($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//将课程信息和课时信息同步到所有已下单的订单信息中
|
||||||
|
self::orderInfoSync($id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($trans){
|
if($trans){
|
||||||
@ -1131,6 +1149,23 @@ class Activity extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function orderInfoSync($classes_lib_id){
|
||||||
|
$classes_lib = self::get($classes_lib_id);
|
||||||
|
if($classes_lib){
|
||||||
|
//查询所有课程订单更新课程单信息
|
||||||
|
$order = \app\common\model\school\activity\order\OrderDetail::where("activity_id",$classes_lib_id)->select();
|
||||||
|
foreach ($order as $row){
|
||||||
|
$update = $classes_lib->toArray();
|
||||||
|
$update_data = $row->checkAssemblyParameters($update,["id","price","status","createtime","updatetime"]);
|
||||||
|
$row->save($update_data);
|
||||||
|
}
|
||||||
|
// \app\common\model\school\activity\order\Order::where("activity_id",$classes_lib_id)->update(["fee_scale"=>$classes_lib["fee_scale"]]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1301,4 +1336,18 @@ class Activity extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getActivityAuthIds($user_id,$vaild=false)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(!$vaild){
|
||||||
|
$activity_ids = self::where("user_id",$user_id)->column("id");
|
||||||
|
}else{
|
||||||
|
//只要审核通过且未结束和取消的
|
||||||
|
$activity_ids = self::where("user_id",$user_id)->where("auth_status","in",["1"])->where("status","in",["1","2","3","4"])->column("id");
|
||||||
|
}
|
||||||
|
return $activity_ids;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,18 @@
|
|||||||
|
|
||||||
namespace app\common\model\school\activity\order;
|
namespace app\common\model\school\activity\order;
|
||||||
|
|
||||||
|
use addons\epay\library\Service;
|
||||||
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\school\activity\Activity;
|
use app\common\model\school\activity\Activity;
|
||||||
|
use app\common\model\school\activity\Refund;
|
||||||
|
use app\common\model\User;
|
||||||
|
use bw\Common;
|
||||||
|
use fast\Random;
|
||||||
|
use think\Cache;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use traits\model\SoftDelete;
|
use traits\model\SoftDelete;
|
||||||
|
|
||||||
class Order extends Model
|
class Order extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
@ -208,4 +215,802 @@ class Order extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(OrderDetail::class, 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
return $this->belongsTo(OrderDetail::class, 'activity_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function ordercode()
|
||||||
|
{
|
||||||
|
return $this->hasMany(OrderCode::class,'activity_order_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**得到基础条件
|
||||||
|
* @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',"auth_status","server_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['server_status']) && $whereData['server_status']!=="") $model = $model->where("{$alisa}server_status", 'in', $whereData['server_status']);
|
||||||
|
if (isset($whereData['not_server_status'])&& $whereData['not_server_status']!=="") $model = $model->where("{$alisa}server_status", 'not in', $whereData['not_server_status']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (isset($whereData['auth_status']) && $whereData['auth_status']!=="") $model = $model->where("{$alisa}auth_status", 'in', $whereData['auth_status']);
|
||||||
|
if (isset($whereData['not_auth_status'])&& $whereData['not_auth_status']!=="") $model = $model->where("{$alisa}auth_status", 'not in', $whereData['not_auth_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}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=[],$has_evaluate=0,$server_status="",$params=[]){
|
||||||
|
$with_field = [
|
||||||
|
'user'=>['nickname','mobile','avatar','realname'],
|
||||||
|
'base'=>['*'],
|
||||||
|
'detail'=>['*'],
|
||||||
|
'ordercode'=>['*'],
|
||||||
|
];
|
||||||
|
$CANCEL = '-3';
|
||||||
|
$NOPAY = '0';
|
||||||
|
$PAYED = '2';
|
||||||
|
$RESERV = '3';
|
||||||
|
$REFUND = '6';
|
||||||
|
$FINISH = '9';
|
||||||
|
$IN_SERVICE = '4';
|
||||||
|
$IN_REFUND = '5';
|
||||||
|
|
||||||
|
$alisa = (new self)->getWithAlisaName();
|
||||||
|
$sort = "field({$alisa}.status,'{$NOPAY}','{$PAYED}','{$RESERV}','{$FINISH}','{$REFUND}','{$IN_SERVICE}','{$CANCEL}' ,'{$IN_REFUND}') asc,{$alisa}.id desc";
|
||||||
|
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,"activity_id"=>$activity_id,"has_evaluate"=>$has_evaluate,"server_status"=>$server_status];
|
||||||
|
// if($type)$serch_where['type'] = $type;
|
||||||
|
return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function baseCount($where = []){
|
||||||
|
$CANCEL = '-3';
|
||||||
|
$NOPAY = '0';
|
||||||
|
$PAYED = '2';
|
||||||
|
$RESERV = '3';
|
||||||
|
$REFUND = '6';
|
||||||
|
$FINISH = '9';
|
||||||
|
$IN_SERVICE = '4';
|
||||||
|
$IN_REFUND = '5';
|
||||||
|
|
||||||
|
$cancel_number = self::getBaseWhere(array_merge(['status'=>$CANCEL],$where))->count();
|
||||||
|
$nopay_number = self::getBaseWhere(array_merge(['status'=>$NOPAY],$where))->count();
|
||||||
|
$payed_number = self::getBaseWhere(array_merge(['status'=>$PAYED],$where))->count();
|
||||||
|
$reserv_number = self::getBaseWhere(array_merge(['status'=>$RESERV],$where))->count();
|
||||||
|
|
||||||
|
|
||||||
|
$retund_number = self::getBaseWhere(array_merge(['status'=>$REFUND],$where))->count();
|
||||||
|
$in_retund_number = self::getBaseWhere(array_merge(['status'=>$IN_REFUND],$where))->count();
|
||||||
|
|
||||||
|
$finish_number = self::getBaseWhere(array_merge(['status'=>$FINISH],$where))->count();
|
||||||
|
$in_service_number = self::getBaseWhere(array_merge(['status'=>$IN_SERVICE],$where))->count();
|
||||||
|
|
||||||
|
return compact('cancel_number','nopay_number','payed_number','in_service_number','retund_number','in_retund_number','finish_number','reserv_number');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**订单数量统计
|
||||||
|
* @param int $user_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function orderCount($user_id = 0,$activity_id=[],$params=[]){
|
||||||
|
return self::baseCount(array_merge(['user_id'=>$user_id,"activity_id"=>$activity_id],$params));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function workList($user_id,$page, $limit,$keywords,$status,$activity_id=[],$activity_ids=[],$has_evaluate=0,$server_status="",$params=[]){
|
||||||
|
if(!$activity_ids) $activity_ids = [-5];
|
||||||
|
|
||||||
|
$with_field = [
|
||||||
|
'user'=>['nickname','mobile','avatar','realname'],
|
||||||
|
'base'=>['*'],
|
||||||
|
'detail'=>['*'],
|
||||||
|
'ordercode'=>['*'],
|
||||||
|
];
|
||||||
|
$CANCEL = '-3';
|
||||||
|
$NOPAY = '0';
|
||||||
|
$PAYED = '2';
|
||||||
|
$RESERV = '3';
|
||||||
|
$REFUND = '6';
|
||||||
|
$FINISH = '9';
|
||||||
|
$IN_SERVICE = '4';
|
||||||
|
$IN_REFUND = '5';
|
||||||
|
$alisa = (new self)->getWithAlisaName();
|
||||||
|
$sort = "field({$alisa}.status,'{$NOPAY}','{$PAYED}','{$RESERV}','{$FINISH}','{$REFUND}','{$IN_SERVICE}','{$CANCEL}','{$IN_REFUND}') asc,{$alisa}.id desc";
|
||||||
|
$serch_where = ['status'=>$status,'keywords'=>$keywords,"activity_id"=>$activity_id,"activity_ids"=>$activity_ids,"server_status"=>$server_status];
|
||||||
|
// if($type)$serch_where['type'] = $type;
|
||||||
|
return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**订单数量统计
|
||||||
|
* @param int $user_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function workCount($activity_id=[],$activity_ids=[],$params=[]){
|
||||||
|
if(!$activity_ids) $activity_ids = [-5];
|
||||||
|
|
||||||
|
return self::baseCount(array_merge(["activity_id"=>$activity_id,"activity_ids"=>$activity_ids],$params));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**得到订单详情
|
||||||
|
* @param $order_no
|
||||||
|
*/
|
||||||
|
public static function getDetail($order_no,$activity_id = []){
|
||||||
|
$model = self::where('order_no|id|pay_no',$order_no);
|
||||||
|
if($activity_id)$model = $model->where("activity_id","in",$activity_id);
|
||||||
|
$data = $model->find();
|
||||||
|
|
||||||
|
if(!$data) return $data;
|
||||||
|
//加载订单详情
|
||||||
|
$data->detail;
|
||||||
|
//订单用户
|
||||||
|
// $data->user;
|
||||||
|
$data->user->visible(['id','nickname','mobile','avatar','realname']);
|
||||||
|
|
||||||
|
//规格信息
|
||||||
|
$data->ordercode;
|
||||||
|
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**展示订单信息
|
||||||
|
* @param $order_no
|
||||||
|
* @param $price_info
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function showInfo($order_no, $price_info = []){
|
||||||
|
$data = [];
|
||||||
|
$data['order_no'] =$order_no;
|
||||||
|
$data['order_info'] = self::getDetail($order_no);
|
||||||
|
return array_merge($data,$price_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**得到订单
|
||||||
|
* @param $order_no
|
||||||
|
* @return array|false|\PDOStatement|string|Model
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @throws \think\exception\DbException
|
||||||
|
*/
|
||||||
|
public static function getOrder($order_no){
|
||||||
|
$order = self::where('order_no|id|pay_no',$order_no)->find();
|
||||||
|
if(!$order)throw new \Exception("订单不存在");
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置订单缓存
|
||||||
|
* @param $uid
|
||||||
|
* @param $data
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function setOrderCache($uid, $data)
|
||||||
|
{
|
||||||
|
//缓存名 = uid + order_no
|
||||||
|
$cacheNmae = 'activity_order_cache' . $uid . $data['order_no'];
|
||||||
|
// 缓存在3600秒之后过期
|
||||||
|
return Cache::set($cacheNmae, $data, config("site.unpaid_activity_expire_time"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到订单缓存
|
||||||
|
* @param $uid
|
||||||
|
* @param $order_no
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getOrderCache($uid, $order_no)
|
||||||
|
{
|
||||||
|
//缓存名 = uid + order_no
|
||||||
|
$cacheNmae = 'activity_order_cache' . $uid . $order_no;
|
||||||
|
// 缓存在3600秒之后过期
|
||||||
|
return Cache::get($cacheNmae);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除订单缓存
|
||||||
|
* @param $uid
|
||||||
|
* @param $order_no
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function deleteOrderCache($uid, $order_no)
|
||||||
|
{
|
||||||
|
//缓存名 = uid + order_no
|
||||||
|
$cacheNmae = 'activity_order_cache' . $uid . $order_no;
|
||||||
|
// 缓存在3600秒之后过期
|
||||||
|
return Cache::rm($cacheNmae);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**订单校验
|
||||||
|
* @param $user_id 用户id
|
||||||
|
* @param $classes_lib_id 课程id
|
||||||
|
* @param $order_no 订单号
|
||||||
|
* @param $param 表单扩展参数
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function orderVaild($user_id,$activity_id,$num, $order_no, $param,$check=false){
|
||||||
|
if(!$user_id||!$activity_id )throw new \Exception("缺少必要参数");
|
||||||
|
|
||||||
|
//更新活动状态
|
||||||
|
(new Activity)->updateStatus($activity_id);
|
||||||
|
//校验订单参数
|
||||||
|
//课程活动是否存在并上架
|
||||||
|
$activity = Activity::where('id',$activity_id)->find();
|
||||||
|
if(!$activity || $activity['status']!='2' || $activity['auth_status']!='1') throw new \Exception("该活动不在可报名时间段!");
|
||||||
|
|
||||||
|
|
||||||
|
//默认校验订单是否已创建
|
||||||
|
if($check){
|
||||||
|
//此为创建订单时判断
|
||||||
|
//判断订单是否已创建
|
||||||
|
$order_info = self::where(['order_no'=>$order_no])->find();
|
||||||
|
if($order_info) throw new \Exception("订单已生成,如需重新下单请退出页面重新进入!");
|
||||||
|
//下单必须传规格id
|
||||||
|
$num = (int)$num;
|
||||||
|
if(!$num) throw new \Exception("请选择报名人数!");
|
||||||
|
$activity_max_people = config("site.activity_max_people");
|
||||||
|
if($activity_max_people){
|
||||||
|
if($num > $activity_max_people || $num < 1) throw new \Exception("单次报名人数不能超过{$activity_max_people}人!");
|
||||||
|
}
|
||||||
|
//判断数量是否超出库存
|
||||||
|
$sale = Activity::activitySale($activity_id,$num);//活动销量
|
||||||
|
if($sale > $activity['stock']){
|
||||||
|
//判断超了几人
|
||||||
|
$sub = $sale - $activity['stock'];
|
||||||
|
|
||||||
|
throw new \Exception("活动人数已超{$sub}人!无法下单!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//用户存不存在
|
||||||
|
$user_info = User::where('id',$user_id)->find();
|
||||||
|
if(!$user_info) throw new \Exception("用户不存在!");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCost($user_id,$activity_id,$num=1,$param=[],$other_params=[],$check = false){
|
||||||
|
//用户
|
||||||
|
$user_info = User::get($user_id);
|
||||||
|
$user_data = [
|
||||||
|
"nickname"=>$user_info["nickname"],
|
||||||
|
"realname"=>$user_info["realname"],
|
||||||
|
"avatar"=>$user_info["avatar"],
|
||||||
|
"mobile"=>$user_info["mobile"],
|
||||||
|
"money" =>$user_info["money"],
|
||||||
|
"score" =>$user_info["score"],
|
||||||
|
];
|
||||||
|
//课程
|
||||||
|
$activity_info = Activity::get($activity_id);
|
||||||
|
$activity_info = $activity_info->toArray();
|
||||||
|
$activity_info["activity_id"] = $activity_id;
|
||||||
|
$activity_info["activity_order_id"] = 0;
|
||||||
|
$activity_info["refund_scale_json"] = "";
|
||||||
|
$activity_info["refund_status"]= "1";
|
||||||
|
$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['use_num'] = 0;//已使用课时
|
||||||
|
// $activity_info['sub_num'] = $activity_info['classes_num'];//剩余课时
|
||||||
|
// //单价 = 课程价格/总课时
|
||||||
|
// $activity_info["unit_price"] = bcdiv($activity_info['price'],$activity_info['classes_num'],2);
|
||||||
|
// $activity_info["used_price"] = 0;
|
||||||
|
|
||||||
|
$totalprice = bcmul($num,$activity_info["price"],2);
|
||||||
|
//组装订单下单数据
|
||||||
|
$order_data = [];
|
||||||
|
$order_data["user_id"] = $user_id;
|
||||||
|
$order_data["activity_id"] = $activity_id;
|
||||||
|
$order_data["activity_order_detail_id"] = 0;
|
||||||
|
$order_data["num"] = $num;
|
||||||
|
$order_data["fee_scale"] = $activity_info["fee_scale"];
|
||||||
|
$order_data["beforeprice"] = $totalprice;
|
||||||
|
$order_data["totalprice"] = $totalprice;
|
||||||
|
$order_data["payprice"] = 0;
|
||||||
|
$order_data["status"] = '0';
|
||||||
|
|
||||||
|
|
||||||
|
return compact('order_data','activity_info','user_data',"num");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** 订单确认(订单计算)
|
||||||
|
* @param $user_id 下单用户
|
||||||
|
* @param $order_no 订单号(缓存标识)
|
||||||
|
* @param $activity_id 課程活动id
|
||||||
|
* @param $num 人数
|
||||||
|
* @param $param 額外参数(扩展用)
|
||||||
|
* @param bool $is_compute 是否重新计算订单
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function confirm($user_id, $activity_id,$num,$order_no,$param=[], $is_compute = false)
|
||||||
|
{
|
||||||
|
if ($order_no && !$is_compute) {
|
||||||
|
//得到缓存
|
||||||
|
$data = self::getOrderCache($user_id, $order_no);
|
||||||
|
if (!$data) throw new \Exception('请您完善参加信息!');
|
||||||
|
$price_info = $data['price_info'];
|
||||||
|
} else {
|
||||||
|
//订单信息计算
|
||||||
|
// if(!$param) throw new \Exception('缺少必要信息');
|
||||||
|
$this->orderVaild($user_id,$activity_id,$num,$order_no, $param);
|
||||||
|
//订单支付信息
|
||||||
|
$price_info = $this->getCost($user_id,$activity_id,$num,$param);
|
||||||
|
//生成订单号
|
||||||
|
if (!$order_no) $order_no = get_order_sn();
|
||||||
|
//生成缓存
|
||||||
|
$data = compact('user_id', 'activity_id','num','param', 'order_no', 'price_info');
|
||||||
|
self::setOrderCache($user_id, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
\think\Hook::listen('activity_order_create_before', $data);
|
||||||
|
|
||||||
|
//下单数据展示
|
||||||
|
return $this->showInfo($order_no, $price_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**得到待支付订单
|
||||||
|
* @param $order_no
|
||||||
|
* @return array|false|\PDOStatement|string|Model
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @throws \think\exception\DbException
|
||||||
|
*/
|
||||||
|
public static function getNopayOrder($order_no){
|
||||||
|
$order = self::where('order_no|id|pay_no',$order_no)->where("status",'0')->find();
|
||||||
|
if(!$order)throw new \Exception("待支付订单不存在");
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**调用订单支付成功事件
|
||||||
|
* @param $order_no
|
||||||
|
* @param $pay_type
|
||||||
|
* @param $price
|
||||||
|
* @param $price_check
|
||||||
|
* @param bool $trans
|
||||||
|
* @return bool
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function paySuccess($order_no,$notify=[],$price=0,$price_check=false,$trans=false){
|
||||||
|
$order = self::getNopayOrder($order_no);
|
||||||
|
//金额校验 :第三方支付时回调入口判断
|
||||||
|
if($price_check){
|
||||||
|
if(bccomp($price,$order['totalprice'])==-1)throw new \Exception("支付金额与订单需要支付金额对应不上,回调失败!");
|
||||||
|
}
|
||||||
|
//判断逻辑
|
||||||
|
if($trans){
|
||||||
|
self::beginTrans();
|
||||||
|
}
|
||||||
|
$res = true;
|
||||||
|
try{
|
||||||
|
//事务逻辑
|
||||||
|
//不拆分订单,直接执行
|
||||||
|
self::paySetData($order,$notify);
|
||||||
|
|
||||||
|
// //如果需要快捷预约
|
||||||
|
// $classes_lib_spec_id = $order['classes_lib_spec_id'];
|
||||||
|
// if($classes_lib_spec_id){
|
||||||
|
// //记录代下单人信息
|
||||||
|
// $param = [
|
||||||
|
// "type" =>'2',
|
||||||
|
// "help_user_id" =>$order["user_id"] ,
|
||||||
|
// "help_type" => 'admin',
|
||||||
|
// ];
|
||||||
|
//
|
||||||
|
// //确认订单
|
||||||
|
// $res = (new \app\common\model\school\classes\hourorder\Order)->confirm($order["user_id"],$order['id'],null, $classes_lib_spec_id,$param, true);
|
||||||
|
// $remark = "订单支付完成同时快捷预约一个课时";
|
||||||
|
// //创建订单
|
||||||
|
// $result = (new \app\common\model\school\classes\hourorder\Order)->cacheCreateOrder($res['order_no'], $order["user_id"],$remark);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if($trans){
|
||||||
|
self::commitTrans();
|
||||||
|
}
|
||||||
|
}catch (\Exception $e){
|
||||||
|
if($trans){
|
||||||
|
self::rollbackTrans();
|
||||||
|
}
|
||||||
|
throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function updatePay($order,$notify=[]){
|
||||||
|
if(is_string($order)||is_numeric($order))$order = self::getNopayOrder($order);
|
||||||
|
$order->status ='2';
|
||||||
|
$order->paytime = time();
|
||||||
|
$order->pay_no = $notify['transaction_id'] ?? null;
|
||||||
|
$order->pay_json = $notify['payment_json'] ?? '{}';
|
||||||
|
$order->pay_type = $notify['pay_type'] ?? 'yue';
|
||||||
|
//如果订单创建时间大于预约时间,则等于预约时间
|
||||||
|
// if($order['createtime']>$order['starttime'])$order['createtime'] = $order['starttime'];
|
||||||
|
switch ($order->pay_type) {
|
||||||
|
case "offline": //线下付款,线上不需要支付
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$order->payprice = $notify['pay_fee'] ?? $order->totalprice;
|
||||||
|
}
|
||||||
|
$order->platform = $notify['platform'] ?? 'miniapp';
|
||||||
|
$order->sub_refundprice = $order->payprice; //剩余未退 = 支付金额
|
||||||
|
|
||||||
|
$order->save();
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function paySetData($order,$notify=[]){
|
||||||
|
//订单支付更新
|
||||||
|
$order = self::updatePay($order,$notify);
|
||||||
|
//生成订单一维码和二维码
|
||||||
|
$order = self::buildCode($order);
|
||||||
|
//记录订单日志
|
||||||
|
OrderLog::log($order['id'],"活动订单支付成功,核销码生成,等待核销",'user',$order['user_id']);
|
||||||
|
//调用支付成功事件
|
||||||
|
$data = ['order' => self::where("id",$order['id'])->find()];
|
||||||
|
\think\Hook::listen('activity_order_payed_after', $data);
|
||||||
|
//更新订单数据
|
||||||
|
self::statisticsAndUpdateClassesNumber($order);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function buildCode($order){
|
||||||
|
if(is_string($order)||is_numeric($order))$order = self::getNopayOrder($order);
|
||||||
|
|
||||||
|
$num = $order['num'];
|
||||||
|
for ($i=0;$i<$num;$i++){
|
||||||
|
$params = [
|
||||||
|
"activity_order_id"=>$order["id"],
|
||||||
|
"status" =>'3',
|
||||||
|
"activity_id"=>$order['activity_id'],
|
||||||
|
];
|
||||||
|
$orderCode = OrderCode::create($params);
|
||||||
|
$orderCode["code"] = en_code($orderCode["id"]);
|
||||||
|
$orderCode["miniurl"] = self::getMiniQrcodeLink(["order_id"=>$order['id'],"code"=>$orderCode["code"]]);
|
||||||
|
|
||||||
|
|
||||||
|
//生成核销二维码和一维码
|
||||||
|
// //生成二维码和一维码
|
||||||
|
// //二维码
|
||||||
|
// $orderCode->codeimage = (Common::getQrcode([
|
||||||
|
// 'text' => $orderCode["miniurl"],
|
||||||
|
// 'size' => 200,
|
||||||
|
// ]))['url'];
|
||||||
|
// //一维码
|
||||||
|
// $orderCode->codeoneimage = (Common::getBarcode([
|
||||||
|
// 'text' => $orderCode["miniurl"],
|
||||||
|
// 'size' => 200,
|
||||||
|
// ]))['url'];
|
||||||
|
|
||||||
|
|
||||||
|
$orderCode->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function getPath($params=[],$expression = '{{KEYWORD}}'){
|
||||||
|
$path = config("site.activity_verification_url");
|
||||||
|
if(!$path) throw new \Exception("请先配置小程序路径");
|
||||||
|
// 参数替换
|
||||||
|
$template = Common::parsePrintTemplateString($path,$params,$expression);
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMiniQrcodeLink($params=[],$expression = '{{KEYWORD}}',$qrcode=false){
|
||||||
|
$path = self::getPath($params,$expression);
|
||||||
|
//如果路径开头有斜杠则去除
|
||||||
|
if(substr($path,0,1) == "/"){
|
||||||
|
$path = substr($path,1);
|
||||||
|
}
|
||||||
|
//解析该路径,获取url参数和除去参数的url
|
||||||
|
$url_params = [];
|
||||||
|
$url = "";
|
||||||
|
if(strpos($path,"?") !== false){
|
||||||
|
$url_params = explode("?",$path);
|
||||||
|
$url = $url_params[0];
|
||||||
|
$url_params = $url_params[1];
|
||||||
|
}else{
|
||||||
|
$url = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$q_params = [];
|
||||||
|
//生成小程序二维码
|
||||||
|
$query = $url_params;
|
||||||
|
$q_params["path"] = $url;
|
||||||
|
if($query)$q_params["query"] = $query;
|
||||||
|
|
||||||
|
// 实例对应的接口对象
|
||||||
|
$scheme = new \WeMini\Scheme(Service::wechatConfig());
|
||||||
|
$res= $scheme->urlLink($q_params);
|
||||||
|
if(!isset($res["url_link"]))throw new \Exception("生成小程序二维码失败");
|
||||||
|
$url_link = $res["url_link"];
|
||||||
|
if(!$qrcode)return $url_link;
|
||||||
|
|
||||||
|
//链接生成二维码
|
||||||
|
//二维码
|
||||||
|
$response = Common::getQrcode([
|
||||||
|
'text' => $url_link,
|
||||||
|
'size' => 200,
|
||||||
|
],false,false,true);
|
||||||
|
//全返回
|
||||||
|
return compact("url_link","response");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据缓存创建订单
|
||||||
|
*/
|
||||||
|
public function cacheCreateOrder($order_no, $user_id,$remark="", $trans = false)
|
||||||
|
{
|
||||||
|
//得到缓存
|
||||||
|
$orderInfo = self::getOrderCache($user_id, $order_no); //得到下单信息
|
||||||
|
if (!$orderInfo) throw new \Exception('请您完善预约信息');
|
||||||
|
|
||||||
|
if ($trans) {
|
||||||
|
self::beginTrans();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
//'classes_activity_id','classes_activity_item_id'
|
||||||
|
//1订单执行创建
|
||||||
|
$order = $this->createOrder($user_id,$orderInfo['activity_id'],$orderInfo['num'],$order_no,$orderInfo['param'],$remark);
|
||||||
|
|
||||||
|
$orderitem = $order->detail;
|
||||||
|
//如果是免费订单,则直接调用支付完成
|
||||||
|
if ($orderitem['feel'] == '1' || $order['totalprice'] == 0) {
|
||||||
|
//调用订单支付成功事件
|
||||||
|
$this->paySuccess($order_no,['platform'=>"miniapp",'pay_type'=>'yue']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//5删除缓存
|
||||||
|
self::deleteOrderCache($user_id, $order_no);
|
||||||
|
|
||||||
|
if ($trans) {
|
||||||
|
self::commitTrans();
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
if ($trans) {
|
||||||
|
self::rollbackTrans();
|
||||||
|
}
|
||||||
|
throw new \Exception($e->getMessage().$e->getFile() . $e->getLine());
|
||||||
|
}
|
||||||
|
return self::showInfo($order_no);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function createOrder($user_id,$activity_id,$num,$order_no,$param,$remark='',$other_params=[]){
|
||||||
|
|
||||||
|
$this->orderVaild($user_id,$activity_id,$num, $order_no, $param,true);
|
||||||
|
//订单支付信息
|
||||||
|
$order_info = self::getCost($user_id,$activity_id,$num,$param,$other_params,true);
|
||||||
|
|
||||||
|
//组装订单数据 compact('order_data','activity_info','user_data',"activity_info");
|
||||||
|
$order_data = $order_info['order_data'];
|
||||||
|
$order_data["order_no"] = $order_no;
|
||||||
|
|
||||||
|
$res1 = self::create($order_data);
|
||||||
|
if (!$res1) throw new \Exception('创建订单失败');
|
||||||
|
$activity_info = $order_info["activity_info"];
|
||||||
|
if(!$activity_info)throw new \Exception('订单未选活动!');
|
||||||
|
|
||||||
|
//課程详情
|
||||||
|
$activity_info = $order_info['activity_info'];
|
||||||
|
|
||||||
|
$order_detail_data = [];
|
||||||
|
$order_detail_data = array_merge($order_detail_data,$activity_info);
|
||||||
|
$order_detail_data["activity_id"] = $activity_info['id'];
|
||||||
|
$order_detail_data["activity_order_id"] = $res1['id'];
|
||||||
|
|
||||||
|
unset($order_detail_data['id']);
|
||||||
|
unset($order_detail_data['createtime']);
|
||||||
|
|
||||||
|
$orderDetail = (new OrderDetail());
|
||||||
|
$orderDetail->allowField(true)->save($order_detail_data);
|
||||||
|
|
||||||
|
|
||||||
|
// $order_item_data = [];
|
||||||
|
// $order_item_data = array_merge($order_item_data,$classes_activity_item->toArray());
|
||||||
|
// $order_item_data["classes_activity_item_id"] = $classes_activity_item['id'];
|
||||||
|
// $order_item_data["classes_activity_order_id"] = $res1['id'];
|
||||||
|
//
|
||||||
|
// unset($order_item_data['id']);
|
||||||
|
// unset($order_item_data['createtime']);
|
||||||
|
// $orderItem = (new OrderItem());
|
||||||
|
// $orderItem->allowField(true)->save($order_item_data);
|
||||||
|
|
||||||
|
//更新订单详情id
|
||||||
|
$res1->activity_order_detail_id = $orderDetail->id;
|
||||||
|
$res1->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//记录订单日志
|
||||||
|
OrderLog::log($res1['id'],"活动订单创建成功,等待下一步操作(如果付费需去支付)",'user',$user_id);
|
||||||
|
//7事件
|
||||||
|
$data = ['order' => self::where("id",$res1['id'])->find()];
|
||||||
|
\think\Hook::listen('activity_order_create_after', $data);
|
||||||
|
|
||||||
|
|
||||||
|
//更新订单数据
|
||||||
|
self::statisticsAndUpdateClassesNumber($res1);
|
||||||
|
|
||||||
|
|
||||||
|
return $res1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//统计并更新活动数等相关统计数据
|
||||||
|
public static function statisticsAndUpdateClassesNumber($order){
|
||||||
|
if(is_string($order)||is_numeric($order))$order = self::getOrder($order);
|
||||||
|
// $detail = $order->detail;
|
||||||
|
// if(!$detail)throw new \think\Exception("订单信息缺失!");
|
||||||
|
//
|
||||||
|
// //课程下单时已核销人数更新
|
||||||
|
// $lib = $order->activity;
|
||||||
|
// if($lib){
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//将课程信息和课时信息同步到所有已下单的订单信息中
|
||||||
|
Activity::update_classes($order["activity_id"]);
|
||||||
|
|
||||||
|
//如果有评价执行评价更新
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
namespace app\common\model\school\activity\order;
|
namespace app\common\model\school\activity\order;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use traits\model\SoftDelete;
|
use traits\model\SoftDelete;
|
||||||
|
|
||||||
class OrderCode extends Model
|
class OrderCode extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace app\common\model\school\activity\order;
|
namespace app\common\model\school\activity\order;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\school\activity\Activity;
|
use app\common\model\school\activity\Activity;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use traits\model\SoftDelete;
|
use traits\model\SoftDelete;
|
||||||
|
|
||||||
class OrderDetail extends Model
|
class OrderDetail extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace app\common\model\school\activity\order;
|
namespace app\common\model\school\activity\order;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\user\withdrawal\UserwithdrawalLog;
|
use app\common\model\user\withdrawal\UserwithdrawalLog;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use traits\model\SoftDelete;
|
use traits\model\SoftDelete;
|
||||||
|
|
||||||
class SettleLog extends Model
|
class SettleLog extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
@ -32,6 +32,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{field: 'user_id', title: __('User_id')},
|
{field: 'user_id', title: __('User_id')},
|
||||||
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||||
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
|
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
|
||||||
|
{field: 'feel', title: __('Feel'), searchList: {"0":__('Feel 0'),"1":__('Feel 1')}, formatter: Table.api.formatter.normal},
|
||||||
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
|
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
|
||||||
{field: 'auth_status', title: __('Auth_status'), searchList: {"0":__('Auth_status 0'),"1":__('Auth_status 1'),"2":__('Auth_status 2')}, formatter: Table.api.formatter.status},
|
{field: 'auth_status', title: __('Auth_status'), searchList: {"0":__('Auth_status 0'),"1":__('Auth_status 1'),"2":__('Auth_status 2')}, formatter: Table.api.formatter.status},
|
||||||
{field: 'reason', title: __('Reason'), operate: 'LIKE'},
|
{field: 'reason', title: __('Reason'), operate: 'LIKE'},
|
||||||
@ -62,7 +63,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{field: 'views', title: __('Views')},
|
{field: 'views', title: __('Views')},
|
||||||
{field: 'add_type', title: __('Add_type'), searchList: {"1":__('Add_type 1'),"2":__('Add_type 2')}, formatter: Table.api.formatter.normal},
|
{field: 'add_type', title: __('Add_type'), searchList: {"1":__('Add_type 1'),"2":__('Add_type 2')}, formatter: Table.api.formatter.normal},
|
||||||
{field: 'add_id', title: __('Add_id')},
|
{field: 'add_id', title: __('Add_id')},
|
||||||
{field: 'feel', title: __('Feel'), searchList: {"0":__('Feel 0'),"1":__('Feel 1')}, formatter: Table.api.formatter.normal},
|
|
||||||
{field: 'sign_num', title: __('Sign_num')},
|
{field: 'sign_num', title: __('Sign_num')},
|
||||||
{field: 'verification_num', title: __('Verification_num')},
|
{field: 'verification_num', title: __('Verification_num')},
|
||||||
{field: 'collect', title: __('Collect')},
|
{field: 'collect', title: __('Collect')},
|
||||||
|
@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{field: 'id', title: __('Id')},
|
{field: 'id', title: __('Id')},
|
||||||
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||||
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||||
{field: 'refund_hour', title: __('Refund_hour')},
|
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"3":__('Status 3'),"5":__('Status 5'),"7":__('Status 7'),"9":__('Status 9'),"11":__('Status 11')}, formatter: Table.api.formatter.status},
|
||||||
{field: 'weigh', title: __('Weigh'), operate: false},
|
{field: 'weigh', title: __('Weigh'), operate: false},
|
||||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||||
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user