|
@@ -1,13 +1,14 @@
|
|
|
<?php
|
|
|
declare (strict_types = 1);
|
|
|
|
|
|
-namespace app\youzan\command;
|
|
|
+namespace app\txx\command;
|
|
|
|
|
|
-use app\admin\model\Act;use app\youzan\model\YzGood;use think\console\Command;
|
|
|
+use app\txx\model\YzActivityPromoCode;
|
|
|
+use think\console\Command;
|
|
|
use think\console\Input;
|
|
|
use think\console\input\Argument;
|
|
|
use think\console\input\Option;
|
|
|
-use think\console\Output;
|
|
|
+use think\console\Output;use think\facade\Cache;
|
|
|
|
|
|
class ActGood extends Command
|
|
|
{
|
|
@@ -20,9 +21,16 @@ class ActGood extends Command
|
|
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
|
{
|
|
|
- $output->writeln('<info>actgood</info>');
|
|
|
- $actgood = \app\admin\model\ActGood::with(["act"])->where(["version"=>"2.0","status"=>1,"is_del"=>0,"promocode_id"=>0])->findOrEmpty();
|
|
|
+ if(Cache::get("createPro1")==1) return;
|
|
|
+ Cache::set("createPro1",1,60);
|
|
|
+ try {
|
|
|
+ $output->writeln('<info>actgood</info>');
|
|
|
+ $actgood = \app\txx\model\ActGood::with(['act'])->where(['version'=>'2.0','status'=>1,'is_del'=>0,'promocode_id'=>0])->findOrEmpty();
|
|
|
if($actgood->isEmpty())$this->createPromocode($actgood);
|
|
|
+ }catch (\Exception $e){
|
|
|
+ $output->writeln('<error>'.$e->getMessage().'</error>');
|
|
|
+ }
|
|
|
+ Cache::set("createPro1",0);
|
|
|
}
|
|
|
/**id
|
|
|
act_good_id
|
|
@@ -54,10 +62,11 @@ class ActGood extends Command
|
|
|
*/
|
|
|
//
|
|
|
public function createPromocode($actgood){
|
|
|
- $promocode = \app\youzan\model\YzActivityPromoCode::where(["act_good_id"=>$actgood->id,"skuCoode"=>$actgood->yz_good_code,"status"=>0])->findOrEmpty();
|
|
|
+ $promocode = YzActivityPromoCode::where(["act_good_id"=>$actgood->id,"skuCoode"=>$actgood->yz_good_code,'is_del'=>0])->findOrEmpty();
|
|
|
if($promocode->isEmpty()){
|
|
|
- $promocode = \app\youzan\model\YzActivityPromoCode::create([
|
|
|
+ $promocode = YzActivityPromoCode::create([
|
|
|
"act_good_id"=>$actgood->id,
|
|
|
+ "actCode"=>$actgood->actCode,
|
|
|
"skuCoode"=>$actgood->yz_good_code,
|
|
|
"item_id"=>0,
|
|
|
"title"=>$actgood->name,
|
|
@@ -66,7 +75,7 @@ class ActGood extends Command
|
|
|
"is_forbid_preference"=>1,
|
|
|
"specify_item_ids"=>"",
|
|
|
"is_share"=>0,
|
|
|
- "start_at"=>startTime($actgood->endTime),
|
|
|
+ "start_at"=>startTime($actgood->startTime),
|
|
|
"end_at"=>endTime(date("Y-m-d H:i:s",strtotime($actgood->endTime)+3600*24*7)),
|
|
|
"total"=>$actgood->balance_num,
|
|
|
"expire_notice"=>1,
|
|
@@ -88,6 +97,10 @@ class ActGood extends Command
|
|
|
$actgood->status = 4;
|
|
|
$actgood->save();
|
|
|
}
|
|
|
+ }else{
|
|
|
+ $actgood->remark = "优惠券信息已存在";
|
|
|
+ $actgood->status = 4;
|
|
|
+ $actgood->save();
|
|
|
}
|
|
|
}
|
|
|
}
|