Ordercreate.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Index.php
  4. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  5. * =========================================================
  6. * Copy right 2015-2025 山西牛酷信息科技有限公司, 保留所有权利。
  7. * ----------------------------------------------
  8. * 官方网址: http://www.niushop.com.cn
  9. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  10. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  11. * =========================================================
  12. * @author : niuteam
  13. * @date : 2015.1.17
  14. * @version : v1.0.0.0
  15. */
  16. namespace addon\bundling\api\controller;
  17. use app\api\controller\BaseApi;
  18. use addon\bundling\model\BundlingOrderCreate as OrderCreateModel;
  19. /**
  20. * 订单创建
  21. * @author Administrator
  22. *
  23. */
  24. class Ordercreate extends BaseApi
  25. {
  26. /**
  27. * 创建订单
  28. */
  29. public function create()
  30. {
  31. $token = $this->checkToken();
  32. if ($token['code'] < 0) return $this->response($token);
  33. $order_create = new OrderCreateModel();
  34. $data = [
  35. 'bl_id' => isset($this->params['bl_id']) ? $this->params['bl_id'] : '',//组合套餐id
  36. 'num' => isset($this->params['num']) ? $this->params['num'] : 1,//组合套餐数量(买几套)
  37. 'member_id' => $this->member_id,
  38. 'order_from' => $this->params['app_type'],
  39. 'order_from_name' => $this->params['app_type_name'],
  40. 'is_balance' => isset($this->params['is_balance']) ? $this->params['is_balance'] : 0,//是否使用余额
  41. 'pay_password' => isset($this->params['pay_password']) ? $this->params['pay_password'] : '',//支付密码
  42. 'buyer_message' => $this->params['buyer_message'],
  43. 'delivery' => isset($this->params["delivery"]) && !empty($this->params["delivery"]) ? json_decode($this->params["delivery"], true) : [],
  44. 'coupon' => isset($this->params["coupon"]) && !empty($this->params["coupon"]) ? json_decode($this->params["coupon"], true) : [],
  45. 'member_address' => isset($this->params["member_address"]) && !empty($this->params["member_address"]) ? json_decode($this->params["member_address"], true) : []
  46. ];
  47. if (empty($data['bl_id'])) {
  48. return $this->response($this->error('', '缺少必填参数商品数据'));
  49. }
  50. $res = $order_create->create($data);
  51. return $this->response($res);
  52. }
  53. /**
  54. * 计算信息
  55. */
  56. public function calculate()
  57. {
  58. $token = $this->checkToken();
  59. if ($token['code'] < 0) return $this->response($token);
  60. $order_create = new OrderCreateModel();
  61. $data = [
  62. 'bl_id' => isset($this->params['bl_id']) ? $this->params['bl_id'] : '',//组合套餐id
  63. 'num' => isset($this->params['num']) ? $this->params['num'] : 1,//组合套餐数量(买几套)
  64. 'member_id' => $this->member_id,
  65. 'order_from' => $this->params['app_type'],
  66. 'order_from_name' => $this->params['app_type_name'],
  67. 'is_balance' => isset($this->params['is_balance']) ? $this->params['is_balance'] : 0,//是否使用余额
  68. 'delivery' => isset($this->params["delivery"]) && !empty($this->params["delivery"]) ? json_decode($this->params["delivery"], true) : [],
  69. 'coupon' => isset($this->params["coupon"]) && !empty($this->params["coupon"]) ? json_decode($this->params["coupon"], true) : [],
  70. 'member_address' => isset($this->params["member_address"]) && !empty($this->params["member_address"]) ? json_decode($this->params["member_address"], true) : []
  71. ];
  72. if (empty($data['bl_id'])) {
  73. return $this->response($this->error('', '缺少必填参数商品数据'));
  74. }
  75. $res = $order_create->calculate($data);
  76. return $this->response($this->success($res));
  77. }
  78. /**
  79. * 待支付订单 数据初始化
  80. * @return string
  81. */
  82. public function payment()
  83. {
  84. $token = $this->checkToken();
  85. if ($token['code'] < 0) return $this->response($token);
  86. $order_create = new OrderCreateModel();
  87. $data = [
  88. 'bl_id' => isset($this->params['bl_id']) ? $this->params['bl_id'] : '',
  89. 'num' => isset($this->params['num']) ? $this->params['num'] : '',
  90. 'member_id' => $this->member_id,
  91. 'order_from' => $this->params['app_type'],
  92. 'is_balance' => isset($this->params['is_balance']) ? $this->params['is_balance'] : 0,//是否使用余额
  93. 'order_from_name' => $this->params['app_type_name']
  94. ];
  95. if (empty($data['bl_id'])) {
  96. return $this->response($this->error('', '缺少必填参数商品数据'));
  97. }
  98. $res = $order_create->orderPayment($data);
  99. return $this->response($this->success($res));
  100. }
  101. }