12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\admin\controller\order;
- use app\admin\validate\coupon\CouponValidate;
- use app\admin\validate\device\DeviceValidate;
- use app\admin\validate\order\OrderValidate;
- use app\controller\Curd;
- use app\model\Coupon;
- use app\model\Device;
- use app\model\Order;
- use app\model\OrderSheet;
- use app\model\SysSerial;
- use support\exception\BusinessException;
- use support\Request;
- use support\Response;
- class PendingController extends Curd
- {
- public function __construct()
- {
- $this->model = new Order();
- $this->validate = true;
- $this->validateClass = new OrderValidate();
- }
- /**
- * @Desc 列表
- * @Author Gorden
- * @Date 2024/3/28 15:01
- *
- * @param Request $request
- * @return Response
- * @throws \support\exception\BusinessException
- */
- public function select(Request $request): Response
- {
- [$where, $format, $limit, $field, $order] = $this->selectInput($request);
- $order = $request->get('order', 'desc');
- $field = $field ?? 'order_addtimes';
- $where['order_status_system'] = 'WAITING';
- $query = $this->doSelect($where, $field, $order);
- return $this->doFormat($query, $format, $limit);
- }
- /**
- * @Desc 订单商品详情
- * @Author Gorden
- * @Date 2024/3/29 8:50
- *
- * @param Request $request
- * @return Response
- */
- public function sheet(Request $request)
- {
- $orderId = $request->get('order_id');
- $orderSheet = OrderSheet::with([
- 'member' => function ($query) {
- $query->select('member_id', 'member_mobile');
- },
- 'goods' => function ($query) {
- $query->select('goods_id', 'goods_name', 'goods_cover', 'goods_market_price', 'goods_sales_price');
- },
- ])->where('join_sheet_order_id', $orderId)
- ->get()
- ->toArray();
- foreach ($orderSheet as &$item) {
- $item['goods']['goods_cover'] = getenv('STORAGE_DOMAIN') . $item['goods']['goods_cover'];
- }
- $order = Order::where('order_id', $orderId)->first();
- $data = [
- 'order' => $order,
- 'sheet' => $orderSheet
- ];
- return json_success('', $data);
- }
- protected function updateInput(Request $request): array
- {
- $primary_key = $this->model->getKeyName();
- $id = $request->post($primary_key);
- $data = $this->inputFilter($request->post());
- $data['coupon_begindate'] = strtotime($data['coupon_begindate']);
- $data['coupon_enddate'] = strtotime($data['coupon_enddate']);
- $model = $this->model->find($id);
- if (!$model) {
- throw new BusinessException('记录不存在', 2);
- }
- unset($data[$primary_key]);
- return [$id, $data];
- }
- }
|