| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
- * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
- * =========================================================
- */
- namespace addon\store\shopapi\controller;
- use addon\store\model\cashier\PendOrder as PendOrderModel;
- class Pendorder extends BaseStoreApi
- {
- public function add()
- {
- $goods = $this->params[ 'goods' ] ?? '[]';
- $discount = $this->params[ 'discount' ] ?? '{}';
- $data = [
- 'site_id' => $this->site_id,
- 'member_id' => $this->params[ 'member_id' ] ?? 0,
- 'store_id' => $this->store_id,
- 'goods' => json_decode($goods, true),
- 'discount_moeny' => $this->params[ 'discount_moeny' ] ?? 0,
- 'discount' => json_decode($discount, true),
- 'remark' => $this->params[ 'remark' ] ?? ''
- ];
- $res = ( new PendOrderModel() )->add($data);
- return $this->response($res);
- }
- public function edit()
- {
- $goods = $this->params[ 'goods' ] ?? '[]';
- $discount = $this->params[ 'discount' ] ?? '{}';
- $data = [
- 'site_id' => $this->site_id,
- 'order_id' => $this->params[ 'order_id' ],
- 'member_id' => $this->params[ 'member_id' ] ?? 0,
- 'store_id' => $this->store_id,
- 'goods' => json_decode($goods, true),
- 'discount_moeny' => $this->params[ 'discount_moeny' ] ?? 0,
- 'discount' => json_decode($discount, true),
- 'remark' => $this->params[ 'remark' ] ?? ''
- ];
- $res = ( new PendOrderModel() )->edit($data);
- return $this->response($res);
- }
- public function page()
- {
- $page_index = $this->params[ 'page' ] ?? 1;
- $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
- $conditon = [
- [ 'o.site_id', '=', $this->site_id ],
- [ 'o.store_id', '=', $this->store_id ]
- ];
- $model = new PendOrderModel();
- $data = $model->getOrderPageList($conditon, 'o.*,m.nickname', 'o.create_time desc', $page_index, $page_size, 'o', [ [ 'member m', 'm.member_id = o.member_id', 'left' ] ]);
- if (!empty($data[ 'data' ][ 'list' ])) {
- $field = 'og.*, g.goods_type, g.goods_name, gs.spec_name, g.goods_image';
- foreach ($data[ 'data' ][ 'list' ] as $k => $v) {
- $list = $model->getOrderGoodsList([ [ 'og.order_id', '=', $v[ 'order_id' ] ] ], $field, '', 'og', [
- [ 'goods g', 'g.goods_id = og.goods_id', 'left' ],
- [ 'goods_sku gs', 'gs.sku_id = og.sku_id', 'left' ]
- ])[ 'data' ];
- $data[ 'data' ][ 'list' ][ $k ][ 'order_goods' ] = $list;
- }
- }
- return $this->response($data);
- }
- public function delete()
- {
- $order_id = $this->params[ 'order_id' ];
- $res = ( new PendOrderModel() )->delete([
- 'site_id' => $this->site_id,
- 'store_id' => $this->store_id,
- 'order_id' => $order_id
- ]);
- return $this->response($res);
- }
- public function updateRemark()
- {
- $order_id = $this->params[ 'order_id' ];
- $remark = $this->params[ 'remark' ];
- $res = ( new PendOrderModel() )->update([ 'remark' => $remark ], [
- [ 'site_id', '=', $this->site_id ],
- [ 'store_id', '=', $this->store_id ],
- [ 'order_id', '=', $order_id ]
- ]);
- return $this->response($res);
- }
- }
|