lqmac 1 year ago
parent a714b51751
commit fadb61d82a
  1. 26
      application/api/controller/Order.php
  2. 4
      application/api/controller/User.php

@ -175,7 +175,7 @@ class Order extends Api
*/ */
public function getGoodsList(){ public function getGoodsList(){
$page = $this->request->post("page", 1); $page = $this->request->post("page", 1);
$limit = $this->request->post("limit", 10); $limit = $this->request->post("limit", 20);
$warehouse_id = $this->request->post("warehouse_id", 3); $warehouse_id = $this->request->post("warehouse_id", 3);
$user = $this->auth->getUserinfo(); $user = $this->auth->getUserinfo();
$warehouse = Warehouse::where('id', $warehouse_id)->find(); $warehouse = Warehouse::where('id', $warehouse_id)->find();
@ -186,14 +186,31 @@ class Order extends Api
if ($is_allow_access > 0 ) { if ($is_allow_access > 0 ) {
$this->error("抢购次数被限制"); $this->error("抢购次数被限制");
} }
$list = Db::name('order')->alias('order')
$list = OrderModel::where('warehouse_id', $warehouse_id)->where('order_type',1)->where('status', 3)->where('user_id', "<>", $user['id'])->field("id,user_id,order_amount,pay_amount,warehouse_id")->order('id', 'desc')->paginate($this->request->param('list_rows', 20))->each(function ($item, $key){ ->join("order_detail order_detail","order_detail.order_id = order.id")
->join("goods goods","goods.id = order_detail.goods_id")
->field("order.id,order.user_id,order.order_amount,order.pay_amount,order.warehouse_id")
->where('order.warehouse_id', $warehouse_id)
->where('order.order_type',1)
->where('order.status', 3)
->where('order.user_id', "<>", $user['id'])
->group('order.id')
->order('goods.status', 'desc')
->order("order.id desc")
->paginate($limit, false, [])->each(function ($item, $key){
$detail = Detail::where('order_id', $item['id'])->find(); $detail = Detail::where('order_id', $item['id'])->find();
$goods = Goods::where('id', $detail['goods_id'])->find(); $goods = Goods::where('id', $detail['goods_id'])->find();
$goods['image'] = cdnurl($goods['image'], true); $goods['image'] = cdnurl($goods['image'], true);
$item['goods'] = $goods; $item['goods'] = $goods;
return $item; return $item;
}); });
// $list = OrderModel::where('warehouse_id', $warehouse_id)->where('order_type',1)->where('status', 3)->where('user_id', "<>", $user['id'])->field("id,user_id,order_amount,pay_amount,warehouse_id")->order('id', 'desc')->paginate($this->request->param('list_rows', 20))->each(function ($item, $key){
// $detail = Detail::where('order_id', $item['id'])->find();
// $goods = Goods::where('id', $detail['goods_id'])->find();
// $goods['image'] = cdnurl($goods['image'], true);
// $item['goods'] = $goods;
// return $item;
// });
$this->success("succ", $list); $this->success("succ", $list);
} }
/** /**
@ -285,6 +302,7 @@ class Order extends Api
"warehouse_id" => $goods['warehouse_id'], "warehouse_id" => $goods['warehouse_id'],
"order_amount" => $order_amount, "order_amount" => $order_amount,
"pay_amount" => $pay_amount, "pay_amount" => $pay_amount,
"actual_amount" => -$pay_amount,
"coupon_price" => 0, "coupon_price" => 0,
"coupon_id" => 0, "coupon_id" => 0,
"consignee" => $address['consignee'], "consignee" => $address['consignee'],
@ -613,6 +631,7 @@ class Order extends Api
"warehouse_id" => $order['warehouse_id'], "warehouse_id" => $order['warehouse_id'],
"order_amount" => intval($goods_price), "order_amount" => intval($goods_price),
"pay_amount" => intval($goods_price), "pay_amount" => intval($goods_price),
"actual_amount" => intval($goods_price),
"coupon_price" => 0, "coupon_price" => 0,
"coupon_id" => 0, "coupon_id" => 0,
"status" => 3, "status" => 3,
@ -742,6 +761,7 @@ class Order extends Api
"warehouse_id" => $order_info['warehouse_id'], "warehouse_id" => $order_info['warehouse_id'],
"order_amount" => intval($goods_price), "order_amount" => intval($goods_price),
"pay_amount" => intval($goods_price), "pay_amount" => intval($goods_price),
"actual_amount" => intval($goods_price),
"coupon_price" => 0, "coupon_price" => 0,
"coupon_id" => 0, "coupon_id" => 0,
"status" => 3, "status" => 3,

@ -643,7 +643,7 @@ class User extends Api
if ($value['payer_id'] == $user['id']) { if ($value['payer_id'] == $user['id']) {
$value['type'] = 1; $value['type'] = 1;
//付款人不需要看到付款待确认的记录 //付款人不需要看到付款待确认的记录
if ($value['status' == 2]) { if ($value['status'] == 2) {
unset($list[$key]); unset($list[$key]);
} }
} else { } else {
@ -653,7 +653,7 @@ class User extends Api
$value['seller'] = UserModel::where('id', $value['payee_id'])->find(); $value['seller'] = UserModel::where('id', $value['payee_id'])->find();
} }
$this->success("succ", $list); $this->success("succ", array_values($list));
} }
/** /**
* 收支确认支付 * 收支确认支付

Loading…
Cancel
Save