WeChatCallbackLogic.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace addons\WechatVideoShop\common\logic;
  3. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackBrandTrait;
  4. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackCateTrait;
  5. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackComplaintTrait;
  6. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackGoodsTrait;
  7. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackOrderTrait;
  8. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackRefundTrait;
  9. use addons\WechatVideoShop\common\logic\traits\WeChatCallbackShopCloseTrait;
  10. class WeChatCallbackLogic
  11. {
  12. use WeChatCallbackBrandTrait, WeChatCallbackComplaintTrait, WeChatCallbackCateTrait, WeChatCallbackGoodsTrait, WeChatCallbackRefundTrait,
  13. WeChatCallbackOrderTrait, WeChatCallbackRefundTrait, WeChatCallbackShopCloseTrait;
  14. protected $mall_id;
  15. protected $shop_id;
  16. protected $data = [];
  17. protected $customer_num = 0; // 消费次数
  18. public function __construct(int $mall_id = 0, int $shop_id = 0, int $customer_num = 0, array $data = [])
  19. {
  20. $this->mall_id = $mall_id;
  21. $this->shop_id = $shop_id;
  22. $this->customer_num = $customer_num;
  23. $this->data = $data;
  24. }
  25. /**
  26. * 队列初始化
  27. * @param array $params
  28. * @return void
  29. */
  30. protected function init(array $params)
  31. {
  32. if (!empty($params)) {
  33. $this->mall_id = $params['mall_id'] ?? 0;
  34. $this->shop_id = $params['shop_id'] ?? 0;
  35. $this->customer_num = $params['customer_num'] ?? 0;
  36. $this->data = $params['data'] ?? [];
  37. }
  38. }
  39. /**
  40. * 不存在的事件都在这里
  41. * @return void
  42. */
  43. public function call(array $params)
  44. {
  45. $this->init($params);
  46. \Yii::error(__METHOD__ . " method not exists [$this->mall_id] -> " . var_export($this->data, true));
  47. }
  48. }