Pendorder.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\store\shopapi\controller;
  13. use addon\store\model\cashier\PendOrder as PendOrderModel;
  14. class Pendorder extends BaseStoreApi
  15. {
  16. public function add()
  17. {
  18. $goods = $this->params[ 'goods' ] ?? '[]';
  19. $discount = $this->params[ 'discount' ] ?? '{}';
  20. $data = [
  21. 'site_id' => $this->site_id,
  22. 'member_id' => $this->params[ 'member_id' ] ?? 0,
  23. 'store_id' => $this->store_id,
  24. 'goods' => json_decode($goods, true),
  25. 'discount_moeny' => $this->params[ 'discount_moeny' ] ?? 0,
  26. 'discount' => json_decode($discount, true),
  27. 'remark' => $this->params[ 'remark' ] ?? ''
  28. ];
  29. $res = ( new PendOrderModel() )->add($data);
  30. return $this->response($res);
  31. }
  32. public function edit()
  33. {
  34. $goods = $this->params[ 'goods' ] ?? '[]';
  35. $discount = $this->params[ 'discount' ] ?? '{}';
  36. $data = [
  37. 'site_id' => $this->site_id,
  38. 'order_id' => $this->params[ 'order_id' ],
  39. 'member_id' => $this->params[ 'member_id' ] ?? 0,
  40. 'store_id' => $this->store_id,
  41. 'goods' => json_decode($goods, true),
  42. 'discount_moeny' => $this->params[ 'discount_moeny' ] ?? 0,
  43. 'discount' => json_decode($discount, true),
  44. 'remark' => $this->params[ 'remark' ] ?? ''
  45. ];
  46. $res = ( new PendOrderModel() )->edit($data);
  47. return $this->response($res);
  48. }
  49. public function page()
  50. {
  51. $page_index = $this->params[ 'page' ] ?? 1;
  52. $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
  53. $conditon = [
  54. [ 'o.site_id', '=', $this->site_id ],
  55. [ 'o.store_id', '=', $this->store_id ]
  56. ];
  57. $model = new PendOrderModel();
  58. $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' ] ]);
  59. if (!empty($data[ 'data' ][ 'list' ])) {
  60. $field = 'og.*, g.goods_type, g.goods_name, gs.spec_name, g.goods_image';
  61. foreach ($data[ 'data' ][ 'list' ] as $k => $v) {
  62. $list = $model->getOrderGoodsList([ [ 'og.order_id', '=', $v[ 'order_id' ] ] ], $field, '', 'og', [
  63. [ 'goods g', 'g.goods_id = og.goods_id', 'left' ],
  64. [ 'goods_sku gs', 'gs.sku_id = og.sku_id', 'left' ]
  65. ])[ 'data' ];
  66. $data[ 'data' ][ 'list' ][ $k ][ 'order_goods' ] = $list;
  67. }
  68. }
  69. return $this->response($data);
  70. }
  71. public function delete()
  72. {
  73. $order_id = $this->params[ 'order_id' ];
  74. $res = ( new PendOrderModel() )->delete([
  75. 'site_id' => $this->site_id,
  76. 'store_id' => $this->store_id,
  77. 'order_id' => $order_id
  78. ]);
  79. return $this->response($res);
  80. }
  81. public function updateRemark()
  82. {
  83. $order_id = $this->params[ 'order_id' ];
  84. $remark = $this->params[ 'remark' ];
  85. $res = ( new PendOrderModel() )->update([ 'remark' => $remark ], [
  86. [ 'site_id', '=', $this->site_id ],
  87. [ 'store_id', '=', $this->store_id ],
  88. [ 'order_id', '=', $order_id ]
  89. ]);
  90. return $this->response($res);
  91. }
  92. }