后台订单详细-添加用户vip购买记录;添加本次积分余额
parent
4f547b475a
commit
1ecef40100
|
|
@ -17,13 +17,16 @@ use App\Admin\Renderable\Grid\Filter\OrderStatusIn;
|
|||
use App\Admin\Renderable\PackageProductSimpleTable;
|
||||
use App\Constants\OrderStatus;
|
||||
use App\Enums\PayWay;
|
||||
use App\Enums\PointLogAction;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderActivity;
|
||||
use App\Models\OrderLog;
|
||||
use App\Models\OrderPackage;
|
||||
use App\Models\OrderProduct;
|
||||
use App\Models\OrderProfit;
|
||||
use App\Models\PointLog;
|
||||
use App\Models\Tag;
|
||||
use App\Models\UserVip;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
|
|
@ -404,7 +407,20 @@ class OrderController extends AdminController
|
|||
return bcdiv($this->point_discount_amount + $this->total_amount, 100, 2);
|
||||
})->prepend('- ¥');
|
||||
$show->field('point_discount_amount')->as(function ($v) {
|
||||
return bcdiv($v, 100, 2);
|
||||
$result = bcdiv($v, 100, 2);
|
||||
// 使用积分抵扣
|
||||
if ($v > 0) {
|
||||
// 当前订单使用积分抵扣, 对应的积分流水记录
|
||||
$pointLog = PointLog::query()
|
||||
->where('loggable_type', (new Order())->getMorphClass())
|
||||
->where('loggable_id', $this->id)
|
||||
->where('action', PointLogAction::Consumption)
|
||||
->first();
|
||||
if ($pointLog) {
|
||||
$result .= '(本次余额: ' . bcdiv($pointLog->after_points, 100, 0) . ')';
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
})->prepend('- ¥');
|
||||
$show->field('total_amount')->as(function ($v) {
|
||||
return bcdiv($v, 100, 2);
|
||||
|
|
@ -599,6 +615,23 @@ class OrderController extends AdminController
|
|||
$grid->disableRefreshButton();
|
||||
}));
|
||||
$column->row($profitBox->collapsable());
|
||||
|
||||
// 会员购买记录
|
||||
$userId = Order::where('id', $id)->value('user_id');
|
||||
$userVipBuilder = UserVip::where('user_id', $userId)->orderBy('success_time', 'desc');
|
||||
$userVipBox = Box::make('会员购买记录', Grid::make($userVipBuilder, function (Grid $grid) {
|
||||
$grid->column('name', '会员卡');
|
||||
$grid->column('times', '时效')->display(function ($v) {
|
||||
return data_get($v, 'text');
|
||||
});
|
||||
$grid->column('success_time', '办理时间');
|
||||
$grid->column('expired', '有效时间');
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->disablePagination();
|
||||
$grid->disableRefreshButton();
|
||||
}));
|
||||
$column->row($userVipBox->collapsable());
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class UserVipController extends AdminController
|
|||
|
||||
$show->field('pay.pay_sn', '订单号');
|
||||
$show->field('pay.pay_way', '支付方式')->as(function ($value) {
|
||||
return $this->pay->pay_way->text();
|
||||
return $this->pay?->pay_way->text();
|
||||
});
|
||||
|
||||
$show->panel()->tools(function ($tools) {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ class VipService
|
|||
*/
|
||||
public function success(UserVip $userVip, array $params = null)
|
||||
{
|
||||
if ($userVip->status == UserVip::STATUS_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
$userVip->update([
|
||||
'status' => 1,
|
||||
'success_time' => data_get($params, 'pay_at', now())
|
||||
|
|
|
|||
Loading…
Reference in New Issue