release
parent
f7a2a9c29e
commit
1255c0fa5f
|
|
@ -77,7 +77,7 @@ class AgentController extends AdminController
|
|||
{
|
||||
return Form::make(new Agent(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->number('sort')->min(1)->required()->help('不可重复')->rules(function (Form $form) {
|
||||
$form->number('sort')->min(1)->required()->help('不可重复, 1级为最高')->rules(function (Form $form) {
|
||||
$rule = Rule::unique('vips');
|
||||
if ($id = $form->model()->id) {
|
||||
$rule->ignore($id);
|
||||
|
|
|
|||
|
|
@ -255,9 +255,9 @@ class OrderController extends AdminController
|
|||
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
|
||||
});
|
||||
$count = $query->count();
|
||||
$total_amount = number_format($query->sum('total_amount') / 100);
|
||||
$market_price = number_format($query->sum('market_price') / 100);
|
||||
$cost_price = number_format($query->sum('cost_price') / 100);
|
||||
$total_amount = number_format($query->sum('total_amount') / 100, 2);
|
||||
$market_price = number_format($query->sum('market_price') / 100, 2);
|
||||
$cost_price = number_format($query->sum('cost_price') / 100, 2);
|
||||
$sales_value = number_format($query->sum('sales_value'));
|
||||
return <<<HTML
|
||||
<table class="table table-bordered">
|
||||
|
|
@ -293,6 +293,8 @@ class OrderController extends AdminController
|
|||
$column->row(Show::make($id, $builder, function (Show $show) {
|
||||
// $show->field('id');
|
||||
$show->row(function (Show\Row $show) {
|
||||
$show->width(6)->field('user.phone');
|
||||
$show->field('store.title', '店铺');
|
||||
$show->width(6)->field('sn');
|
||||
$show->field('order_status')->as(function ($v) {
|
||||
return $this->order_status;
|
||||
|
|
@ -357,8 +359,7 @@ class OrderController extends AdminController
|
|||
$show->width(6)->field('sales_value');
|
||||
$show->field('completed_at', '完成时间');
|
||||
$show->field('note');
|
||||
$show->field('store.title', '店铺');
|
||||
$show->width(12)->field('remark')->width(10, 1);
|
||||
$show->field('remark');
|
||||
});
|
||||
|
||||
$show->panel()
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ class OrderProfitController extends AdminController
|
|||
$form->text('ratio');
|
||||
$form->text('money');
|
||||
$form->text('status');
|
||||
$show->field('pay_way');
|
||||
$show->field('pay_no');
|
||||
$show->field('paid_at');
|
||||
$form->field('pay_way');
|
||||
$form->field('pay_no');
|
||||
$form->field('paid_at');
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ class OrderDistribute extends Command
|
|||
$count = 0;
|
||||
foreach($orders as $order) {
|
||||
$profit = $service->storeByOrder($order);
|
||||
$count++;
|
||||
if ($profit) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$this->info('符合要求: ' . $count);
|
||||
DB::commit();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class OrderPackage
|
|||
public function handle(OrderPaid $event)
|
||||
{
|
||||
$order = Order::find($event->order->id);
|
||||
|
||||
|
||||
// 订单来源为 帮客户下单 order_pres
|
||||
$source = $order->source;
|
||||
if ($source instanceof OrderPre) {
|
||||
|
|
@ -55,28 +55,30 @@ class OrderPackage
|
|||
$product = $store->productSkus()->findOrFail($sku_id);
|
||||
|
||||
// 订单商品, 需要发货, 店铺库存足够
|
||||
if ($order_product && $send > 0 && $product->pivot->amount > $send) {
|
||||
if ($order_product && $send > 0) {
|
||||
array_push($package_params, [
|
||||
'order_product_id' => $order_product->id,
|
||||
'quantity' => $send
|
||||
]);
|
||||
|
||||
if ($product->pivot->amount - $send < 0) {
|
||||
$balance = $product->pivot->amount - $send;
|
||||
if ($balance < 0) {
|
||||
throw new BizException('店铺的 ' . $product->name .' 库存不足');
|
||||
}
|
||||
// 更新店铺商品库存
|
||||
$store->productSkus()->updateExistingPivot($product->id, [
|
||||
'amount' => $product->pivot->amount - $send
|
||||
'amount' => $balance
|
||||
]);
|
||||
// 添加发货记录
|
||||
// 添加店铺发货记录
|
||||
$store->stockLogs()->create([
|
||||
'operator_type' => $inviter ? get_class($inviter) : '',
|
||||
'operator_id' => $inviter ? $inviter->id : '',
|
||||
'source_type' => Order::class,
|
||||
'source_id' => $order->id,
|
||||
'amount' => 0-$send,
|
||||
'balance' => $balance,
|
||||
'product_sku_id' => $product->id,
|
||||
'remarks' => '店铺提货',
|
||||
'remarks' => '店铺提货(自动)',
|
||||
'tag_id' => $tag->id
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class DistributeService
|
|||
// 订单成长值
|
||||
$sales_value = $order->sales_value;
|
||||
$user = $order->user;
|
||||
$user_agent = $user->agent;
|
||||
// 已经添加过返现记录
|
||||
if ($user->salesValueLogs()->where('order_id', $order->id)->exists()) {
|
||||
return false;
|
||||
|
|
@ -52,20 +53,26 @@ class DistributeService
|
|||
$user->update([
|
||||
'agent_id' => $level_up->id,
|
||||
]);
|
||||
$user_agent = $level_up;
|
||||
}
|
||||
|
||||
// 上级返利
|
||||
$parent_ids = array_reverse($user->userInfo->parent_ids);
|
||||
$parents = User::with(['userInfo', 'agent'])->whereIn('id', $parent_ids)->get();
|
||||
// 过滤掉不是代理身份的用户
|
||||
// 过滤掉当前等级 大于 下一级的等级的用户
|
||||
$filtered = $parents->filter(function ($item, $key) use ($parents) {
|
||||
// 过滤掉 不是代理身份 的用户
|
||||
// 过滤掉 相同等级 的 后者 用户
|
||||
// 过滤掉等级 低于 下单用户等级 的用户(sort = 1 为最高)
|
||||
$exists_list = [];
|
||||
$filtered = $parents->filter(function ($item) use ($user_agent, &$exists_list) {
|
||||
if (!$item->agent) {
|
||||
return false;
|
||||
}
|
||||
$next = $parents->get($key + 1);
|
||||
if ($next && $next->agent) {
|
||||
return $item->agent->sort < $next->agent->sort;
|
||||
if (in_array($item->agent->sort, $exists_list)) {
|
||||
return false;
|
||||
}
|
||||
array_push($exists_list, $item->agent->sort);
|
||||
if ($user_agent) {
|
||||
return $user_agent->sort > $item->agent->sort;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
@ -108,7 +115,6 @@ class DistributeService
|
|||
{
|
||||
// 订单已取消, 换货后生成的新订单
|
||||
if ($order->isCancelled() || $order->is_change) {
|
||||
logger(0);
|
||||
return false;
|
||||
}
|
||||
// 订单确认收货
|
||||
|
|
@ -120,7 +126,7 @@ class DistributeService
|
|||
return false;
|
||||
}
|
||||
// 订单超过售后期限
|
||||
$value = app_settings('sale_after_expire_days');
|
||||
$value = app_settings('app.sale_after_expire_days');
|
||||
if ($value && $order->completed_at) {
|
||||
$diff_day = $order->completed_at->diffInDays();
|
||||
return $diff_day > $value;
|
||||
|
|
|
|||
|
|
@ -367,6 +367,10 @@ class AdminPermissionSeeder extends Seeder
|
|||
'curd' => ['index', 'create', 'store', 'edit', 'update', 'destroy'],
|
||||
'children' =>[],
|
||||
],
|
||||
'sales_value_logs' => [
|
||||
'name' => '成长值记录',
|
||||
'curd' => ['index']
|
||||
]
|
||||
];
|
||||
// try {
|
||||
// DB::begintransaction();
|
||||
|
|
|
|||
Loading…
Reference in New Issue