草稿箱调整
This commit is contained in:
parent
96d9c7a487
commit
471dc1f040
@ -281,6 +281,8 @@ class ActivityDrafts extends Base
|
||||
if($user)$user_id = $user['id'];
|
||||
$params = [];
|
||||
$params["user_id"] = $user_id; //老师id
|
||||
|
||||
// var_dump($params["user_id"]);
|
||||
$params["cate_ids"] = $this->request->post('cate_ids/s', ''); //课程标签
|
||||
$params["refund_id"] = $this->request->post('refund_id/d', ''); //课程标签
|
||||
|
||||
|
@ -181,7 +181,7 @@ class ActivityHook
|
||||
|
||||
|
||||
//调用取消活动接口
|
||||
(new Activity)->cancel($activity["id"],"1",false,$oper_type,$oper_id);
|
||||
if($activity["status"] != "-1") (new Activity)->cancel($activity["id"],"1",false,$oper_type,$oper_id);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ class Activity extends BaseModel
|
||||
// $row = self::get($id);
|
||||
// var_dump($row["audit_status"]);
|
||||
//如果审核状态是审核中,并且时间已经到了3=待开始,4=进行中,则活动自动取消
|
||||
if(($row["status"]=='3' || $row["status"]=='4') && $row["auth_status"]=='0'){
|
||||
if(($row["status"]=='3' || $row["status"]=='4' || $row["status"]=='-1') && $row["auth_status"]=='0'){
|
||||
//直接改为审核失败
|
||||
$row["auth_time"] = time();
|
||||
$row["reason"] = "超期系统自动审核失败,请重发该活动";
|
||||
@ -1738,7 +1738,8 @@ class Activity extends BaseModel
|
||||
|
||||
$row = self::where("id",$id)->where("status","in",["1","2","3","4"])->find();
|
||||
|
||||
if(!$row) throw new \Exception("活动已取消或已结束");
|
||||
//
|
||||
if(!$row) throw new \Exception("活动{$id}已取消或已结束");
|
||||
|
||||
if($check) {
|
||||
if($oper_type=='user' && $row["user_id"] != $oper_id) throw new \Exception("您无权取消该活动");
|
||||
@ -1764,6 +1765,15 @@ class Activity extends BaseModel
|
||||
//自动退款检测:如果有订单,则自动取消
|
||||
$this->orderAllCancel($id);
|
||||
|
||||
|
||||
self::update_classes($id);
|
||||
// //如果是未审核,自动改成审核失败
|
||||
// if($row["auth_status"]=="0"){
|
||||
// //改为审核失败
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
if($trans){
|
||||
self::commitTrans();
|
||||
}
|
||||
|
@ -42,9 +42,26 @@ class ActivityDrafts extends BaseModel
|
||||
'sign_end_time_text',
|
||||
'add_type_text',
|
||||
'feel_text',
|
||||
'createtime_text',
|
||||
'updatetime_text',
|
||||
];
|
||||
|
||||
|
||||
public function getCreatetimeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
|
||||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||||
}
|
||||
|
||||
|
||||
public function getUpdatetimeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['updatetime']) ? $data['updatetime'] : '');
|
||||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getImagesAttr($value, $data)
|
||||
@ -336,8 +353,8 @@ class ActivityDrafts extends BaseModel
|
||||
|
||||
|
||||
}else{
|
||||
if(!$row && empty($params["time"])) throw new \Exception("请选择活动开始和结束时间");
|
||||
if(!$row && empty($params["sign_time"])) throw new \Exception("请选择报名开始和结束时间");
|
||||
// if(!$row && empty($params["time"])) throw new \Exception("请选择活动开始和结束时间");
|
||||
// if(!$row && empty($params["sign_time"])) throw new \Exception("请选择报名开始和结束时间");
|
||||
if($row){
|
||||
if(empty($params["time"])){
|
||||
$params["start_time"] = $row["start_time"];
|
||||
@ -360,29 +377,29 @@ class ActivityDrafts extends BaseModel
|
||||
|
||||
$rule = [
|
||||
'user_id'=>'require',
|
||||
'title'=>'require',
|
||||
'images'=>'require',
|
||||
// 'headimage' => 'require',
|
||||
'address' => 'require',
|
||||
'address_detail' => 'require',
|
||||
'longitude' => 'require',
|
||||
'latitude' => 'require',
|
||||
// 'province' => 'require',
|
||||
// 'city' => 'require',
|
||||
// 'district' => 'require',
|
||||
// 'address_city' => 'require',
|
||||
// 'type' => 'require',
|
||||
'stock' => 'require',
|
||||
// 'address_type' => 'require',
|
||||
'content' => 'require',
|
||||
'cate_ids' => 'require',
|
||||
'price' => 'require',
|
||||
|
||||
|
||||
'start_time' => 'require',
|
||||
'end_time' => 'require',
|
||||
'sign_start_time' => 'require',
|
||||
'sign_end_time' => 'require',
|
||||
// 'title'=>'require',
|
||||
// 'images'=>'require',
|
||||
//// 'headimage' => 'require',
|
||||
// 'address' => 'require',
|
||||
// 'address_detail' => 'require',
|
||||
// 'longitude' => 'require',
|
||||
// 'latitude' => 'require',
|
||||
//// 'province' => 'require',
|
||||
//// 'city' => 'require',
|
||||
//// 'district' => 'require',
|
||||
//// 'address_city' => 'require',
|
||||
//// 'type' => 'require',
|
||||
// 'stock' => 'require',
|
||||
//// 'address_type' => 'require',
|
||||
// 'content' => 'require',
|
||||
// 'cate_ids' => 'require',
|
||||
// 'price' => 'require',
|
||||
//
|
||||
//
|
||||
// 'start_time' => 'require',
|
||||
// 'end_time' => 'require',
|
||||
// 'sign_start_time' => 'require',
|
||||
// 'sign_end_time' => 'require',
|
||||
// 'refund_id' => 'require',
|
||||
|
||||
|
||||
@ -423,7 +440,22 @@ class ActivityDrafts extends BaseModel
|
||||
|
||||
self::check($params,$rule,$rule_msg);
|
||||
|
||||
if ($params["content"]) {
|
||||
|
||||
//必须至少一个参数有值,price除外
|
||||
foreach ( $params as $key => $value){
|
||||
if($value){
|
||||
break;
|
||||
}
|
||||
if($key != "price" && !$value){
|
||||
unset($params[$key]);
|
||||
}
|
||||
}
|
||||
if(count($params) < 2){
|
||||
throw new \Exception("请至少填写1项活动信息!");
|
||||
}
|
||||
|
||||
|
||||
if ($params["content"]) {
|
||||
$params["content"] = htmlspecialchars_decode($params["content"]);
|
||||
|
||||
// 过滤掉禁止自动换行属性:text-wrap-mode: nowrap;
|
||||
@ -434,17 +466,25 @@ class ActivityDrafts extends BaseModel
|
||||
|
||||
|
||||
|
||||
if (!empty($params["images"])) {
|
||||
$images = is_array($params["images"]) ? $params["images"] : explode(",",$params["images"]);
|
||||
foreach ($images as $key => &$image){
|
||||
|
||||
if(!$image){
|
||||
unset($images[$key]);
|
||||
}
|
||||
|
||||
$images = is_array($params["images"]) ? $params["images"] : explode(",",$params["images"]);
|
||||
//轮播图至少3张
|
||||
if(count($images) < 3 || count($images) > 5){
|
||||
throw new \Exception("轮播图至少3张,最多5张");
|
||||
}
|
||||
foreach ($images as $image){
|
||||
if(!$image) throw new \Exception("轮播图不能为空");
|
||||
}
|
||||
// var_dump($images);
|
||||
//轮播图至少3张
|
||||
// if(count($images) < 3 || count($images) > 5){
|
||||
// throw new \Exception("轮播图至少3张,最多5张,当前上传张数为".count($images));
|
||||
// }
|
||||
//重新合并成一个字符串
|
||||
$params["images"] = implode(",",$images);
|
||||
}
|
||||
|
||||
|
||||
//发活动是否需要实名认证
|
||||
// if(config("site.activity_realname_switch")){
|
||||
// //查询是否实名认证
|
||||
@ -453,23 +493,23 @@ class ActivityDrafts extends BaseModel
|
||||
// }
|
||||
|
||||
|
||||
$params["price"] = $params["price"] ?? 0;
|
||||
|
||||
|
||||
if( $params["price"]>0){
|
||||
if(!empty($params["refund_id"])){
|
||||
// if(empty($params["refund_id"])) throw new \Exception("金额为{$params['price']},退款策略必填");
|
||||
$refund_id = $params["refund_id"];
|
||||
$refund = Refund::where("id",$refund_id) ->find();
|
||||
|
||||
if($params["price"]>0){
|
||||
if(empty($params["refund_id"])) throw new \Exception("退款策略必填");
|
||||
$refund_id = $params["refund_id"];
|
||||
$refund = Refund::where("id",$refund_id) ->find();
|
||||
|
||||
if(!$refund){
|
||||
throw new \Exception("退款策略不存在");
|
||||
if(!$refund){
|
||||
throw new \Exception("退款策略不存在");
|
||||
}
|
||||
$paid_activity_min_price = config("site.paid_activity_min_price");
|
||||
if($params["price"]<$paid_activity_min_price){
|
||||
throw new \Exception("活动售价不能低于".$paid_activity_min_price."元");
|
||||
}
|
||||
}
|
||||
$paid_activity_min_price = config("site.paid_activity_min_price");
|
||||
if($params["price"]<$paid_activity_min_price){
|
||||
throw new \Exception("活动售价不能低于".$paid_activity_min_price."元");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if($params["price"]<0)$params["price"]=0;
|
||||
|
||||
@ -654,7 +694,7 @@ class ActivityDrafts extends BaseModel
|
||||
$cate_list = Cate::where("status",'1')->column("name","id");
|
||||
// $label_list = Label::where("status",'1')->column("name","id");
|
||||
// $type_list = Type::where("status",'1')->column("name","id");
|
||||
$selfetch = self::with($with)->where("{$a}show", '=', '1');
|
||||
$selfetch = self::with($with);
|
||||
|
||||
|
||||
|
||||
@ -1006,9 +1046,10 @@ class ActivityDrafts extends BaseModel
|
||||
}
|
||||
$self['classes_cate'] = $classes_cate;
|
||||
|
||||
|
||||
$self['sign_time'] = "{$self["sign_start_time_text"]} - {$self["sign_end_time_text"]}";
|
||||
$self['time'] = "{$self["start_time_text"]} - {$self["end_time_text"]}";
|
||||
$self['sign_time'] = "";
|
||||
$self['time'] = "";
|
||||
if($self["sign_start_time"]) $self['sign_time'] = "{$self["sign_start_time_text"]} - {$self["sign_end_time_text"]}";
|
||||
if($self["start_time"]) $self['time'] = "{$self["start_time_text"]} - {$self["end_time_text"]}";
|
||||
|
||||
// $self['join_info'] = self::getJoininfo($id,$self["stock"],10);
|
||||
|
||||
@ -1335,7 +1376,7 @@ class ActivityDrafts extends BaseModel
|
||||
try{
|
||||
|
||||
unset($params["id"]);
|
||||
unset($params["user_id"]);
|
||||
// unset($params["user_id"]);
|
||||
|
||||
$this->update_check($params,$row);
|
||||
$result = $row->allowField(true)->save($params);
|
||||
|
Loading…
x
Reference in New Issue
Block a user