You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.3 KiB
PHP
97 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\H5;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\SanFangCodeService;
|
|
use App\Services\ZhongKangService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class SanFangController extends Controller
|
|
{
|
|
public function GetSanFangList(Request $request)
|
|
{
|
|
$list = DB::table('sanfang')->where(['status' => 1])->get();
|
|
return \Yz::Return(true, "查询完成", ['list' => $list]);
|
|
}
|
|
|
|
//查询三方码
|
|
public function GetSanFangCode(Request $request)
|
|
{
|
|
$code = request('code');
|
|
$person_id = request('person_id');
|
|
$qudao_type = request('qudao_type');//1H5转赠码2有赞3中康
|
|
if(!isset($person_id)) return \Yz::echoError1("person_id不能为空");
|
|
$person = DB::table('web_user_person')->where(['id' => $person_id, 'is_del' => 0])->first();
|
|
// if ($qudao_type == 1) {
|
|
//
|
|
// $code = DB::table('transfer_code')->where(['code' => $code, 'status' => 1, 'is_del' => 0])->first();
|
|
// if (!$code) return \Yz::echoError1("此转赠码不可用");
|
|
// $data = [
|
|
// 'code_num' => $code->code,
|
|
// 'status' => $code->status,
|
|
// 'price' => $code->price,
|
|
// 'combo_id' => $code->combo_id,
|
|
// 'qudao_type' => $qudao_type,
|
|
// ];
|
|
// return \Yz::Return(true, "查询成功", $data);
|
|
// }
|
|
// if ($qudao_type == 3) {
|
|
// $service = new ZhongKangService();
|
|
// $res= $service->GetHexiaoCode($code,$person->name,$person->id_number);
|
|
// if($res['status']==true && $res['data']['status']==1){
|
|
// $data = [
|
|
// 'code_num' => $res['data']['code_num'],
|
|
// 'status' => $res['data']['status'],
|
|
// 'price' => $res['data']['price'],
|
|
// 'combo_id' => $res['data']['combo_id'],
|
|
// 'qudao_type' => $qudao_type,
|
|
// ];
|
|
// return \Yz::Return(true, "查询成功", $data);
|
|
// }else{
|
|
// return \Yz::echoError1("此转赠码不可用(中康)");
|
|
// }
|
|
// }
|
|
$service = new SanFangCodeService();
|
|
$result = $service->GetSanFangCode($code, $person_id, $qudao_type);
|
|
if ($result['status'] == true) {
|
|
//查询库里的套餐是否可用
|
|
$combo = DB::table('combos')->where(['combo_id' => $result['data']['combo_id'], 'status' => 1])->first();
|
|
if (!$combo) {
|
|
return \Yz::echoError1("此套餐不可用");
|
|
}
|
|
$data = [
|
|
'code_num' => $result['data']['code_num'],
|
|
'status' => $result['data']['status'],
|
|
'price' => $result['data']['price'],
|
|
'combo_id' => $result['data']['combo_id'],
|
|
'qudao_type' => $qudao_type,
|
|
];
|
|
return \Yz::Return(true, "查询成功", $data);
|
|
}else{
|
|
return \Yz::echoError1($result['msg']);
|
|
}
|
|
}
|
|
|
|
//操作三方码(应该是无用)
|
|
public function HeXiaoSanFangCode(Request $request)
|
|
{
|
|
$qudao_type = request('qudao_type');//1H5转赠码2有赞
|
|
$code = request('code');
|
|
if ($qudao_type == 1) {
|
|
$u = false;
|
|
$data = [
|
|
'status' => 2,
|
|
'tj_num' => isset($tj_num) ? $tj_num : null,
|
|
];
|
|
$u = DB::table('transfer_code')->where(['code' => $code, 'status' => 1, 'is_del' => 0])->update($data);
|
|
if ($u) {
|
|
return \Yz::Return(true, "操作成功", ['code_num' => $code]);
|
|
} else {
|
|
return \Yz::echoError1("操作失败");
|
|
}
|
|
}
|
|
}
|
|
}
|