| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace addons\CloudStockTwo\common\logic\deduction;
- use addons\CloudStockTwo\common\models\CloudStockTwoAgent;
- use addons\CloudStockTwo\common\models\CloudStockTwoLevel;
- use common\enums\StatusEnum;
- class FillDeductionLogic extends DeductionLogic
- {
- public function getUnitGoodsPrice()
- {
- if ($this->order->pay_money <= 0) return 0;
- $this->unit_goods_price = $this->getOrderGoodsUnitPrice();
- //队列触发的,不用再计算平级、越级奖
- //平级奖、越级奖扣除
- //获取补货者代理商数据
- // $agent = CloudStockTwoAgent::findOne(['user_id' => $this->user_id, 'mall_id' => $this->mall_id,'status'=>StatusEnum::ENABLED]);
- //发放平一级对象,直推
- // if (!empty($this->user['parent_id'])) {
- // $direct_agent = CloudStockTwoAgent::findOne(['user_id' => $this->user['parent_id'], 'mall_id' => $this->mall_id,'status'=>StatusEnum::ENABLED]);
- // $stock_level = CloudStockTwoLevel::findOne(['mall_id' => $this->mall_id, 'level' => $direct_agent['level'], 'status' => StatusEnum::ENABLED]);
- // //获取平一级代理商数据
- // if ($direct_agent) {
- // //发放平一级奖励
- // $over_desc = "补货越级奖发放,越级层数1";
- // $equal_desc = "补货平级奖发放,平级层数1";
- // $this->equalOne($agent, $direct_agent, $stock_level, $over_desc, $equal_desc, $this->order['num']);
- // }
- // //发放平二级用户,间推
- // if (!empty($this->user['second_parent_id'])) {
- // //获取平二级代理商数据
- // $second_parent_agent = CloudStockTwoAgent::findOne(['user_id' => $this->user['second_parent_id'],'status'=>StatusEnum::ENABLED, 'mall_id' => $this->mall_id]);
- // if($second_parent_agent){
- // switch (true) {
- // case $agent['level'] > $second_parent_agent['level']:
- // $over_level = 2;
- // $over_desc = "补货越级奖发放,越级层数" . $over_level;
- // $this->sendOverReward($second_parent_agent, $stock_level, $over_level, $over_desc, $this->order['num']);
- // break;
- // case $agent['level'] == $second_parent_agent['level']:
- // $equal_level = 2;
- // $equal_desc = "补货平级奖发放,平级层数" . $equal_level;
- // $stock_level = CloudStockTwoLevel::findOne(['mall_id' => $this->mall_id, 'level' => $second_parent_agent['level'], 'status' => StatusEnum::ENABLED]);
- // $this->sendEqualReward($second_parent_agent, $stock_level, $equal_level, $equal_desc, $this->order['num']);
- // break;
- // }
- // }
- // }
- // }
- return $this->unit_goods_price;
- }
- /**
- * 货款单价
- * @return float|int
- */
- public function getOrderGoodsUnitPrice()
- {
- $money = ($this->order->pay_money - $this->order->reward_unit_price) / $this->order->num;
- return $money;
- }
- }
|