SetProfitStrategyJob.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\jobs;
  3. use app\models\Option;
  4. use app\modules\admin\models\PlatformForm;
  5. use yii\base\BaseObject;
  6. use yii\queue\JobInterface;
  7. //云仓营销策略设置
  8. class SetProfitStrategyJob extends BaseObject implements JobInterface
  9. {
  10. public function execute($queue)
  11. {
  12. $platform_profit_strategy = Option::get('platform_profit_strategy', 0, 'store')['value'];
  13. $platform_profit_strategy = json_decode($platform_profit_strategy, true);
  14. if (!empty($platform_profit_strategy)) {
  15. //服务收费start
  16. if (intval($platform_profit_strategy['service_charge_model'])) {
  17. //平台溢价
  18. $service_charge_rate = $platform_profit_strategy['service_charge_rate'];
  19. } else {
  20. //供货商抽成
  21. $service_charge_rate = 0;
  22. }
  23. $form = new PlatformForm();
  24. $result = $form->setPlatformNegotiatedPrice($service_charge_rate);
  25. debug_log($result, 'set_platform_negotiated_price.log');
  26. //服务收费end
  27. //风控规则start
  28. if (intval($platform_profit_strategy['is_risk_control'])) {
  29. $id = \Yii::$app->cache->get('risk_control_model_id');
  30. if ($id && !\Yii::$app->queue->isDone($id)) {
  31. \Yii::$app->queue->remove($id);
  32. }
  33. $id = \queue_push(new \app\jobs\RiskControlModelJob());
  34. \Yii::$app->cache->set('risk_control_model_id', $id);
  35. }
  36. //风控规则end
  37. //加价保护start
  38. // if (intval($platform_profit_strategy['is_markup_protection'])) {
  39. //如果开启 就在保存商品时判断 不使用消息队列判断
  40. // }
  41. //加价保护end
  42. }
  43. }
  44. }