vip
parent
94c3d3f251
commit
e0a48ac08d
|
|
@ -19,7 +19,7 @@ class DeskController extends AdminController
|
|||
$grid->column('id');
|
||||
$grid->column('store_id')->display(fn() => data_get($this->store, 'title'));
|
||||
$grid->column('name');
|
||||
// $grid->column('status')->switch();
|
||||
$grid->column('status')->switch();
|
||||
$grid->column('wxcode')->image('', 100, 100);
|
||||
$grid->column('remarks')->editable();
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ class DeskController extends AdminController
|
|||
return Form::make(new Desk(), function (Form $form) {
|
||||
$form->select('store_id')->options(Store::pluck('title', 'id'))->required();
|
||||
$form->text('name')->required();
|
||||
// $form->switch('status')->default(1);
|
||||
$form->switch('status')->default(1);
|
||||
$form->text('remarks');
|
||||
|
||||
$form->embeds('extra', function (Form\EmbeddedForm $form) {
|
||||
|
|
@ -56,13 +56,6 @@ class DeskController extends AdminController
|
|||
$form->disableEditingCheck();
|
||||
$form->disableDeleteButton();
|
||||
$form->disableResetButton();
|
||||
|
||||
$form->saved(function (Form $form, $result) {
|
||||
// 新增桌号, 生成小程序码
|
||||
if ($form->isCreating()) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +65,7 @@ class DeskController extends AdminController
|
|||
$show->field('id');
|
||||
$show->field('store_id')->as(fn() => data_get($this->store, 'name'));
|
||||
$show->field('name');
|
||||
// $show->field('status')->bool();
|
||||
$show->field('status')->bool();
|
||||
$show->field('wxcode');
|
||||
$show->field('remarks');
|
||||
|
||||
|
|
|
|||
|
|
@ -53,27 +53,23 @@ class ProductController extends AdminController
|
|||
$grid->column('store.title', '店铺');
|
||||
$grid->column('productSku.category.name', '分类');
|
||||
$grid->column('productSku.name', '名称');
|
||||
$grid->column('productSku.sell_price', '销售价')->display(fn ($value) => bcdiv($value, 100, 2));
|
||||
$grid->column('productSku.specs', '规格')->label();
|
||||
$grid->column('productSku.cost_price', '成本价')->display(function ($value) {
|
||||
return bcdiv($value, 100, 2);
|
||||
});
|
||||
$grid->column('productSku.sell_price', '销售价')->display(function ($value) {
|
||||
return bcdiv($value, 100, 2);
|
||||
});
|
||||
$grid->column('amount', '库存');
|
||||
$grid->column('productSku.cost_price', '成本价')->display(fn ($value) => bcdiv($value, 100, 2));
|
||||
$grid->column('profit', '毛利')->display(function () {
|
||||
$sell_price = data_get($this->productSku, 'sell_price');
|
||||
$cost_price = data_get($this->productSku, 'cost_price');
|
||||
return round(($sell_price - $cost_price) / 100, 2, PHP_ROUND_HALF_DOWN);
|
||||
});
|
||||
$grid->column('cost', '总成本')->display(function () {
|
||||
$cost_price = data_get($this->productSku, 'cost_price');
|
||||
return round($cost_price / 100 * $this->amount, 2, PHP_ROUND_HALF_DOWN);
|
||||
});
|
||||
$grid->column('amount', '库存');
|
||||
$grid->column('sell', '总销售')->display(function () {
|
||||
$sell_price = data_get($this->productSku, 'sell_price');
|
||||
return round($sell_price / 100 * $this->amount, 2, PHP_ROUND_HALF_DOWN);
|
||||
});
|
||||
$grid->column('cost', '总成本')->display(function () {
|
||||
$cost_price = data_get($this->productSku, 'cost_price');
|
||||
return round($cost_price / 100 * $this->amount, 2, PHP_ROUND_HALF_DOWN);
|
||||
});
|
||||
$grid->column('status', '状态')->switch();
|
||||
$grid->paginate(10);
|
||||
|
||||
|
|
@ -117,11 +113,11 @@ class ProductController extends AdminController
|
|||
<tr>
|
||||
<td>统计</td>
|
||||
<td>总数: $count</td>
|
||||
<td>成本价: $cost_price</td>
|
||||
<td>销售价: $sell_price</td>
|
||||
<td>成本价: $cost_price</td>
|
||||
<td>库存: $stock</td>
|
||||
<td>总成本: $cost</td>
|
||||
<td>总销售: $sell</td>
|
||||
<td>总成本: $cost</td>
|
||||
<tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class StoreController extends AdminController
|
|||
$show->field('remarks');
|
||||
$show->field('created_at');
|
||||
|
||||
$show->field('order_desk_print_template')->as(fn() => data_get($this->extra, 'order_desk_print_template'));
|
||||
$show->field('order_desk_print_template')->as(fn() => data_get($info->extra, 'order_desk_print_template'));
|
||||
|
||||
$show->tools(function (Tools $tools) {
|
||||
$tools->append(new ExportGoodsSpu());
|
||||
|
|
|
|||
|
|
@ -53,8 +53,11 @@ class OrderService
|
|||
}
|
||||
|
||||
$newTotalAmount = $reduceOrderProduct->total_amount + $reduceOrderProduct->reduced_amount - $amount;
|
||||
if ($newTotalAmount < 0) {
|
||||
$newTotalAmount = 0;
|
||||
}
|
||||
|
||||
//更新订单商品的金额
|
||||
// 更新订单商品的金额
|
||||
$reduceOrderProduct->update([
|
||||
'reduced_amount' => $amount,
|
||||
'total_amount'=> $newTotalAmount,
|
||||
|
|
|
|||
|
|
@ -14,18 +14,20 @@ class ProductSkuFilter extends ModelFilter
|
|||
*/
|
||||
public function category($id)
|
||||
{
|
||||
$category = ProductCategory::showable()->find($id);
|
||||
|
||||
if ($category === null) {
|
||||
return $this->whereRaw('1=0');
|
||||
}
|
||||
|
||||
$ids = $category->descendants()->showable()->pluck('id');
|
||||
|
||||
if ($ids->isEmpty()) {
|
||||
$this->where('category_id', $id);
|
||||
} else {
|
||||
$this->whereIn('category_id', $ids);
|
||||
if ($id > 0) {
|
||||
$category = ProductCategory::showable()->find($id);
|
||||
|
||||
if ($category === null) {
|
||||
return $this->whereRaw('1=0');
|
||||
}
|
||||
|
||||
$ids = $category->descendants()->showable()->pluck('id');
|
||||
|
||||
if ($ids->isEmpty()) {
|
||||
$this->where('category_id', $id);
|
||||
} else {
|
||||
$this->whereIn('category_id', $ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class OrderProductResource extends JsonResource
|
|||
return [
|
||||
'id' => $this->id,
|
||||
'sku_id' => $this->sku_id,
|
||||
'spu_id' => $this->spu_id,
|
||||
'name' => $this->name,
|
||||
'cover' => $this->cover,
|
||||
'specs' => array_values((array) $this->specs),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ class Desk extends Model
|
|||
|
||||
protected $fillable = ['extra', 'name', 'remarks', 'status', 'store_id', 'wxcode'];
|
||||
|
||||
protected $attributes = [
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'extra' => 'json'
|
||||
];
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ class Store extends Model
|
|||
{
|
||||
use HasFactory, HasDateTimeFormatter;
|
||||
|
||||
protected $fillable = ['title', 'image'];
|
||||
protected $fillable = ['title', 'image', 'extra'];
|
||||
|
||||
protected $casts = [
|
||||
'extra' => 'json'
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'status' => 1,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ class VipService
|
|||
'pay_way' => $pay_way
|
||||
]);
|
||||
$money = $userVip->price;
|
||||
if ($money <= 0) {
|
||||
$this->success($userVip);
|
||||
return ['status' => 1];
|
||||
}
|
||||
|
||||
$debug = config('app.debug');
|
||||
if ($debug) {
|
||||
$money = 0.01;
|
||||
|
|
@ -63,7 +68,7 @@ class VipService
|
|||
'trade_type' => WxpayTradeType::JSAPI->value,
|
||||
'openid' => $openid,
|
||||
];
|
||||
return ['pay_way' => $pay_way, 'data' => (new WxpayService())->pay($params)];
|
||||
return ['pay_way' => $pay_way, 'data' => (new WxpayService())->pay($params), 'status' => 0];
|
||||
}
|
||||
throw new BizException('未知的支付方式');
|
||||
}
|
||||
|
|
@ -80,7 +85,12 @@ class VipService
|
|||
'success_time' => data_get($params, 'pay_at', now())
|
||||
]);
|
||||
$user = $userVip->user;
|
||||
$vip_expired = $this->convertTimes(data_get($userVip->times, 'num'), data_get($userVip->times, 'unit'), $user->vip_expired);
|
||||
$success_time = $userVip->success_time;
|
||||
$start = $user->vip_expired;
|
||||
if ($success_time->gt($start)) {
|
||||
$start = $success_time;
|
||||
}
|
||||
$vip_expired = $this->convertTimes(data_get($userVip->times, 'num'), data_get($userVip->times, 'unit'), $start);
|
||||
$userVip->update([
|
||||
'expired' => $vip_expired
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue