|
@@ -154,15 +154,21 @@ class Activity extends Base{
|
|
|
$this->error("信息有误");
|
|
|
}
|
|
|
if(!in_array($info->status,[4,5]))throw new \Exception("状态有误");
|
|
|
- $info->status=1;
|
|
|
+
|
|
|
try{
|
|
|
if($info->promocode_id!==0){
|
|
|
- $promocode= \app\youzan\model\YzActivityPromoCode::findOrEmpty($info->promocode_id);
|
|
|
- if($promocode->isEmpty())throw new \Exception('优惠券信息有误');
|
|
|
- $promocode->save(['status'=>0]);
|
|
|
+ $promocode= \app\youzan\model\YzActivityPromoCode::where(["is_del"=>0,"id"=>$info->promocode_id])->findOrEmpty();
|
|
|
+ if($promocode->isEmpty()){
|
|
|
+ $info->promocode_id=0;
|
|
|
+ $info->status=1;
|
|
|
+ }else {
|
|
|
+ $promocode->save(['status'=>0]);
|
|
|
+ $info->remark="重试生成券码";
|
|
|
+ }
|
|
|
|
|
|
}else{
|
|
|
$info->promocode_id=0;
|
|
|
+ $info->status=1;
|
|
|
}
|
|
|
$save= $info->save();
|
|
|
if(!$save)throw new \Exception('重置失败');
|
|
@@ -183,7 +189,7 @@ class Activity extends Base{
|
|
|
$save= $info->save();
|
|
|
if(!$save)throw new \Exception('删除失败');
|
|
|
if($info->promocode_id!==0){
|
|
|
- $promocode= \app\youzan\model\YzActivityPromoCode::findOrEmpty($info->promocode_id);
|
|
|
+ $promocode= \app\youzan\model\YzActivityPromoCode::where(['is_del'=>0,'id'=>$info->promocode_id])->findOrEmpty();
|
|
|
if($promocode->isEmpty())throw new \Exception('优惠券信息有误');
|
|
|
$promocode->save(['is_del'=>1]);
|
|
|
}
|
|
@@ -221,4 +227,32 @@ class Activity extends Base{
|
|
|
});
|
|
|
$this->success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 优惠券删除
|
|
|
+ */
|
|
|
+ public function promocodeDelete(){
|
|
|
+ $param=$this->request->param(["id"=>""],"post","trim");
|
|
|
+ $info= YzActivityPromoCode::where(['is_del'=>0,'id'=>$param['id']])->findOrEmpty();
|
|
|
+ if($info->isEmpty()){
|
|
|
+ $this->error("信息有误");
|
|
|
+ }
|
|
|
+ $info->is_del=1;
|
|
|
+ try{
|
|
|
+ $save= $info->save();
|
|
|
+ if(!$save)throw new \Exception('删除失败');
|
|
|
+ if($info->act_good_id!==0){
|
|
|
+ $act= $this->model->with(["act"])->where(['is_del'=>0,'id'=>$info->act_good_id])->findOrEmpty();
|
|
|
+ if(!$act->isEmpty()){
|
|
|
+ if(time()<strtotime($act->startTime)){ //活动未开始
|
|
|
+ $act->promocode_id=0;
|
|
|
+ $act->status=1;
|
|
|
+ $act->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ $this->success("删除成功");
|
|
|
+ }
|
|
|
}
|