积分优化
parent
61b32d6f8e
commit
95bb9c7822
|
|
@ -79,7 +79,7 @@ class AfterSaleController extends AdminController
|
||||||
}
|
}
|
||||||
return bcdiv($value, 100, 2);
|
return bcdiv($value, 100, 2);
|
||||||
})->prepend('¥');
|
})->prepend('¥');
|
||||||
$grid->column('points');
|
$grid->column('points')->display(fn ($value) => bcdiv($value, 100, 2));
|
||||||
$grid->column('type')->using([
|
$grid->column('type')->using([
|
||||||
AfterSaleModel::TYPE_REFUND_AND_RETURN => '退款退货',
|
AfterSaleModel::TYPE_REFUND_AND_RETURN => '退款退货',
|
||||||
AfterSaleModel::TYPE_REFUND => '退款',
|
AfterSaleModel::TYPE_REFUND => '退款',
|
||||||
|
|
@ -159,7 +159,7 @@ class AfterSaleController extends AdminController
|
||||||
$show->field('amount', '售后金额')->as(function ($amount) {
|
$show->field('amount', '售后金额')->as(function ($amount) {
|
||||||
return '¥'.bcdiv($amount, 100, 2);
|
return '¥'.bcdiv($amount, 100, 2);
|
||||||
});
|
});
|
||||||
$show->field('points', '售后积分');
|
$show->field('points', '售后积分')->as(fn ($amount) => bcdiv($amount, 100, 2));
|
||||||
}
|
}
|
||||||
$show->width(6)->field('user.user_info.nickname', '下单用户');
|
$show->width(6)->field('user.user_info.nickname', '下单用户');
|
||||||
$show->field('user.phone');
|
$show->field('user.phone');
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ class OrderController extends AdminController
|
||||||
'商品名称',
|
'商品名称',
|
||||||
'数量',
|
'数量',
|
||||||
'价格',
|
'价格',
|
||||||
|
'积分',
|
||||||
'金额',
|
'金额',
|
||||||
'待发货数量',
|
'待发货数量',
|
||||||
'所属订单',
|
'所属订单',
|
||||||
|
|
@ -92,6 +93,7 @@ class OrderController extends AdminController
|
||||||
$product->name,
|
$product->name,
|
||||||
$product->quantity,
|
$product->quantity,
|
||||||
bcdiv($product->sell_price, '100', 2),
|
bcdiv($product->sell_price, '100', 2),
|
||||||
|
bcdiv($product->point_discount_amount, '100', 2),
|
||||||
bcdiv($product->total_amount, '100', 2),
|
bcdiv($product->total_amount, '100', 2),
|
||||||
$product->remain_quantity,
|
$product->remain_quantity,
|
||||||
$order->sn,
|
$order->sn,
|
||||||
|
|
@ -148,6 +150,9 @@ class OrderController extends AdminController
|
||||||
<span class="label bg-success">{$phone}</span>
|
<span class="label bg-success">{$phone}</span>
|
||||||
HTML;
|
HTML;
|
||||||
});
|
});
|
||||||
|
$grid->column('point_discount_amount')->display(function ($value) {
|
||||||
|
return bcdiv($value, 100, 2);
|
||||||
|
})->prepend('¥');
|
||||||
$grid->column('total_amount')->display(function ($value) {
|
$grid->column('total_amount')->display(function ($value) {
|
||||||
return bcdiv($value, 100, 2);
|
return bcdiv($value, 100, 2);
|
||||||
})->prepend('¥');
|
})->prepend('¥');
|
||||||
|
|
@ -207,6 +212,13 @@ class OrderController extends AdminController
|
||||||
PayWay::WxpayMiniProgram->value => PayWay::WxpayMiniProgram->text(),
|
PayWay::WxpayMiniProgram->value => PayWay::WxpayMiniProgram->text(),
|
||||||
PayWay::Offline->value => PayWay::Offline->text(),
|
PayWay::Offline->value => PayWay::Offline->text(),
|
||||||
])->width(3);
|
])->width(3);
|
||||||
|
$filter->where('order_type', function ($builder) {
|
||||||
|
if ($this->input == 1) {
|
||||||
|
$builder->where('point_discount_amount', '>', 0);
|
||||||
|
} else {
|
||||||
|
$builder->where('point_discount_amount', 0);
|
||||||
|
}
|
||||||
|
}, '订单类型')->select([1 => '积分订单', 2 => '其他订单'])->width(3);
|
||||||
$filter->where('order_status', function ($q) {
|
$filter->where('order_status', function ($q) {
|
||||||
switch ($this->input) {
|
switch ($this->input) {
|
||||||
case OrderStatus::PENDING:
|
case OrderStatus::PENDING:
|
||||||
|
|
@ -274,12 +286,14 @@ class OrderController extends AdminController
|
||||||
$market_price = number_format($query->sum('market_price') / 100, 2);
|
$market_price = number_format($query->sum('market_price') / 100, 2);
|
||||||
$cost_price = number_format($query->sum('cost_price') / 100, 2);
|
$cost_price = number_format($query->sum('cost_price') / 100, 2);
|
||||||
$sales_value = number_format($query->sum('sales_value'));
|
$sales_value = number_format($query->sum('sales_value'));
|
||||||
|
$point_discount_amount = bcdiv($query->sum('point_discount_amount'), 100, 2);
|
||||||
return <<<HTML
|
return <<<HTML
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>统计</td>
|
<td>统计</td>
|
||||||
<td>订单数: $count</td>
|
<td>订单数: $count</td>
|
||||||
|
<td>积分: $point_discount_amount</td>
|
||||||
<td>订单总额: $total_amount</td>
|
<td>订单总额: $total_amount</td>
|
||||||
<td>市场价: $market_price</td>
|
<td>市场价: $market_price</td>
|
||||||
<td>成本价: $cost_price</td>
|
<td>成本价: $cost_price</td>
|
||||||
|
|
@ -425,7 +439,7 @@ class OrderController extends AdminController
|
||||||
$grid->column('coupon_discount_amount', '优惠券折扣')->display(function ($value) {
|
$grid->column('coupon_discount_amount', '优惠券折扣')->display(function ($value) {
|
||||||
return bcdiv($value, 100, 2);
|
return bcdiv($value, 100, 2);
|
||||||
})->prepend('¥');
|
})->prepend('¥');
|
||||||
$grid->column('point_discount_amount', '积分抵扣')->display(function ($value) {
|
$grid->column('point_discount_amount', '积分')->display(function ($value) {
|
||||||
return bcdiv($value, 100, 2);
|
return bcdiv($value, 100, 2);
|
||||||
})->prepend('¥');
|
})->prepend('¥');
|
||||||
$grid->column('reduced_amount', '减免金额')->display(function ($value) {
|
$grid->column('reduced_amount', '减免金额')->display(function ($value) {
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,15 @@ class PointLogController extends AdminController
|
||||||
$grid->column('id')->sortable();
|
$grid->column('id')->sortable();
|
||||||
$grid->column('user.phone')->copyable();
|
$grid->column('user.phone')->copyable();
|
||||||
$grid->column('action')->display(fn ($action) => $action->label())->label();;
|
$grid->column('action')->display(fn ($action) => $action->label())->label();;
|
||||||
$grid->column('change_points');
|
$grid->column('change_points')->display(function ($value) {
|
||||||
$grid->column('before_points');
|
return bcdiv($value, 100, 2);
|
||||||
$grid->column('after_points');
|
});
|
||||||
|
$grid->column('before_points')->display(function ($value) {
|
||||||
|
return bcdiv($value, 100, 2);
|
||||||
|
});
|
||||||
|
$grid->column('after_points')->display(function ($value) {
|
||||||
|
return bcdiv($value, 100, 2);
|
||||||
|
});
|
||||||
$grid->column('remark');
|
$grid->column('remark');
|
||||||
$grid->column('created_at');
|
$grid->column('created_at');
|
||||||
|
|
||||||
|
|
@ -59,7 +65,7 @@ class PointLogController extends AdminController
|
||||||
|
|
||||||
$totalPoints = (clone $query)->sum('change_points');
|
$totalPoints = (clone $query)->sum('change_points');
|
||||||
|
|
||||||
$row->column(2, new InfoBox('积分总数', $totalPoints, 'fa fa-ticket'));
|
$row->column(2, new InfoBox('积分总数', bcdiv($totalPoints, 100, 2), 'fa fa-ticket'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class UserController extends AdminController
|
||||||
$grid->column('userInfo.inviterInfo.user.phone')->display(function ($v) {
|
$grid->column('userInfo.inviterInfo.user.phone')->display(function ($v) {
|
||||||
return $v ?: $this->userInfo?->inviter_id;
|
return $v ?: $this->userInfo?->inviter_id;
|
||||||
})->copyable();
|
})->copyable();
|
||||||
$grid->column('userInfo.points')->sortable()->if(function () {
|
$grid->column('userInfo.points')->display(fn ($value) => bcdiv($value, 100, 2))->sortable()->if(function () {
|
||||||
return Admin::user()->can('dcat.admin.point_logs.index');
|
return Admin::user()->can('dcat.admin.point_logs.index');
|
||||||
})->then(function (Grid\Column $column) {
|
})->then(function (Grid\Column $column) {
|
||||||
$column->link(function ($value) {
|
$column->link(function ($value) {
|
||||||
|
|
@ -157,7 +157,7 @@ class UserController extends AdminController
|
||||||
// $show->field('userInfo.nickname');
|
// $show->field('userInfo.nickname');
|
||||||
// $show->field('userInfo.gender')->using(UserInfo::$genderTexts)->label();
|
// $show->field('userInfo.gender')->using(UserInfo::$genderTexts)->label();
|
||||||
// $show->field('userInfo.birthday');
|
// $show->field('userInfo.birthday');
|
||||||
|
$show->field('user_info.points', '积分')->as(fn ($value) => bcdiv($value, 100, 2))->prepend('¥');
|
||||||
$show->field('user_info.growth_value', '成长值');
|
$show->field('user_info.growth_value', '成长值');
|
||||||
$show->field('profit');
|
$show->field('profit');
|
||||||
$show->field('user_info.is_company', '员工')->as(function ($v) {
|
$show->field('user_info.is_company', '员工')->as(function ($v) {
|
||||||
|
|
@ -173,7 +173,6 @@ class UserController extends AdminController
|
||||||
// $value = bcdiv($value, 100, 2);
|
// $value = bcdiv($value, 100, 2);
|
||||||
// return $value;
|
// return $value;
|
||||||
// })->prepend('¥');
|
// })->prepend('¥');
|
||||||
// $show->field('user_info.points');
|
|
||||||
});
|
});
|
||||||
$show->row(function (Show\Row $show) {
|
$show->row(function (Show\Row $show) {
|
||||||
$show->width(6)->field('last_login_ip');
|
$show->width(6)->field('last_login_ip');
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,11 @@ class AfterSaleVerify extends Form implements LazyRenderable
|
||||||
})->saving(function ($amount) {
|
})->saving(function ($amount) {
|
||||||
return bcmul($amount, 100);
|
return bcmul($amount, 100);
|
||||||
})->symbol('¥');
|
})->symbol('¥');
|
||||||
$this->number('points')->default($afterSale->points);
|
$this->currency('points')->customFormat(function () use ($afterSale) {
|
||||||
|
return bcdiv($afterSale->points, 100, 2);
|
||||||
|
})->saving(function ($points) {
|
||||||
|
return bcmul($points, 100);
|
||||||
|
})->symbol('¥');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->radio('state')
|
$this->radio('state')
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class PointChange extends Form implements LazyRenderable
|
||||||
{
|
{
|
||||||
$changePoints = (int) $input['change_points'];
|
$changePoints = (int) $input['change_points'];
|
||||||
|
|
||||||
if ($changePoints < 1) {
|
if ($changePoints < 0) {
|
||||||
return $this->response()->error('积分必须大于1');
|
return $this->response()->error('积分必须大于1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +68,9 @@ class PointChange extends Form implements LazyRenderable
|
||||||
])
|
])
|
||||||
->default(PointLogAction::Recharge->value)
|
->default(PointLogAction::Recharge->value)
|
||||||
->required();
|
->required();
|
||||||
$this->number('change_points', '积分')->min(1)->required();
|
$this->currency('change_points', '积分')->symbol('¥')->saving(function ($value) {
|
||||||
|
return bcmul($value, 100);
|
||||||
|
})->required();
|
||||||
$this->textarea('remark', '备注')->required();
|
$this->textarea('remark', '备注')->required();
|
||||||
$this->confirm('是否确认变更?', '提交后该动作无法逆转');
|
$this->confirm('是否确认变更?', '提交后该动作无法逆转');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class PointLogResource extends JsonResource
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'action' => $this->action,
|
'action' => $this->action,
|
||||||
'change_points' => $this->change_points,
|
'change_points' => bcdiv($this->change_points, 100, 2),
|
||||||
'remark' => (string) $this->remark,
|
'remark' => (string) $this->remark,
|
||||||
'created_at' => $this->created_at->toDateTimeString(),
|
'created_at' => $this->created_at->toDateTimeString(),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class UserInfoResource extends JsonResource
|
||||||
'birthday' => (string) $this->birthday?->toDateString(),
|
'birthday' => (string) $this->birthday?->toDateString(),
|
||||||
'code' => (string) $this->code,
|
'code' => (string) $this->code,
|
||||||
'is_company' => (boolean) $this->is_company,
|
'is_company' => (boolean) $this->is_company,
|
||||||
'points' => $this->points,
|
'points' => bcdiv($this->points, 100, 2),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum PayWay: string {
|
enum PayWay: string {
|
||||||
|
case None = 'none';
|
||||||
case Offline = 'offline';
|
case Offline = 'offline';
|
||||||
case Balance = 'balance';
|
case Balance = 'balance';
|
||||||
case Wallet = 'wallet';
|
case Wallet = 'wallet';
|
||||||
|
|
@ -31,6 +32,7 @@ enum PayWay: string {
|
||||||
public function label()
|
public function label()
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
static::None => 'none',
|
||||||
static::Offline => 'offline',
|
static::Offline => 'offline',
|
||||||
static::Balance => 'balance',
|
static::Balance => 'balance',
|
||||||
static::Wallet => 'wallet',
|
static::Wallet => 'wallet',
|
||||||
|
|
@ -42,6 +44,7 @@ enum PayWay: string {
|
||||||
public function mallText()
|
public function mallText()
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
static::None => '无',
|
||||||
static::Offline => '线下',
|
static::Offline => '线下',
|
||||||
static::Balance => '余额',
|
static::Balance => '余额',
|
||||||
static::Wallet => '可提',
|
static::Wallet => '可提',
|
||||||
|
|
@ -59,6 +62,7 @@ enum PayWay: string {
|
||||||
public function text(): string
|
public function text(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
static::None => '无',
|
||||||
static::Offline => '线下',
|
static::Offline => '线下',
|
||||||
static::Balance => '余额',
|
static::Balance => '余额',
|
||||||
static::Wallet => '钱包',
|
static::Wallet => '钱包',
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ class OrderService
|
||||||
$coupon?->markAsUse();
|
$coupon?->markAsUse();
|
||||||
|
|
||||||
if ($order->total_amount === 0) {
|
if ($order->total_amount === 0) {
|
||||||
$this->pay($order, PayWay::Balance);
|
$this->pay($order, PayWay::None);
|
||||||
|
|
||||||
$order->refresh();
|
$order->refresh();
|
||||||
}
|
}
|
||||||
|
|
@ -855,8 +855,8 @@ class OrderService
|
||||||
'coupon_discount_amount' => trim_trailing_zeros(bcdiv($couponDiscountAmount, 100, 2)), // 优惠券折扣金额
|
'coupon_discount_amount' => trim_trailing_zeros(bcdiv($couponDiscountAmount, 100, 2)), // 优惠券折扣金额
|
||||||
'total_amount' => trim_trailing_zeros(bcdiv($totalAmount, 100, 2)), // 实付金额
|
'total_amount' => trim_trailing_zeros(bcdiv($totalAmount, 100, 2)), // 实付金额
|
||||||
'bargain_amount' => trim_trailing_zeros(bcdiv($bargainAmount, 100, 2)), //砍价金额
|
'bargain_amount' => trim_trailing_zeros(bcdiv($bargainAmount, 100, 2)), //砍价金额
|
||||||
'remaining_points' => $remainingPoints, // 剩余积分
|
'remaining_points' => trim_trailing_zeros(bcdiv($remainingPoints, 100, 2)), // 剩余积分
|
||||||
'available_points' => $availablePoints, // 可用积分
|
'available_points' => trim_trailing_zeros(bcdiv($availablePoints, 100, 2)), // 可用积分
|
||||||
'point_discount_amount' => trim_trailing_zeros(bcdiv($availablePoints, 100, 2)), // 积分抵扣金额
|
'point_discount_amount' => trim_trailing_zeros(bcdiv($availablePoints, 100, 2)), // 积分抵扣金额
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ return [
|
||||||
'market_price' => '市场价',
|
'market_price' => '市场价',
|
||||||
'cost_price' => '成本价',
|
'cost_price' => '成本价',
|
||||||
'out_trade_no' => '支付流水号',
|
'out_trade_no' => '支付流水号',
|
||||||
'point_discount_amount' => '积分抵扣',
|
'point_discount_amount' => '积分',
|
||||||
],
|
],
|
||||||
'options' => [
|
'options' => [
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue