Skip to content

Commit

Permalink
feat: remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Jul 5, 2024
1 parent c36a57c commit 2e9780f
Show file tree
Hide file tree
Showing 42 changed files with 20,800 additions and 224 deletions.
3 changes: 3 additions & 0 deletions config/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
'Cms' => [
'enable' => true,
],
// 'DataAliyunOssFe' => [
// 'enable' => true,
// ],
// 'Recommend' => [
// 'enable' => true,
// ],
Expand Down
4 changes: 3 additions & 1 deletion module/Banner/Admin/Controller/BannerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ protected function crud(AdminCRUDBuilder $builder)
->when(BannerType::VIDEO, function ($context) {
/** @var HasFields $context */
$context->video('video', '视频');
})->required();
})
->defaultValue(BannerType::IMAGE)
->required();
$builder->color('backgroundColor', '背景色');
$builder->link('link', '链接');
$builder->display('created_at', L('Created At'))->listable(false);
Expand Down
5 changes: 3 additions & 2 deletions module/Banner/Docs/release.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## 1.8.0
## 1.8.0 轮播图获取支持仅图片过滤方法,视频 Banner 概率不播放问题

- 新增:轮播图获取支持近图片过滤方法
- 新增:轮播图获取支持仅图片过滤方法
- 优化:视频 `Banner` 概率不播放问题
- 优化:轮播类型添加修改是否为空判断

---

Expand Down
4 changes: 2 additions & 2 deletions module/Banner/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"require": [
"Vendor:>=3.0.0"
],
"modstartVersion": ">=2.6.0",
"modstartVersion": ">=3.9.0",
"title": "通用轮播",
"version": "1.8.0",
"author": "官方",
Expand All @@ -24,4 +24,4 @@
]
]
}
}
}
70 changes: 58 additions & 12 deletions module/Member/Api/Controller/MemberVipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
use ModStart\Core\Exception\BizException;
use ModStart\Core\Input\InputPackage;
use ModStart\Core\Input\Response;
use ModStart\Core\Util\SerializeUtil;
use Module\Member\Auth\MemberUser;
use Module\Member\Auth\MemberVip;
use Module\Member\Core\MemberVipPayCenterBiz;
use Module\Member\Core\MemberVipVoucherBiz;
use Module\Member\Model\MemberVipOrder;
use Module\Member\Support\MemberLoginCheck;
use Module\Member\Util\MemberVipUtil;
use Module\PayCenter\Support\PayCenterPerform;
Expand Down Expand Up @@ -50,23 +53,45 @@ public function buy()
if (empty($memberVip)) {
return Response::generateError('请选择会员类型');
}
$priceInfoRet = $this->calc($vipId);
$priceInfoRet = $this->processCalc();
if ($priceInfoRet['code']) {
return Response::generateError($priceInfoRet['msg']);
}
$money = $priceInfoRet['data']['price'];
if ($money < 0.01) {
return Response::generateError('支付金额为空0.01');
}
$memberVipOrder = ModelUtil::insert('member_vip_order', [
'status' => OrderStatus::WAIT_PAY,
'memberUserId' => MemberUser::id(),
'vipId' => $memberVip['id'],
'payFee' => $money,
'expire' => $priceInfoRet['data']['expire'],
'type' => $priceInfoRet['data']['type'],
]);
BizException::throwsIf('请安装 PayCenter 模块', !modstart_module_enabled('PayCenter'));
try {
ModelUtil::transactionBegin();
$orderParam = [];
if (!empty($priceInfoRet['data']['usedVoucherItems'])) {
$orderParam['voucherItemIds'] = array_column($priceInfoRet['data']['usedVoucherItems'], 'id');
}
$memberVipOrder = ModelUtil::insert(MemberVipOrder::class, [
'status' => OrderStatus::WAIT_PAY,
'memberUserId' => MemberUser::id(),
'vipId' => $memberVip['id'],
'payFee' => $money,
'expire' => $priceInfoRet['data']['expire'],
'type' => $priceInfoRet['data']['type'],
'param' => SerializeUtil::jsonEncode($orderParam),
]);
if (!empty($priceInfoRet['data']['usedVoucherItems'])) {
MemberVipVoucherBiz::bizer()->processUpdateUsedItemsInTransactionOrFail(
MemberUser::id(),
$priceInfoRet['data']['usedVoucherItems'],
'MemberVipOrder',
$memberVipOrder['id']
);
}
ModelUtil::transactionCommit();
} catch (BizException $e) {
ModelUtil::transactionRollback();
return Response::generateError($e->getMessage());
} catch (\Exception $e) {
ModelUtil::transactionRollback();
throw $e;
}
$payCenterPerform = app(PayCenterPerform::class);
return $payCenterPerform->performSubmitOrder(
MemberVipPayCenterBiz::NAME,
Expand All @@ -76,7 +101,14 @@ public function buy()
);
}

public function calc($vipId = 0)
public function calc()
{
$ret = $this->processCalc();
unset($ret['data']['usedVoucherItems']);
return $ret;
}

private static function processCalc()
{
$input = InputPackage::buildFromInput();
if (MemberUser::isNotLogin()) {
Expand All @@ -97,6 +129,20 @@ public function calc($vipId = 0)
if ($ret['code']) {
return Response::generateError($ret['msg']);
}
return Response::generateSuccessData($ret['data']);
$data = $ret['data'];
if (modstart_module_enabled('Voucher')) {
$voucherId = $input->getInteger('voucherId');
if ($voucherId > 0) {
$bizer = MemberVipVoucherBiz::bizer();
$voucherItems = MemberVipVoucherBiz::listValidForMemberWithItemIds(MemberUser::id(), [$voucherId]);
$voucherItems = $bizer->processFindUsableItems(MemberUser::id(), $voucherItems);
$processResult = $bizer->processComputeItems(MemberUser::id(), $voucherItems, [
'price' => $data['price'],
]);
$data['price'] = $processResult['price'];
$data['usedVoucherItems'] = $processResult['usedVoucherItems'];
}
}
return Response::generateSuccessData($data);
}
}
2 changes: 1 addition & 1 deletion module/Member/Asset/script/memberVip.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion module/Member/Asset/style/member.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion module/Member/Core/MemberVipPayCenterBiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use ModStart\Core\Dao\ModelUtil;
use ModStart\Core\Exception\BizException;
use ModStart\Core\Input\Response;
use ModStart\Core\Util\SerializeUtil;
use ModStart\Module\ModuleManager;
use Module\Member\Events\MemberUserVipChangeEvent;
use Module\Member\Model\MemberVipOrder;
use Module\Member\Util\MemberCreditUtil;
use Module\Member\Util\MemberUtil;
use Module\Member\Util\MemberVipUtil;
Expand Down Expand Up @@ -72,16 +74,41 @@ public function createOrderForQuick($quickOrder, $param = [])
$priceInfoRet = MemberVipUtil::calcPrice($memberUser['vipId'], $memberUser['vipExpire'], $vipId);
BizException::throwsIf($priceInfoRet['msg'], $priceInfoRet['code'] > 0);
$money = $priceInfoRet['data']['price'];
if (modstart_module_enabled('Voucher')) {
$voucherId = isset($quickOrder['param']['voucherId']) ? intval($quickOrder['param']['voucherId']) : 0;
if ($voucherId > 0) {
$bizer = MemberVipVoucherBiz::bizer();
$voucherItems = MemberVipVoucherBiz::listValidForMemberWithItemIds($memberUserId, [$voucherId]);
$voucherItems = $bizer->processFindUsableItems($memberUserId, $voucherItems);
$processResult = $bizer->processComputeItems($memberUserId, $voucherItems, [
'price' => $money,
]);
$money = $processResult['price'];
}
}
// Log::info('MemberVipPayCenterBiz.createOrderForQuick - ' . json_encode([$quickOrder, $priceInfoRet], JSON_UNESCAPED_UNICODE));
BizException::throwsIf('订单金额异常', $money < 0.01 || $money > 1000 * 10000);
$order = ModelUtil::insert('member_vip_order', [
$orderParam = [];
if (!empty($processResult['usedVoucherItems'])) {
$orderParam['voucherItemIds'] = array_column($processResult['usedVoucherItems'], 'id');
}
$order = ModelUtil::insert(MemberVipOrder::class, [
'status' => OrderStatus::WAIT_PAY,
'memberUserId' => $memberUserId,
'vipId' => $memberVip['id'],
'payFee' => $money,
'expire' => $priceInfoRet['data']['expire'],
'type' => $priceInfoRet['data']['type'],
'param' => SerializeUtil::jsonEncode($orderParam),
]);
if (!empty($processResult['usedVoucherItems'])) {
MemberVipVoucherBiz::bizer()->processUpdateUsedItemsInTransactionOrFail(
$memberUserId,
$processResult['usedVoucherItems'],
'MemberVipOrder',
$order['id']
);
}
return Response::generateSuccessData([
'bizId' => $order['id'],
'feeTotal' => $money,
Expand Down
59 changes: 59 additions & 0 deletions module/Member/Core/MemberVipVoucherBiz.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Module\Member\Core;

use ModStart\Core\Util\NumberUtil;
use ModStart\Form\Form;
use Module\Voucher\Biz\AbstractVoucherBiz;
use Module\Voucher\Type\VoucherType;

class MemberVipVoucherBiz extends AbstractVoucherBiz
{
const NAME = 'MemberVip';

public function name()
{
return self::NAME;
}

public function title()
{
return '会员VIP';
}

public function adminRenderForm(Form $form)
{
$form->radio('type', '类型')
->options(VoucherType::only([VoucherType::DISCOUNT]))
->when('=', VoucherType::DISCOUNT, function (Form $form) {
$form->number('typeDiscount', '折扣')->help('0-100,80表示打八折');
})
->required()
->defaultValue(VoucherType::DISCOUNT);
}

public function itemUsable($voucherItemData, $memberUserId, $data = [])
{
$vipId = $data['vipId'];
if (empty($vipId)) {
return false;
}
switch ($voucherItemData['_voucher']['type']) {
case VoucherType::DISCOUNT:
return true;
}
return false;
}

public function processComputeItems($memberUserId, $usingVoucherItemDataList, $data = [], $param = [])
{
$data['usedVoucherItems'] = $usingVoucherItemDataList;
// 折扣券
foreach ($this->filterVoucherItems($usingVoucherItemDataList, VoucherType::DISCOUNT) as $item) {
$discount = $item['_voucher']['typeDiscount'];
$data['price'] = NumberUtil::discountDecimal($data['price'], $discount);
}
return $data;
}

}
5 changes: 5 additions & 0 deletions module/Member/Core/ModuleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use Module\Vendor\Job\MailSendJob;
use Module\Vendor\Provider\Schedule\ScheduleBiz;
use Module\Vendor\Provider\SmsTemplate\SmsTemplateProvider;
use Module\Voucher\Biz\VoucherBiz;

class ModuleServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -197,6 +198,10 @@ public function boot(Dispatcher $events)
PayCenterBiz::register(MemberVipPayCenterBiz::class);
}

if (modstart_module_enabled('Voucher')) {
VoucherBiz::register(MemberVipVoucherBiz::class);
}

if (ModuleManager::getModuleConfig('Member', 'dataStatisticEnable', false)) {
MemberAdminShowPanelProvider::register(MemberDataStatisticAdminShowPanelProvider::class);
if (class_exists(DataUploadingEvent::class)) {
Expand Down
9 changes: 8 additions & 1 deletion module/Member/Docs/release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## 4.4.0
## 4.5.0

- 新增:VIP 优惠券功能集成,支持折扣券
- 优化:VIP 开通页面交互形式优化

---

## 4.4.0 授权绑定优化,已知问题修复

- 新增:用户上传数据表模型表
- 优化:手机快速注册登录密码设置控件不是password修复
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class ModifyMemberVipOrderParam extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('member_vip_order', function (Blueprint $table) {
$table->string('param', 100)->nullable()->comment('参数');
});

}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{

}
}
12 changes: 12 additions & 0 deletions module/Member/Model/MemberVipOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php


namespace Module\Member\Model;


use Illuminate\Database\Eloquent\Model;

class MemberVipOrder extends Model
{
protected $table = 'member_vip_order';
}
Loading

0 comments on commit 2e9780f

Please sign in to comment.