Skip to content

Commit

Permalink
修改 自动扣款逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
liufei-ereach committed Jul 4, 2024
1 parent cc9c77f commit 1222cb9
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion js/dist/admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/admin.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/forum.js

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

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions js/src/admin/components/StoreGoodsDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class StoreGoodsDetailModal extends Modal {
this.params.status = Stream(Number(val))
}}
> </Switch>
</span>
</span>
</div>
<div class="spacing" style="display: flex; align-items: center;">
<span>{app.translator.trans("mattoid-store.admin.settings.goods-code")}</span>
Expand Down Expand Up @@ -179,16 +179,16 @@ export default class StoreGoodsDetailModal extends Modal {

<div className="spacing" style={this.params.type() === 'limit' ? 'display:inline-block' : 'display: none'}>
<div style="width: 200px; display: inline-block;">
<Switch
state={this.params.autoDeduction()}
onchange={(val) => {
this.params.autoDeduction = Stream(Number(val))
}}
>
{app.translator.trans(
"mattoid-store.admin.settings.goods-auto-deduction"
)}
</Switch>
<span>{app.translator.trans("mattoid-store.admin.settings.goods-auto-deduction")}</span>
<span style="margin-left: 15px;">
<Switch
state={this.params.autoDeduction()}
onchange={(val) => {
this.params.autoDeduction = Stream(Number(val))
}}
>
</Switch>
</span>
</div>
</div>

Expand Down
4 changes: 1 addition & 3 deletions js/src/forum/components/StoreItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export default class StoreItem extends Component {
{app.translator.trans('mattoid-store.lib.item-stock')}: {this.storeData.stock == -99 ? app.translator.trans('mattoid-store.forum.infinite') : this.storeData.stock }&nbsp;|&nbsp;
{app.translator.trans('mattoid-store.lib.item-type-' + this.storeData.type)}&nbsp;
<span style={this.storeData.type === 'limit' ? 'display:inline-block' : 'display: none'}>({this.storeData.outtime}{app.translator.trans('mattoid-store.forum.days')})</span>
</div>
<div className="spacing" style={this.storeData.type === 'limit' && this.storeData.autoDeduction ? 'display:inline-block' : 'display: none'}>
{app.translator.trans('mattoid-store.lib.item-invalid', {'day' : this.storeData.outtime})}
<span style={this.storeData.type === 'limit' && this.storeData.autoDeduction ? 'display:inline-block' : 'display: none'}>&nbsp;|&nbsp;{app.translator.trans('mattoid-store.lib.item-invalid', {'day' : this.storeData.outtime})}</span>
</div>
<div className="spacing">
<div id="box">
Expand Down
2 changes: 1 addition & 1 deletion locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ mattoid-store:
item-limit-unit-hour: hour
item-limit-unit-minute: minute
item-limit-unit-second: second
item-invalid: Deduction of fees every {day} day
item-invalid: Automatic renewal
cancel: Cancel
confirm: Ok
2 changes: 1 addition & 1 deletion locale/zh-Hans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mattoid-store:
list-empty: 这里空空如也
list-load-more: 更多

item-invalid: 每{day}天扣费一次
item-invalid: 自动续费

cancel: 取消
confirm: 确定
14 changes: 11 additions & 3 deletions src/Console/Command/GoodsInvalidCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ protected function fire()
$store = $storeMap[$cart->store_id];
try {
// 自动扣费,扣费成功
if ($cart->auto_deduction) {
$this->autoDeduction($store, $cart);
}
$this->autoDeduction($store, $cart);
} catch (\Exception $e) {
$buyStatus = false;
$this->error("[{$cart->code}]-{$cart->id}-{$cart->store_id}: 自动扣费失败【{$e->getMessage()}");
Expand Down Expand Up @@ -86,6 +84,16 @@ protected function fire()

private function autoDeduction(StoreModel $store, StoreCartModel $cart)
{
// 商品未开启自动扣费
if ($cart->auto_deduction) {

}

// 商品下架不支持续费
if ($store->status != 1) {
throw new ValidationException(['message' => $this->translator->trans('mattoid-store.forum.error.invalid-product')]);
}

$key = md5("{$store->store_id}-{$cart->user_id}");
if (!$this->cache->add($key, time(), 5)) {
throw new ValidationException(['message' => $this->translator->trans('mattoid-store.forum.error.validate-fail')]);
Expand Down

0 comments on commit 1222cb9

Please sign in to comment.