SyncSharerList.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\jobs;
  3. use app\models\StoreMini;
  4. use app\modules\admin\models\VideoShopForm;
  5. use app\modules\admin\models\VideoShopOrderForm;
  6. use app\utils\Wechat\WechatMini;
  7. use yii\base\BaseObject;
  8. use yii\queue\JobInterface;
  9. use app\models\Store;
  10. class SyncSharerList extends BaseObject implements JobInterface
  11. {
  12. public $store_id;
  13. public function execute($queue)
  14. {
  15. $storeList = [];
  16. if(is_null($this->store_id)){
  17. $storeList = Store::find()->where(['is_delete' => 0])->select('id')->column();
  18. }else{
  19. $storeList = [$this->store_id];
  20. }
  21. foreach ($storeList as $store_id){
  22. $base_ = new WechatMini();
  23. $form_ = new VideoShopOrderForm();
  24. $form = new VideoShopForm();
  25. $store_mini = StoreMini::find()->where(['store_id' => $store_id, 'fuwu_type' => 1, 'is_cancle' => 0])->select('id')->column();
  26. foreach ($store_mini as $mini_item) {
  27. $miniProgram = $base_::getWechatConfig($store_id, $mini_item, 1);
  28. if ($miniProgram) {
  29. $form->miniProgram = $miniProgram;
  30. $form->store_id = $store_id;
  31. $form->mini_id = $base_::$mini_id;
  32. $form->getApplySharerInfo();
  33. $form->syncSharerList();
  34. $form_->miniProgram = $miniProgram;
  35. $form_->store_id = $store_id;
  36. $form_->mini_id = $base_::$mini_id;
  37. $form_->end_time = time();
  38. $form_->start_time = time() - (60 * 60 * 24 * 2);
  39. $form_->syncOrderList();
  40. }
  41. }
  42. }
  43. }
  44. }