main
parent
8d1f6190ae
commit
bacf277042
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API\H5;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Lib\Tools;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class TransferCodeController extends Controller
|
||||||
|
{
|
||||||
|
//生成转赠码
|
||||||
|
public function CreateTransferCode(){
|
||||||
|
$order_id = request('order_id');
|
||||||
|
$order=DB::table('orders')->where(['id'=>$order_id])->first();
|
||||||
|
if(!$order) return \Yz::echoError1("订单不存在");
|
||||||
|
if($order->status<>2) return \Yz::echoError1("订单状态不正确");
|
||||||
|
if(!empty($order->plan_id)) return \Yz::echoError1("该订单不可转赠");
|
||||||
|
if(!empty($order->transfer_type)) return \Yz::echoError1("该订单已经转赠,不可再转赠");
|
||||||
|
$order_code=DB::table('transfer_code')->where(['link_order_id'=>$order_id,'is_del'=>0])->first();
|
||||||
|
if(!!$order_code) return \Yz::echoError1("该订单已有转赠码,不可再转赠");
|
||||||
|
$code=Tools::RandomString(5).$order->id;
|
||||||
|
$c_code_id = DB::table('transfer_code')->insertGetId([
|
||||||
|
'code'=>$code,
|
||||||
|
'price'=>$order->true_price,
|
||||||
|
'combo_id'=>json_decode($order->buy_info,true)['combo']['id'],
|
||||||
|
'link_order_id'=>$order_id,
|
||||||
|
'status'=>1,
|
||||||
|
'is_del'=>0
|
||||||
|
]);
|
||||||
|
$u_order=DB::table('orders')->where(['id'=>$order_id])->update(['transfer_type'=>2,'transfer_link'=>$c_code_id,'status'=>6]);
|
||||||
|
if($u_order){
|
||||||
|
return \Yz::Return(true,"生成成功",['code'=>$code]);
|
||||||
|
}else{
|
||||||
|
return \Yz::echoError1("生成失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue