27 lines
813 B
PHP
27 lines
813 B
PHP
|
<?php
|
||
|
|
||
|
namespace app\commands\tasks;
|
||
|
|
||
|
use app\models\common\CallbackOrder;
|
||
|
use app\models\common\Config;
|
||
|
use app\models\common\WeChat;
|
||
|
use Yansongda\Pay\Pay;
|
||
|
use yii;
|
||
|
use yii\console\Controller;
|
||
|
use yii\console\ExitCode;
|
||
|
class UserCouponController extends Controller
|
||
|
{
|
||
|
public function actionSaveCode(){
|
||
|
$data = (new \yii\db\Query())
|
||
|
->from('{{%ybwm_user_coupon}}')
|
||
|
->where(['state' => 2, 'selfCode' => 0])
|
||
|
->all();
|
||
|
if(!empty($data)){
|
||
|
foreach ($data as $key => $v){
|
||
|
$code = rand(11111111,9999999);
|
||
|
$res = Yii::$app->db->createCommand()->update('{{%ybwm_user_coupon}}', ['selfCode'=>$code], 'id=:id', ['id' =>$v['id']])->execute();
|
||
|
echo empty($res) ? "error" : "ok";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|