DefaultController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace addons\ScoreExpansion\api\modules\v1\controllers;
  3. use addons\ScoreExpansion\common\listeners\OrderPaidListener;
  4. use addons\ScoreExpansion\common\logic\FrozenToActiveLogic;
  5. use addons\ScoreExpansion\common\logic\ScoreExpansionLogic;
  6. use addons\ScoreExpansion\common\models\ScoreExpansionRateTask;
  7. use addons\Store\common\models\StoreOrder;
  8. use common\models\goods\Goods;
  9. use Yii;
  10. use api\controllers\OnAuthController;
  11. use addons\ScoreExpansion\console\controllers\ScoreExpansionController;
  12. /**
  13. * 默认控制器
  14. *
  15. * Class DefaultController
  16. * @package addons\ScoreExpansion\api\modules\v1\controllers
  17. */
  18. class DefaultController extends OnAuthController
  19. {
  20. public $modelClass = '';
  21. /**
  22. * 不用进行登录验证的方法
  23. *
  24. * 例如: ['index', 'update', 'create', 'view', 'delete']
  25. * 默认全部需要验证
  26. *
  27. * @var array
  28. */
  29. protected $authOptional = ['index'];
  30. /**
  31. * 首页
  32. *
  33. * @return string
  34. */
  35. public function actionIndex()
  36. {
  37. return 'Hello world';
  38. }
  39. /**
  40. * 定时任务测试
  41. * @return void
  42. */
  43. public function actionCeShi()
  44. {
  45. // var_dump(strtotime('2023-03-18'));die;
  46. ScoreExpansionController::actionFrozenToActive();
  47. $mall_ids = [1,35];
  48. // FrozenToActiveLogic::carryOutAppraiseSetting($mall_ids);
  49. // $params['id'] = 3725;
  50. // OrderPaidListener::async_handle($params);
  51. }
  52. /**
  53. * 购买商品得积分测试
  54. * @return void
  55. */
  56. public function actionOrderCeShi()
  57. {
  58. $source_table = StoreOrder::tableName();
  59. $task = new ScoreExpansionRateTask();
  60. $task->order_id = 441;
  61. $task->is_work = 0;
  62. $task->source_table = $source_table;
  63. if(!$task->save()){
  64. throw new \yii\db\Exception(ScoreExpansionRateTask::getStaticError());
  65. }
  66. $order_type = 'StoreOrder';
  67. $res = ScoreExpansionLogic::giveRedpack(441, 1, $order_type);
  68. if ($res == false) throw new \yii\db\Exception(ScoreExpansionLogic::getStaticError());
  69. // $res = ScoreExpansionLogic::giveCashierRedpack(10, 2);
  70. return $res;
  71. }
  72. //测试抵扣
  73. public function actionGoodsCeshi()
  74. {
  75. $item = [];
  76. $item['goods'] = Goods::find()->where(['id'=>456])->asArray()->all();
  77. $data = [];
  78. foreach ($item['goods'] as $key=>$val){
  79. $data[$val['id']] = $val;
  80. }
  81. $item['goods'] = $data;
  82. $item['mch_order_info']['mall_id'] = $this->mall_id;
  83. $item['mch_order_info']['user_id'] = $this->user_id;
  84. $marketing = new \addons\ScoreExpansion\common\logic\order\RedpackMarketing();
  85. $item = $marketing::compute($item, $form);
  86. return $item;
  87. }
  88. }