| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace addons\ScoreExpansion\api\modules\v1\controllers;
- use addons\ScoreExpansion\common\listeners\OrderPaidListener;
- use addons\ScoreExpansion\common\logic\FrozenToActiveLogic;
- use addons\ScoreExpansion\common\logic\ScoreExpansionLogic;
- use addons\ScoreExpansion\common\models\ScoreExpansionRateTask;
- use addons\Store\common\models\StoreOrder;
- use common\models\goods\Goods;
- use Yii;
- use api\controllers\OnAuthController;
- use addons\ScoreExpansion\console\controllers\ScoreExpansionController;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\ScoreExpansion\api\modules\v1\controllers
- */
- class DefaultController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['index'];
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- return 'Hello world';
- }
- /**
- * 定时任务测试
- * @return void
- */
- public function actionCeShi()
- {
- // var_dump(strtotime('2023-03-18'));die;
- ScoreExpansionController::actionFrozenToActive();
- $mall_ids = [1,35];
- // FrozenToActiveLogic::carryOutAppraiseSetting($mall_ids);
- // $params['id'] = 3725;
- // OrderPaidListener::async_handle($params);
- }
- /**
- * 购买商品得积分测试
- * @return void
- */
- public function actionOrderCeShi()
- {
- $source_table = StoreOrder::tableName();
- $task = new ScoreExpansionRateTask();
- $task->order_id = 441;
- $task->is_work = 0;
- $task->source_table = $source_table;
- if(!$task->save()){
- throw new \yii\db\Exception(ScoreExpansionRateTask::getStaticError());
- }
- $order_type = 'StoreOrder';
- $res = ScoreExpansionLogic::giveRedpack(441, 1, $order_type);
- if ($res == false) throw new \yii\db\Exception(ScoreExpansionLogic::getStaticError());
- // $res = ScoreExpansionLogic::giveCashierRedpack(10, 2);
- return $res;
- }
- //测试抵扣
- public function actionGoodsCeshi()
- {
- $item = [];
- $item['goods'] = Goods::find()->where(['id'=>456])->asArray()->all();
- $data = [];
- foreach ($item['goods'] as $key=>$val){
- $data[$val['id']] = $val;
- }
- $item['goods'] = $data;
- $item['mch_order_info']['mall_id'] = $this->mall_id;
- $item['mch_order_info']['user_id'] = $this->user_id;
- $marketing = new \addons\ScoreExpansion\common\logic\order\RedpackMarketing();
- $item = $marketing::compute($item, $form);
- return $item;
- }
- }
|