123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php namespace Place_interface\Api;
- use Dever;
- use Place;
- use Place_interface\Lib\Core;
- use Place_act\Lib\Core as Act;
- class Order extends Core
- {
- protected $login = true;
- protected $entry = true;
- # 获取订单列表
- public function list()
- {
- $status = Dever::input('status');
- $data = Dever::load('source/order', 'place_order')->getList(Place::$uid, $status);
- return ['list' => $data];
- }
- # 获取订单详情
- public function info()
- {
- $info = $this->getInfo();
- $info = Dever::load('source/order', 'place_order')->getInfo($info, true);
- $data = ['info' => $info, 'refund_desc_type' => Dever::db('source_refund', 'place_order')->value('desc_type'), 'refund_type' => Dever::db('source_refund', 'place_order')->value('type')];
- if (isset($info['refund']) && $info['refund'] && $info['refund']['type'] == 1 && $info['refund']['status'] == 2) {
- $data['refund_delivery'] = [Dever::call("sector/delivery.getList", 1)];
- }
- return $data;
- }
- # 确认收货
- public function finish()
- {
- $info = $this->getInfo();
- Dever::load('source/order', 'place_order')->finish(1, $info);
- return 'ok';
- }
- # 取消订单
- public function cancel()
- {
- $info = $this->getInfo();
- Dever::load('source/order', 'place_order')->cancel($info);
- return 'ok';
- }
- # 再次支付
- public function pay()
- {
- $info = $this->getInfo();
- if ($info['pay_money_cash'] > 0) {
- $result['pay'] = Dever::load('account', 'place')->pay($info);
- if (isset($result['pay']['link']) && $result['pay']['link']) {
- return $result;
- }
- $result['order_id'] = $info['id'];
- $result['order_num'] = $info['order_num'];
- return $result;
- } else {
- Dever::error('无需支付');
- }
- }
- # 申请退款
- public function refund()
- {
- $info = $this->getInfo();
- /*
- $cash = Dever::input('cash');
- if (!$cash || $cash <= 0) {
- Dever::error('退款金额有误');
- }
- */
- $type = Dever::input('type');
- if (!$type || $type <= 0) {
- Dever::error('退款类型有误');
- }
- $desc_type = Dever::input('desc_type');
- if (!$desc_type || $desc_type <= 0) {
- Dever::error('退款原因有误');
- }
- $desc = Dever::input('desc');
- Dever::load('source/refund', 'place_order')->up([], $info, 1, Place::$uid, $type, 1, $desc_type, $desc);
- return 'ok';
- }
- # 申请退款发货
- public function refundExpress()
- {
- $info = $this->getInfo();
- $refund_id = Dever::input('refund_id');
- if (!$refund_id) {
- Dever::error('退款信息错误');
- }
- $delivery_id = Dever::input('delivery_id');
- if (!$delivery_id) {
- Dever::error('请选择快递公司');
- }
- $number = Dever::input('number');
- if (!$number) {
- Dever::error('请填写单号');
- }
- Dever::load('source/refund', 'place_order')->express($info, $refund_id, $delivery_id, $number);
- return 'ok';
- }
- # 获取订单信息
- private function getInfo()
- {
- $id = Dever::input('id');
- if (!$id) {
- Dever::error('订单信息有误');
- }
- $info = Dever::db('source', 'place_order')->find(['id' => $id, 'uid' => Place::$uid]);
- if (!$info) {
- Dever::error('订单信息有误');
- }
- return $info;
- }
- # 提交评价
- public function review_commit(){}
- public function review()
- {
- $info = $this->getInfo();
- if ($info['review_status'] != 2) {
- Dever::error('您现在不可以评价');
- }
- $data['pic'] = Dever::input('pic');
- if (!$data['pic']) {
- $data['pic'] = '';
- }
- $data['content'] = Dever::input('content', 'is_string', '内容');
- $data['rate'] = Dever::input('rate', 'is_numeric', '评分');
- if (!$data['rate']) {
- Dever::error('评分错误');
- }
- $data['rate'] = intval($data['rate']);
- if ($data['rate'] > 5 || $data['rate'] <= 0) {
- Dever::error('评分错误');
- }
- $data['open'] = Dever::input('open');
- if ($data['open'] == 'true') {
- $data['open'] = 1;
- } else {
- $data['open'] = 2;
- }
- $detail = Dever::db('source_detail', 'place_order')->select(['order_id' => $info['id']]);
- foreach ($detail as $v) {
- $act = Act::load('review', 1, $v['source_id'])->up($data, '请不要发布相同内容');
- }
- Dever::db('source', 'place_order')->update($info['id'], ['review_status' => 3]);
- return 'ok';
- }
- }
|