Commit 037df136 by lizhilin

更新

parent 572c84a0
<?php
namespace App\Store\Forms;
use App\Command\Log;
use App\Models\StoreIncome;
use App\Models\StoreInfo;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Illuminate\Support\Facades\DB;
class IncomeApply extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$store = StoreInfo::where(['store_id'=>Admin::user()->id]);
if($store->balance < $input['amount']){
return $this->response()->error('当前余额不足,提现申请失败')->refresh();
}
DB::beginTransaction();
try {
$model = new StoreIncome();
$model->store_id = Admin::user()->id;
$model->amount = $input['amount'];
$model->invoice = $input['invoice'] ??'';
$model->save();
$store->balance -= $input['amount'];
$store->freeze_balance += $input['amount'];
$store->save();
DB::commit();
Log::add('商城商户提现申请',$model->toArray());
}catch (\Exception $exception){
DB::rollBack();
Log::add('商城商户提现申请失败',$exception);
return $this->response()->error('提现申请失败')->refresh();
}
return $this->response()->success('提现申请成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->currency('amount','金额')->symbol('¥')->required();
$this->multipleImage('invoice','发票信息')
->accept('jpg,jpeg,png')
->maxSize(2048)
->limit(9)
->url('upload/store-invoice')
->help('仅支持jpg、jpeg、png格式图片上传')
->autoUpload()
->saveAsJson();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Store\Forms;
use App\Command\Log;
use App\Models\Pay;
use App\Models\PaymentRecord;
use App\Models\StoreGood;
use App\Models\StoreInfo;
use App\Models\StoreOrder;
use App\Models\UserRefund;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Illuminate\Support\Facades\DB;
class RefundToExamine extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$model = StoreOrder::find($this->payload['id']);
DB::beginTransaction();
try {
$userRefund = UserRefund::where([
'order_id'=>$model->order->id,
'son_order_id'=>$model->id
])->first();
if($input['refund_status']){
if($model->order->status == 2){
$store = StoreInfo::find($model->store_id);
$store->total_revenue -= $model->order->pay_money;
$store->balance -= $model->order->pay_money;
$store->save();
}
$wxOrderSn = PaymentRecord::where(['order_id'=>$model->order_id])->first()->other_order;
$r_sn = Pay::refund($wxOrderSn,$model->order->pay_money,$model->order->refund_amount);
$userRefund->refund_no = $r_sn;
$userRefund->status = 1;
$userRefund->save();
$model->status = 4;
$model->save();
$model->order->status = 8;
$model->order->save();
$goods = StoreGood::find($model->goods_id);
$goods->sale_num -= $model->num;
$goods->inventory += $model->num;
$goods->save();
Log::add('审批同意退款完成',$model->toArray());
DB::commit();
}else{
$userRefund->status = 2;
$userRefund->save();
$model->status = $userRefund->son_order_status;
$model->save();
}
DB::commit();
Log::add('退款审批',$model->toArray());
}catch (\Exception $exception){
DB::rollBack();
Log::add('退款审批失败',$exception);
return $this->response()->error('退款审批失败')->refresh();
}
return $this->response()->success('退款审批成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->radio('refund_status','退款审批')->options([true=>'同意退款',false=>'拒绝退款'])->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Store\Forms;
use App\Jobs\AutoCompleteOrder;
use App\Models\StoreOrder;
use App\Models\TotalOrder;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
class SendOutGoods extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$model = StoreOrder::find($this->payload['id']);
if($input['logistics']=='' || $input['logistics_code']=='' ){
return $this->response()->error('确认发货失败')->refresh();
}
$model->logistics = $input['logistics'] ??'';
$model->logistics_code = $input['logistics_code'] ??'';
$model->status = 1;
if (!$model->save()) {
return $this->response()->error('确认发货失败')->refresh();
}
$order = TotalOrder::find($model->order_id);
//开启自动完成订单
dispatch(new AutoCompleteOrder($order,(7*24*3600)));
return $this->response()->success('确认发货成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->text('logistics','物流名称')->required();
$this->text('logistics_code','物流单号')->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment