TjFlClass.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace biz\market\classes;
  3. use biz\base\classes\BaseClass;
  4. use biz\hb\classes\HbClass;
  5. use biz\shop\classes\ShopClass;
  6. use biz\wx\classes\WxMessageClass;
  7. class TjFlClass extends BaseClass
  8. {
  9. public static $baseFile = '\biz\market\models\TjFl';
  10. //新人福利发红包 ssh 20211026
  11. public static function giveGift($ghs, $custom, $beTjCustom)
  12. {
  13. $shopId = $ghs->shopId ?? 0;
  14. $flData = self::getAllByCondition(['shopId' => $shopId, 'delStatus' => 0], null, '*', null, true);
  15. if (empty($flData)) {
  16. return false;
  17. }
  18. $beTjCustomName = $beTjCustom->name ?? '';
  19. $ghsId = $ghs->id ?? 0;
  20. $ghsName = $ghs->name ?? '';
  21. $ghsAvatar = $ghs->avatar ?? '';
  22. $ghsSjId = $ghs->sjId ?? 0;
  23. $ghsShopId = $ghs->shopId ?? 0;
  24. $ghsShop = ShopClass::getById($ghsShopId, true);
  25. $customId = $ghs->customId ?? 0;
  26. $customName = $custom->name ?? '';
  27. $customPy = $custom->py ?? '';
  28. $customAvatar = $custom->avatar ?? '';
  29. $customSjId = $custom->sjId ?? 0;
  30. $customShopId = $custom->shopId ?? 0;
  31. $sjId = $custom->sjId ?? 0;
  32. $shopId = $custom->shopId ?? 0;
  33. $hdShop = ShopClass::getById($shopId, true);
  34. foreach ($flData as $item) {
  35. $hbAmount = $item->hbAmount ?? 0;
  36. $hbNum = $item->num ?? 0;
  37. $valid = $item->valid ?? 0;
  38. $miniExpend = $item->miniExpend ?? 0;
  39. for ($i = 0; $i < $hbNum; $i++) {
  40. $start = date("Y-m-d H:i:s");
  41. $end = date("Y-m-d H:i:s", time() + $valid * 86400);
  42. $coupon = [
  43. 'sjId' => $sjId,
  44. 'shopId' => $shopId,
  45. 'beginTime' => $start,
  46. 'endTime' => $end,
  47. 'name' => '红包',
  48. 'amount' => $hbAmount,
  49. 'miniCost' => $miniExpend,
  50. 'status' => HbClass::STATUS_UN_USE,
  51. 'ghsId' => $ghsId,
  52. 'ghsName' => $ghsName,
  53. 'ghsAvatar' => $ghsAvatar,
  54. 'ghsSjId' => $ghsSjId,
  55. 'ghsShopId' => $ghsShopId,
  56. 'customId' => $customId,
  57. 'customName' => $customName,
  58. 'customPy' => $customPy,
  59. 'customAvatar' => $customAvatar,
  60. 'customSjId' => $customSjId,
  61. 'customShopId' => $customShopId,
  62. 'from' => HbClass::FROM_TJ,
  63. 'remark' => "介绍的新客【{$beTjCustomName}】大概在" . date("Y-m-d H:i") . "下单",
  64. ];
  65. HbClass::add($coupon);
  66. }
  67. }
  68. WxMessageClass::ghsCustomTjGetGiftInform($ghsShop, $custom, $beTjCustom);
  69. WxMessageClass::hdTjGhsCustomGetGiftInform($hdShop, $ghs, $beTjCustom);
  70. }
  71. }