141 lines
7.0 KiB
PHP
141 lines
7.0 KiB
PHP
<?php
|
|
/**
|
|
* Index.php
|
|
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2015-2025 成都云之牛科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.cdcloudshop.com
|
|
* =========================================================
|
|
* @author : niuteam
|
|
* @date : 2022.8.8
|
|
* @version : v5.0.0.1
|
|
*/
|
|
namespace addon\futures\api\controller;
|
|
use app\api\controller\BaseApi;
|
|
use addon\futures\model\order\FuturesOrderCreate as OrderCreateModel;
|
|
/**
|
|
* 订单创建
|
|
* @author Administrator
|
|
*/
|
|
class Ordercreate extends BaseApi
|
|
{
|
|
/**
|
|
* 创建订单
|
|
*/
|
|
public function create()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token[ 'code' ] < 0) return $this->response($token);
|
|
$order_create = new OrderCreateModel();
|
|
$data = [
|
|
'futures_id' => $this->params[ 'futures_id' ] ?? 0,
|
|
'member_id' => $this->member_id,
|
|
'site_id' => $this->site_id,//站点id
|
|
'order_from' => $this->params[ 'app_type' ],
|
|
'order_from_name' => $this->params[ 'app_type_name' ],
|
|
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
|
'buyer_message' => $this->params[ 'buyer_message' ] ?? '',
|
|
'delivery' => isset($this->params[ 'delivery' ]) && !empty($this->params[ 'delivery' ]) ? json_decode($this->params[ 'delivery' ], true) : [],
|
|
'coupon' => isset($this->params[ 'coupon' ]) && !empty($this->params[ 'coupon' ]) ? json_decode($this->params[ 'coupon' ], true) : [],
|
|
'member_address' => isset($this->params[ 'member_address' ]) && !empty($this->params[ 'member_address' ]) ? json_decode($this->params[ 'member_address' ], true) : [],
|
|
|
|
'latitude' => $this->params[ 'latitude' ] ?? '',
|
|
'longitude' => $this->params[ 'longitude' ] ?? '',
|
|
'is_invoice' => $this->params[ 'is_invoice' ] ?? 0,
|
|
|
|
'pay_password' => $this->params[ 'payPassword' ] ?? '',
|
|
|
|
'invoice_type' => $this->params[ 'invoice_type' ] ?? 0,
|
|
'invoice_title' => $this->params[ 'invoice_title' ] ?? '',
|
|
'taxpayer_number' => $this->params[ 'taxpayer_number' ] ?? '',
|
|
'invoice_content' => $this->params[ 'invoice_content' ] ?? '',
|
|
'invoice_full_address' => $this->params[ 'invoice_full_address' ] ?? '',
|
|
'is_tax_invoice' => $this->params[ 'is_tax_invoice' ] ?? 0,
|
|
'invoice_email' => $this->params[ 'invoice_email' ] ?? '',
|
|
'invoice_title_type' => $this->params[ 'invoice_title_type' ] ?? 0,
|
|
'buyer_ask_delivery_time' => $this->params[ 'buyer_ask_delivery_time' ] ?? '',
|
|
'form_data' => isset($this->params['form_data']) && !empty($this->params['form_data']) ? json_decode($this->params['form_data'], true) : [],
|
|
'goods_sku_list' => !empty($this->params['goods_sku_list']) ? json_decode($this->params['goods_sku_list'], true) : [],
|
|
'sku_id' => isset($this->params['sku_id']) ? $this->params['sku_id'] : '',
|
|
];
|
|
if ($data[ 'futures_id' ] == 0) {
|
|
return $this->response($this->error('', '缺少必填参数商品数据'));
|
|
}
|
|
$res = $order_create->create($data);
|
|
return $this->response($res);
|
|
}
|
|
|
|
/**
|
|
* 计算信息
|
|
*/
|
|
public function calculate()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token[ 'code' ] < 0) return $this->response($token);
|
|
$order_create = new OrderCreateModel();
|
|
$data = [
|
|
'futures_id' => $this->params[ 'futures_id' ] ?? 0,
|
|
'member_id' => $this->member_id,
|
|
'site_id' => $this->site_id,//站点id
|
|
'order_from' => $this->params[ 'app_type' ],
|
|
'order_from_name' => $this->params[ 'app_type_name' ],
|
|
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
|
'delivery' => isset($this->params[ 'delivery' ]) && !empty($this->params[ 'delivery' ]) ? json_decode($this->params[ 'delivery' ], true) : [],
|
|
'coupon' => isset($this->params[ 'coupon' ]) && !empty($this->params[ 'coupon' ]) ? json_decode($this->params[ 'coupon' ], true) : [],
|
|
'member_address' => isset($this->params[ 'member_address' ]) && !empty($this->params[ 'member_address' ]) ? json_decode($this->params[ 'member_address' ], true) : [],
|
|
|
|
'latitude' => $this->params[ 'latitude' ] ?? '',
|
|
'longitude' => $this->params[ 'longitude' ] ?? '',
|
|
|
|
'is_invoice' => $this->params[ 'is_invoice' ] ?? 0,
|
|
'invoice_type' => $this->params[ 'invoice_type' ] ?? 0,
|
|
'invoice_title' => $this->params[ 'invoice_title' ] ?? '',
|
|
'taxpayer_number' => $this->params[ 'taxpayer_number' ] ?? '',
|
|
'invoice_content' => $this->params[ 'invoice_content' ] ?? '',
|
|
'invoice_full_address' => $this->params[ 'invoice_full_address' ] ?? '',
|
|
'is_tax_invoice' => $this->params[ 'is_tax_invoice' ] ?? 0,
|
|
'invoice_email' => $this->params[ 'invoice_email' ] ?? '',
|
|
'invoice_title_type' => $this->params[ 'invoice_title_type' ] ?? 0,
|
|
'buyer_ask_delivery_time' => $this->params[ 'buyer_ask_delivery_time' ] ?? '',
|
|
'goods_sku_list' => !empty($this->params['goods_sku_list']) ? json_decode($this->params['goods_sku_list'], true) : [],
|
|
'sku_id' => isset($this->params['sku_id']) ? $this->params['sku_id'] : '',
|
|
];
|
|
if ($data[ 'futures_id' ] == 0) {
|
|
return $this->response($this->error('', '缺少必填参数商品数据'));
|
|
}
|
|
$res = $order_create->calculate($data);
|
|
return $this->response($res);
|
|
}
|
|
|
|
/**
|
|
* 待支付订单 数据初始化
|
|
* @return string
|
|
*/
|
|
public function payment()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token[ 'code' ] < 0) return $this->response($token);
|
|
$order_create = new OrderCreateModel();
|
|
$data = [
|
|
'futures_id' => $this->params[ 'futures_id' ] ?? 0,
|
|
'member_id' => $this->member_id,
|
|
'site_id' => $this->site_id,//站点id
|
|
'order_from' => $this->params[ 'app_type' ],
|
|
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
|
'order_from_name' => $this->params[ 'app_type_name' ],
|
|
|
|
'latitude' => $this->params[ 'latitude' ] ?? '',
|
|
'longitude' => $this->params[ 'longitude' ] ?? '',
|
|
'default_store_id' => $this->params[ 'default_store_id' ] ?? 0,
|
|
'goods_sku_list' => !empty($this->params['goods_sku_list']) ? json_decode($this->params['goods_sku_list'], true) : [],
|
|
'sku_id' => isset($this->params['sku_id']) ? $this->params['sku_id'] : '',
|
|
];
|
|
if ($data[ 'futures_id' ] == 0) {
|
|
return $this->response($this->error('', '缺少必填参数商品数据'));
|
|
}
|
|
$res = $order_create->orderPayment($data);
|
|
return $this->response($res);
|
|
}
|
|
|
|
} |