|
|
@@ -224,69 +224,6 @@ class NoticeController extends PublicController
|
|
|
Yii::$app->redis->executeCommand('SETEX', [$myKey, 864000, 'has']);
|
|
|
$recharge = RechargeClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
ShopExtClass::skRechargeReport($recharge);
|
|
|
-
|
|
|
- //充值送红包 -- 有多处,请搜索:充值送红包处理
|
|
|
- $shopId = $recharge->shopId;
|
|
|
- $amount = $recharge->amount;
|
|
|
- $maxHbRule = RechargeShbClass::getByCondition(['shopId' => $shopId, 'amount<=' => $amount], false, 'allHbAmount DESC');
|
|
|
-
|
|
|
- if (!empty($maxHbRule)) {
|
|
|
- $currentTime = time();
|
|
|
-
|
|
|
- $rulesJson = $maxHbRule['rules'] ?? '';
|
|
|
- $rulesArr = json_decode($rulesJson, true);
|
|
|
-
|
|
|
- if (is_array($rulesArr) && !empty($rulesArr)) {
|
|
|
- foreach ($rulesArr as $rule) {
|
|
|
- $hbAmount = $rule['hbAmount'];
|
|
|
- $hbNum = $rule['hbNum'];
|
|
|
- $miniCost = $rule['miniCost'];
|
|
|
- $duration = $rule['duration'];
|
|
|
- $effectiveType = $rule['effectiveType'] ?? 2;
|
|
|
- $effectiveDate = $rule['effectiveDate'] ?? '';
|
|
|
- $effectiveDays = $rule['effectiveDays'] ?? 0;
|
|
|
-
|
|
|
- if ($effectiveType == 1 && !empty($effectiveDate) && $effectiveDate != '0000-00-00') {
|
|
|
- $beginTime = strtotime($effectiveDate);
|
|
|
- if (!$beginTime) {
|
|
|
- $beginTime = $currentTime;
|
|
|
- }
|
|
|
- } else {
|
|
|
- $beginTime = $currentTime + 86400 * $effectiveDays;
|
|
|
- }
|
|
|
-
|
|
|
- //给用户生成红包
|
|
|
- $data = [
|
|
|
- 'mainId' => $recharge->mainId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'userId' => $recharge->userId,
|
|
|
- 'customId' => $recharge->customId,
|
|
|
- 'amount' => $hbAmount,
|
|
|
- 'minConsume' => $miniCost,
|
|
|
- 'beginTime' => $beginTime,
|
|
|
- 'endTime' => $duration == 0 ? 4102416000 : ($beginTime + 86400 * $duration),
|
|
|
- 'willTime' => $duration == 0 ? 4102416000 : ($beginTime + 86400 * $duration),
|
|
|
- 'duration' => $duration,
|
|
|
- 'getType' => 2, //取得方式 0新人领取 1门店发放 2充值赠送
|
|
|
- 'remark' => '充值赠送红包',
|
|
|
- ];
|
|
|
-
|
|
|
- $manageData = [
|
|
|
- 'getType' => 2,
|
|
|
- 'getTargetId' => 0,
|
|
|
- 'createStaffId' => 0,
|
|
|
- 'createStaffName' => '',
|
|
|
- 'remark' => $data['remark'] ?? '',
|
|
|
- ];
|
|
|
- for ($i = 0; $i < $hbNum; $i++) {
|
|
|
- $hb = HbClass::add($data);
|
|
|
-
|
|
|
- $manageData['hbId'] = $hb['id'];
|
|
|
- HbManageClass::add($manageData);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|