Ordercreate.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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\order\OrderCreate as OrderCreateModel;
  14. /**
  15. * 订单创建(收银台)
  16. * Class OrderRefund
  17. * @package addon\shop\siteapi\controller
  18. */
  19. class Ordercreate extends BaseStoreApi
  20. {
  21. public function payment()
  22. {
  23. $token = $this->checkToken();
  24. if ($token[ 'code' ] < 0) return $this->response($token);
  25. $order_id = $this->params[ 'order_id' ] ?? 0;
  26. $order_create_model = new OrderCreateModel();
  27. $data = [
  28. 'site_id' => $this->site_id,//站点id
  29. 'order_id' => $order_id,
  30. 'member_id' => $this->params[ 'member_id' ] ?? 0,//购买会员(可有可无)
  31. 'store_id' => $this->store_id ?? 0,
  32. 'app_module' => $this->site_type,
  33. 'coupon_id' => $this->params[ 'coupon_id' ] ?? '',
  34. 'is_use_balance' => $this->params[ 'is_use_balance' ] ?? 0,
  35. 'is_use_point' => $this->params[ 'is_use_point' ] ?? 0,
  36. 'hongbao_id' => $this->params[ 'hongbao_id' ] ?? 0,
  37. 'order_from' => $this->params[ 'order_from' ] ?? 'h5',
  38. 'promotion_type' => '',
  39. 'source' => $this->params[ 'source' ] ?? '',// is_buy 普通购买 cart 购物车 ‘’ 参与活动,
  40. 'promotion_extend' => empty($this->params[ 'promotion_extend' ]) ? [] : json_decode($this->params[ 'promotion_extend' ], true)
  41. ];
  42. if (empty($data[ 'sku_array' ])) {
  43. return $this->response($this->error('', '缺少必填参数商品数据'));
  44. }
  45. $res = $order_create_model->orderPayment($data);
  46. return $this->response($res);
  47. }
  48. /**
  49. * 商品计算
  50. * @return false|string
  51. */
  52. public function calculate()
  53. {
  54. $token = $this->checkToken();
  55. if ($token[ 'code' ] < 0) return $this->response($token);
  56. $order_create_model = new OrderCreateModel();
  57. $data = [
  58. 'site_id' => $this->site_id,//站点id
  59. 'sku_array' => !empty($this->params[ 'sku_array' ]) ? json_decode($this->params[ 'sku_array' ], true) : [],
  60. 'member_id' => $this->params[ 'member_id' ] ?? 0,//购买会员(可有可无)
  61. 'app_module' => $this->site_type,
  62. 'store_id' => $this->params[ 'store_id' ] ?? 0,
  63. 'mobile' => $this->params[ 'mobile' ] ?? '',
  64. 'coupon_id' => $this->params[ 'coupon_id' ] ?? 0,
  65. 'is_use_balance' => $this->params[ 'is_use_balance' ] ?? 0,
  66. 'is_use_point' => $this->params[ 'is_use_point' ] ?? 0,
  67. 'hongbao_id' => $this->params[ 'hongbao_id' ] ?? 0,
  68. 'order_from' => $this->params[ 'order_from' ] ?? 'h5',
  69. 'promotion_type' => '',
  70. 'source' => $this->params[ 'source' ] ?? '',// is_buy 普通购买 cart 购物车 ‘’ 参与活动,
  71. 'promotion_extend' => empty($this->params[ 'promotion_extend' ]) ? [] : json_decode($this->params[ 'promotion_extend' ], true)
  72. ];
  73. if (empty($data[ 'sku_array' ])) {
  74. return $this->response($this->error('', '缺少必填参数商品数据'));
  75. }
  76. $res = $order_create_model->calculate($data);
  77. return $this->response($res);
  78. }
  79. }