FillDeductionLogic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace addons\CloudStockTwo\common\logic\deduction;
  3. use addons\CloudStockTwo\common\models\CloudStockTwoAgent;
  4. use addons\CloudStockTwo\common\models\CloudStockTwoLevel;
  5. use common\enums\StatusEnum;
  6. class FillDeductionLogic extends DeductionLogic
  7. {
  8. public function getUnitGoodsPrice()
  9. {
  10. if ($this->order->pay_money <= 0) return 0;
  11. $this->unit_goods_price = $this->getOrderGoodsUnitPrice();
  12. //队列触发的,不用再计算平级、越级奖
  13. //平级奖、越级奖扣除
  14. //获取补货者代理商数据
  15. // $agent = CloudStockTwoAgent::findOne(['user_id' => $this->user_id, 'mall_id' => $this->mall_id,'status'=>StatusEnum::ENABLED]);
  16. //发放平一级对象,直推
  17. // if (!empty($this->user['parent_id'])) {
  18. // $direct_agent = CloudStockTwoAgent::findOne(['user_id' => $this->user['parent_id'], 'mall_id' => $this->mall_id,'status'=>StatusEnum::ENABLED]);
  19. // $stock_level = CloudStockTwoLevel::findOne(['mall_id' => $this->mall_id, 'level' => $direct_agent['level'], 'status' => StatusEnum::ENABLED]);
  20. // //获取平一级代理商数据
  21. // if ($direct_agent) {
  22. // //发放平一级奖励
  23. // $over_desc = "补货越级奖发放,越级层数1";
  24. // $equal_desc = "补货平级奖发放,平级层数1";
  25. // $this->equalOne($agent, $direct_agent, $stock_level, $over_desc, $equal_desc, $this->order['num']);
  26. // }
  27. // //发放平二级用户,间推
  28. // if (!empty($this->user['second_parent_id'])) {
  29. // //获取平二级代理商数据
  30. // $second_parent_agent = CloudStockTwoAgent::findOne(['user_id' => $this->user['second_parent_id'],'status'=>StatusEnum::ENABLED, 'mall_id' => $this->mall_id]);
  31. // if($second_parent_agent){
  32. // switch (true) {
  33. // case $agent['level'] > $second_parent_agent['level']:
  34. // $over_level = 2;
  35. // $over_desc = "补货越级奖发放,越级层数" . $over_level;
  36. // $this->sendOverReward($second_parent_agent, $stock_level, $over_level, $over_desc, $this->order['num']);
  37. // break;
  38. // case $agent['level'] == $second_parent_agent['level']:
  39. // $equal_level = 2;
  40. // $equal_desc = "补货平级奖发放,平级层数" . $equal_level;
  41. // $stock_level = CloudStockTwoLevel::findOne(['mall_id' => $this->mall_id, 'level' => $second_parent_agent['level'], 'status' => StatusEnum::ENABLED]);
  42. // $this->sendEqualReward($second_parent_agent, $stock_level, $equal_level, $equal_desc, $this->order['num']);
  43. // break;
  44. // }
  45. // }
  46. // }
  47. // }
  48. return $this->unit_goods_price;
  49. }
  50. /**
  51. * 货款单价
  52. * @return float|int
  53. */
  54. public function getOrderGoodsUnitPrice()
  55. {
  56. $money = ($this->order->pay_money - $this->order->reward_unit_price) / $this->order->num;
  57. return $money;
  58. }
  59. }