diff --git a/application/api/controller/Order.php b/application/api/controller/Order.php index c0772c4..706c0e7 100755 --- a/application/api/controller/Order.php +++ b/application/api/controller/Order.php @@ -175,7 +175,7 @@ class Order extends Api */ public function getGoodsList(){ $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); $user = $this->auth->getUserinfo(); $warehouse = Warehouse::where('id', $warehouse_id)->find(); @@ -186,14 +186,31 @@ class Order extends Api if ($is_allow_access > 0 ) { $this->error("抢购次数被限制"); } - - $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; - }); + $list = Db::name('order')->alias('order') + ->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(); + $goods = Goods::where('id', $detail['goods_id'])->find(); + $goods['image'] = cdnurl($goods['image'], true); + $item['goods'] = $goods; + 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); } /** @@ -285,6 +302,7 @@ class Order extends Api "warehouse_id" => $goods['warehouse_id'], "order_amount" => $order_amount, "pay_amount" => $pay_amount, + "actual_amount" => -$pay_amount, "coupon_price" => 0, "coupon_id" => 0, "consignee" => $address['consignee'], @@ -613,6 +631,7 @@ class Order extends Api "warehouse_id" => $order['warehouse_id'], "order_amount" => intval($goods_price), "pay_amount" => intval($goods_price), + "actual_amount" => intval($goods_price), "coupon_price" => 0, "coupon_id" => 0, "status" => 3, @@ -742,6 +761,7 @@ class Order extends Api "warehouse_id" => $order_info['warehouse_id'], "order_amount" => intval($goods_price), "pay_amount" => intval($goods_price), + "actual_amount" => intval($goods_price), "coupon_price" => 0, "coupon_id" => 0, "status" => 3, diff --git a/application/api/controller/User.php b/application/api/controller/User.php index c268785..6004c09 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -643,7 +643,7 @@ class User extends Api if ($value['payer_id'] == $user['id']) { $value['type'] = 1; //付款人不需要看到付款待确认的记录 - if ($value['status' == 2]) { + if ($value['status'] == 2) { unset($list[$key]); } } else { @@ -653,7 +653,7 @@ class User extends Api $value['seller'] = UserModel::where('id', $value['payee_id'])->find(); } - $this->success("succ", $list); + $this->success("succ", array_values($list)); } /** * 收支确认支付