| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace biz\market\classes;
- use biz\base\classes\BaseClass;
- use biz\hb\classes\HbClass;
- use common\components\util;
- class XrFlClass extends BaseClass
- {
- public static $baseFile = '\biz\market\models\XrFl';
- //新人福利发红包 shish 20211026
- public static function giveGift($ghs, $custom)
- {
- $shopId = $ghs->shopId ?? 0;
- $flData = self::getAllByCondition(['shopId' => $shopId], null, '*');
- if (empty($flData)) {
- util::fail('红包发完了');
- }
- $ghsId = $item->id ?? 0;
- $ghsName = $ghs->name ?? '';
- $ghsAvatar = $ghs->avatar ?? '';
- $ghsSjId = $ghs->sjId ?? 0;
- $ghsShopId = $ghs->shopId ?? 0;
- $customId = $ghs->customId ?? 0;
- $customName = $custom->name ?? '';
- $customPy = $custom->py ?? '';
- $customAvatar = $custom->avatar ?? '';
- $customSjId = $custom->sjId ?? 0;
- $customShopId = $custom->shopId ?? 0;
- $sjId = $custom->sjId ?? 0;
- $shopId = $custom->shopId ?? 0;
- foreach ($flData as $item) {
- $hbAmount = $item->hbAmount ?? 0;
- $hbNum = $item->num ?? 0;
- $valid = $item->valid ?? 0;
- $miniExpend = $item->miniExpend ?? 0;
- for ($i = 0; $i < $hbNum; $i++) {
- $start = date("Y-m-d H:i:s");
- $end = date("Y-m-d H:i:s", time() + $valid * 86400);
- $coupon = [
- 'sjId' => $sjId,
- 'shopId' => $shopId,
- 'beginTime' => $start,
- 'endTime' => $end,
- 'name' => '红包',
- 'amount' => $hbAmount,
- 'miniCost' => $miniExpend,
- 'status' => HbClass::STATUS_UN_USE,
- 'ghsId' => $ghsId,
- 'ghsName' => $ghsName,
- 'ghsAvatar' => $ghsAvatar,
- 'ghsSjId' => $ghsSjId,
- 'ghsShopId' => $ghsShopId,
- 'customId' => $customId,
- 'customName' => $customName,
- 'customPy' => $customPy,
- 'customAvatar' => $customAvatar,
- 'customSjId' => $customSjId,
- 'customShopId' => $customShopId,
- 'from' => HbClass::FROM_NEW,
- 'remark' => "新人红包",
- ];
- HbClass::add($coupon);
- }
- }
- }
- }
|