| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace addons\CloudStockTwo\common\logic\reward;
- use addons\CloudStockTwo\common\models\CloudStockTwoAgent;
- use addons\CloudStockTwo\common\models\CloudStockTwoLevel;
- use common\enums\StatusEnum;
- use common\enums\UserWalletEnum;
- class OverReward extends Reward
- {
- public $over_level = 0;
- /**
- * 记录奖励
- */
- protected function addRewardLog()
- {
- $this->getRewardUnitPrice();
- //没有设置奖励金额
- if (empty($this->reward_unit_price)) return false;
- //扣库存数量为0;没有奖励
- if (empty($this->goods_num)) return false;
- if ($this->is_job) return true;
- $insert_wallet = $this->getInsertWallet(UserWalletEnum::OVER);
- if ($insert_wallet) CloudStockTwoAgent::sendUserWalletQueue($insert_wallet);
- }
- public function getRewardUnitPrice()
- {
- $level = CloudStockTwoLevel::findOne(['mall_id' => $this->mall_id, 'level' => $this->bonus_agent['level'], 'status' => StatusEnum::ENABLED]);
- switch ($this->over_level) {
- case 1:
- $over_level_list = json_decode($this->stock_goods['over_level_list'], true);
- $this->reward_unit_price = 0;
- break;
- case 2:
- if(!empty($this->stock_goods['over_level_list_2'])){
- $over_level_list_2 = json_decode($this->stock_goods['over_level_list_2'], true);
- $over_level_list = $over_level_list_2;
- }
- break;
- default:
- $this->reward_unit_price = 0;
- return;
- }
- if (!empty($level) && !empty($over_level_list)) {
- foreach ($over_level_list as $value) {
- if ($value['level'] == $this->bonus_agent->level) {
- $this->reward_unit_price = $value['price'];
- return;
- }
- }
- }
- $this->reward_unit_price = 0;
- }
- }
|