feat: 修改了订单相关的API文档和逻辑
This commit is contained in:
parent
2232843ad1
commit
5e54943d4c
@ -14,7 +14,9 @@ class ProductStatisticLogic extends BaseLogic
|
||||
|
||||
public function get_product_ranking($where)
|
||||
{
|
||||
$list = StoreProductLog::where($where)->with('store')
|
||||
$time = explode('-', $where['create_time']);
|
||||
$time = [strtotime($time[0]), strtotime($time[1])];
|
||||
$list = StoreProductLog::whereBetweenTime('create_time',$time[0],$time[1])->with('store')
|
||||
->field([
|
||||
'store_id',
|
||||
'product_id',
|
||||
@ -29,7 +31,7 @@ class ProductStatisticLogic extends BaseLogic
|
||||
'SUM(collect_num) as collect',
|
||||
'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes',
|
||||
'COUNT(distinct(pay_uid))-1 as repeats'
|
||||
])->group('product_id')->order('pay' . ' desc')->limit(20)->select()->toArray();
|
||||
])->group('product_id')->order('pay' , ' desc')->limit(20)->select()->toArray();
|
||||
foreach ($list as $key => &$item) {
|
||||
if (!$item['store_name']) {
|
||||
unset($list[$key]);
|
||||
|
@ -93,7 +93,6 @@ class UserStatisticLogic extends BaseLogic
|
||||
{
|
||||
$time = explode('-', $where['create_time']);
|
||||
$time = [strtotime($time[0]), strtotime($time[1])];
|
||||
|
||||
$channelType = ''; //$where['channel_type'];
|
||||
if (count($time) != 2) throw new Exception('参数错误');
|
||||
$dayCount = ($time[1] - $time[0]) / 86400 + 1;
|
||||
|
@ -30,15 +30,9 @@ class OrderController extends BaseApiController
|
||||
return $this->dataLists(new OrderList());
|
||||
}
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('核销码查数据'),
|
||||
// ApiDoc\url('/api/order/order/write_code'),
|
||||
// ApiDoc\Method('POST'),
|
||||
// ApiDoc\Param(name: "code", type: "string", require: false, desc: "核销码"),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
// ]
|
||||
/**
|
||||
* 核销码查数据
|
||||
*/
|
||||
public function write_code()
|
||||
{
|
||||
$code = $this->request->post('code');
|
||||
@ -52,18 +46,9 @@ class OrderController extends BaseApiController
|
||||
return $this->success('ok', $res);
|
||||
}
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('核销订单列表'),
|
||||
// ApiDoc\url('/api/order/order/write_list'),
|
||||
// ApiDoc\Method('POST'),
|
||||
// ApiDoc\Param(name: "status", type: "int", require: true, desc: "1:待核销;2:已核销"),
|
||||
// ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"),
|
||||
// ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"),
|
||||
// ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
// ]
|
||||
/**
|
||||
* 核销订单列表
|
||||
*/
|
||||
public function write_list()
|
||||
{
|
||||
$status = (int)$this->request->post('status', 1);
|
||||
@ -81,15 +66,9 @@ class OrderController extends BaseApiController
|
||||
return $this->success('ok', $res);
|
||||
}
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('核销数量'),
|
||||
// ApiDoc\url('/api/order/order/write_count'),
|
||||
// ApiDoc\Method('POST'),
|
||||
// ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
// ]
|
||||
/**
|
||||
* 核销数量
|
||||
*/
|
||||
public function write_count()
|
||||
{
|
||||
$info = $this->userInfo;
|
||||
@ -98,41 +77,9 @@ class OrderController extends BaseApiController
|
||||
return $this->success('ok', $res);
|
||||
}
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('订单校验'),
|
||||
// ApiDoc\url('/api/order/order/checkOrder'),
|
||||
// ApiDoc\Method('POST'),
|
||||
// ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "购物车id"),
|
||||
// ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"),
|
||||
// ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"),
|
||||
// ApiDoc\Param(name: "verify_code", type: "int", require: true, desc: "校验码"),
|
||||
// ApiDoc\Param(name: "shipping_type", type: "int", require: true, desc: "配送方式"),
|
||||
// ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||
// ['name' => 'order', 'desc' => '订单信息', 'type' => 'array', 'children' => [
|
||||
// ['name' => 'create_time', 'desc' => '订单创建时间', 'type' => 'int'],
|
||||
// ['name' => 'order_id', 'desc' => '订单id', 'type' => 'int'],
|
||||
// ['name' => 'total_price', 'desc' => '订单总金额', 'type' => 'float'],
|
||||
// ['name' => 'pay_price', 'desc' => '实际支付金额', 'type' => 'float'],
|
||||
// ['name' => 'total_num', 'desc' => '订单总数量', 'type' => 'int'],
|
||||
// ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'int'],
|
||||
// ['name' => 'cart_id', 'desc' => '购物车id', 'type' => 'string'],
|
||||
// ['name' => 'store_id', 'desc' => '店铺id', 'type' => 'int'],
|
||||
// ['name' => 'shipping_type', 'desc' => '配送方式', 'type' => 'int'],
|
||||
// ]],
|
||||
// ['name' => 'cart_list', 'desc' => '购物车商品列表', 'type' => 'array', 'children' => [
|
||||
// ['name' => 'goods', 'desc' => '商品id', 'type' => 'int'],
|
||||
// ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'int'],
|
||||
// ['name' => 'total', 'desc' => '商品总价', 'type' => 'float'],
|
||||
// ['name' => 'price', 'desc' => '商品单价', 'type' => 'float'],
|
||||
// ['name' => 'product_id', 'desc' => '商品id', 'type' => 'int'],
|
||||
// ['name' => 'old_cart_id', 'desc' => '原购物车id', 'type' => 'string'],
|
||||
// ['name' => 'verify_code', 'desc' => '校验码', 'type' => 'string'],
|
||||
// ]],
|
||||
// ]),
|
||||
// ]
|
||||
/**
|
||||
* 订单校验
|
||||
*/
|
||||
public function checkOrder()
|
||||
{
|
||||
$cartId = (array)$this->request->post('cart_id', []);
|
||||
@ -140,7 +87,7 @@ class OrderController extends BaseApiController
|
||||
// $pay_type = (int)$this->request->post('pay_type');
|
||||
// $auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||
$params = $this->request->post();
|
||||
$user=User::where('id',$this->userId)->find();
|
||||
$user = User::where('id', $this->userId)->find();
|
||||
$res = OrderLogic::cartIdByOrderInfo($cartId, $addressId, $user, $params);
|
||||
if ($res == false) {
|
||||
$msg = OrderLogic::getError();
|
||||
@ -152,19 +99,9 @@ class OrderController extends BaseApiController
|
||||
return $this->data($res);
|
||||
}
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('创建订单'),
|
||||
// ApiDoc\url('/api/order/order/createOrder'),
|
||||
// ApiDoc\Method('POST'),
|
||||
// ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "id"),
|
||||
// ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"),
|
||||
// ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"),
|
||||
// ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"),
|
||||
// ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
// ]
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
public function createOrder()
|
||||
{
|
||||
$cartId = (array)$this->request->post('cart_id', []);
|
||||
@ -180,15 +117,15 @@ class OrderController extends BaseApiController
|
||||
return $this->fail('购物车商品不能超过100个');
|
||||
}
|
||||
|
||||
$user=User::where('id',$this->userId)->find();
|
||||
if($pay_type == PayEnum::PURCHASE_FUNDS || $pay_type == PayEnum::BALANCE_PAY ){
|
||||
if(!isset($params['password'])){
|
||||
$user = User::where('id', $this->userId)->find();
|
||||
if ($pay_type == PayEnum::PURCHASE_FUNDS || $pay_type == PayEnum::BALANCE_PAY) {
|
||||
if (!isset($params['password'])) {
|
||||
return $this->fail('缺失参数');
|
||||
}
|
||||
if(empty($user['pay_password'])){
|
||||
if (empty($user['pay_password'])) {
|
||||
return $this->fail('请设置密码');
|
||||
}
|
||||
if (!password_verify($params['password'], $user['pay_password'])){
|
||||
if (!password_verify($params['password'], $user['pay_password'])) {
|
||||
return $this->fail('密码错误');
|
||||
}
|
||||
}
|
||||
@ -196,7 +133,7 @@ class OrderController extends BaseApiController
|
||||
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
|
||||
|
||||
if ($order != false) {
|
||||
if($order['pay_price'] <= 0){
|
||||
if ($order['pay_price'] <= 0) {
|
||||
$pay_type = 3;
|
||||
}
|
||||
switch ($pay_type) {
|
||||
@ -277,18 +214,9 @@ class OrderController extends BaseApiController
|
||||
return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving, 'all' => $all, 'applyRefund' => $applyRefund, 'refund' => $refund]);
|
||||
}
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('订单支付'),
|
||||
// ApiDoc\url('/api/order/order/pay'),
|
||||
// ApiDoc\Method('POST'),
|
||||
// ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"),
|
||||
// ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"),
|
||||
// ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"),
|
||||
// ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
// ]
|
||||
/**
|
||||
* 订单支付
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
$order_id = (int)$this->request->post('order_id');
|
||||
@ -377,18 +305,18 @@ class OrderController extends BaseApiController
|
||||
public function detail()
|
||||
{
|
||||
$order_id = (int)$this->request->get('order_id');
|
||||
$lat = $this->request->get('lat','');
|
||||
$lng = $this->request->get('long','');
|
||||
$lat = $this->request->get('lat', '');
|
||||
$lng = $this->request->get('long', '');
|
||||
$where = [
|
||||
'id' => $order_id,
|
||||
'uid' => $this->userId,
|
||||
];
|
||||
$url = 'https://'.$this->request->host(true);
|
||||
$url = 'https://' . $this->request->host(true);
|
||||
$parm = [
|
||||
'lat'=>$lat,
|
||||
'long'=>$lng
|
||||
'lat' => $lat,
|
||||
'long' => $lng
|
||||
];
|
||||
$order = OrderLogic::detail($where,$url,$parm);
|
||||
$order = OrderLogic::detail($where, $url, $parm);
|
||||
if ($order) {
|
||||
return $this->data($order);
|
||||
} else {
|
||||
|
@ -138,7 +138,6 @@ class OrderLogic extends BaseLogic
|
||||
throw new Exception('金额低于500');
|
||||
}
|
||||
|
||||
$vipPrice = 0;
|
||||
//成本价 收益
|
||||
$order = [
|
||||
'create_time' => time(),
|
||||
@ -147,7 +146,7 @@ class OrderLogic extends BaseLogic
|
||||
'cost' => self::$cost, //成本价1-
|
||||
'profit' =>0, //利润
|
||||
'pay_price' => $pay_price, //后期可能有降价抵扣
|
||||
'vip_price' => $vipPrice,
|
||||
'vip_price' => 0,
|
||||
'total_num' => count($cart_select), //总数
|
||||
'pay_type' => $params['pay_type'] ?? 0,
|
||||
'reservation_time' => $params['reservation_time'] ?? null,
|
||||
|
@ -80,7 +80,7 @@ class StoreOrder extends BaseModel
|
||||
$query->where('channel_type', $type);
|
||||
})->where('paid', 1)->where('paid', '>=', 0)->where(function ($query) use ($time) {
|
||||
if ($time[0] == $time[1]) {
|
||||
$query->whereDay('create_time', $time[0]);
|
||||
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
||||
} else {
|
||||
$time[1] = $time[1] + 86400;
|
||||
$query->whereTime('create_time', 'between', $time);
|
||||
|
@ -189,7 +189,7 @@ class User extends BaseModel
|
||||
$query->where('user_type', $type);
|
||||
})->where(function ($query) use ($time) {
|
||||
if ($time[0] == $time[1]) {
|
||||
$query->whereDay('create_time', $time[0]);
|
||||
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
||||
} else {
|
||||
$time[1] = $time[1] + 86400;
|
||||
$query->whereTime('create_time', 'between', $time);
|
||||
|
@ -33,7 +33,7 @@ class UserVisit extends BaseModel
|
||||
$query->where('channel_type', $type);
|
||||
})->where(function ($query) use ($time) {
|
||||
if ($time[0] == $time[1]) {
|
||||
$query->whereDay('create_time', $time[0]);
|
||||
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
||||
} else {
|
||||
$time[1] = $time[1] + 86400;
|
||||
$query->whereTime('create_time', 'between', $time);
|
||||
|
@ -32,7 +32,7 @@ class UserRecharge extends BaseModel
|
||||
$query->where('channel_type', $type);
|
||||
})->where($where)->where(function ($query) use ($time) {
|
||||
if ($time[0] == $time[1]) {
|
||||
$query->whereDay('create_time', $time[0]);
|
||||
$query->whereDay('create_time', date('Y-m-d',$time[0]));
|
||||
} else {
|
||||
$time[1] = $time[1] + 86400;
|
||||
$query->whereTime('create_time', 'between', $time);
|
||||
|
Loading…
x
Reference in New Issue
Block a user