FillRewardLogic.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace addons\CloudStock\common\logic\reward;
  3. use addons\CloudStock\common\models\CloudStockAgent;
  4. use app\plugins\cloud_stock\helpers\BonusMessage;
  5. use app\plugins\cloud_stock\helpers\SmsConfig;
  6. use common\enums\AddonsEnum;
  7. use common\enums\UserWalletEnum;
  8. use Overtrue\EasySms\EasySms;
  9. class FillRewardLogic extends Reward
  10. {
  11. /**
  12. * 记录奖励
  13. */
  14. public function addRewardLog()
  15. {
  16. $this->getRewardUnitPrice();
  17. //奖励金额,不记录
  18. if (empty($this->reward_unit_price)) return 0;
  19. //扣库存数量为0;没有奖励
  20. if (empty($this->goods_num)) return 0;
  21. if($this->is_job) return $this->reward_unit_price;
  22. //投递到资产队列
  23. $insert_wallet = $this->getInsertWallet(UserWalletEnum::FILL);
  24. if ($insert_wallet) CloudStockAgent::sendUserWalletQueue($insert_wallet);
  25. return $this->reward_unit_price;
  26. }
  27. /**
  28. * 获取对应等级商品奖励金额单价
  29. */
  30. protected function getRewardUnitPrice()
  31. {
  32. $fill_level_list = json_decode($this->stock_goods['fill_level_list'], true);
  33. if (!empty($fill_level_list)) {
  34. foreach ($fill_level_list as $value) {
  35. if ($value['level'] == $this->bonus_agent['level']) {
  36. $this->reward_unit_price = !empty($value['price']) ? $value['price'] : 0;
  37. return;
  38. }
  39. }
  40. }
  41. $this->reward_unit_price = 0;
  42. }
  43. }