123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- use think\facade\Db;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 卖家订单控制器
- */
- class Sellerorder extends MobileSeller
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerorder.lang.php');
- }
- /**
- * @api {POST} api/Sellerorder/order_list 订单列表
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {String} order_sn 订单号
- * @apiParam {String} buyer_name 用户名
- * @apiParam {String} state_type 订单状态 state_new待付款 state_pay待发货 state_send待收货 state_success已完成 state_cancel已取消
- * @apiParam {String} query_start_date 开始日期 YYYY-MM-DD
- * @apiParam {String} query_end_date 结束日期 YYYY-MM-DD
- * @apiParam {String} page 页码
- * @apiParam {String} pagesize 每页显示数量
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {Object[]} result.order_list 订单列表 (返回字段参考order表)
- * @apiSuccess {Boolean} result.order_list.if_cancel 是否可取消 true是false否
- * @apiSuccess {Boolean} result.order_list.if_modify_price 是否可修改运费 true是false否
- * @apiSuccess {Boolean} result.order_list.if_spay_price 是否可修改商品价格 true是false否
- * @apiSuccess {Boolean} result.order_list.if_send 是否可发货 true是false否
- * @apiSuccess {Boolean} result.order_list.if_lock 是否被锁定 true是false否
- * @apiSuccess {Boolean} result.order_list.if_deliver 是否显示物流跟踪 true是false否
- * @apiSuccess {Object} result.order_list.extend_order_common 订单其他信息 (返回字段参考ordercommon表)
- * @apiSuccess {Object} result.order_list.extend_order_goods 订单商品信息 (返回字段参考ordergoods表)
- * @apiSuccess {Object} result.order_list.extend_order_goods.image_240_url 商品图片完整路径
- * @apiSuccess {Object} result.order_list.extend_order_goods.goods_type_cn 商品类型名称
- * @apiSuccess {Object} result.order_list.extend_order_goods.goods_url 商品PC链接
- * @apiSuccess {Object} result.order_list.extend_member 用户信息 (返回字段参考member表)
- * @apiSuccess {object} result.order_list.zengpin_list 赠品列表 (返回字段参考ordergoods表)
- * @apiSuccess {object} result.order_list.goods_list 订单商品列表 (返回字段参考ordergoods表)
- * @apiSuccess {object} result.order_list.goods_count 商品数量
- * @apiSuccess {Int} result.page_total 总页数
- * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
- */
- public function order_list()
- {
- $order_model = model('order');
- $condition = array();
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_sn = input('post.order_sn');
- if (!empty($order_sn)) {
- $condition[] = array('order_sn', '=', $order_sn);
- }
- $buyer_name = input('post.buyer_name');
- $pagesize = intval('pagesize');
- if (!empty($buyer_name)) {
- $condition[] = array('buyer_name', '=', $buyer_name);
- }
- $allow_state_array = array('state_new', 'state_pay', 'state_send', 'state_success', 'state_cancel');
- $state_type = input('post.state_type');
- if (in_array($state_type, $allow_state_array)) {
- $condition[] = array('order_state', '=', str_replace($allow_state_array, array(ORDER_STATE_NEW, ORDER_STATE_PAY, ORDER_STATE_SEND, ORDER_STATE_SUCCESS, ORDER_STATE_CANCEL), $state_type));
- }
- $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.query_start_date'));
- $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.query_end_date'));
- $start_unixtime = $if_start_date ? strtotime(input('param.query_start_date')) : null;
- $end_unixtime = $if_end_date ? strtotime(input('param.query_end_date')) : null;
- if ($start_unixtime || $end_unixtime) {
- $condition[] = array('add_time', 'between', array($start_unixtime, $end_unixtime));
- }
- $skip_off = input('param.buyer_name');
- if ($skip_off == 1) {
- $condition[] = array('order_state', '<>', ORDER_STATE_CANCEL);
- }
- $order_list = $order_model->getOrderList($condition, (($pagesize < 1) ? 10 : $pagesize), '*', 'order_id desc', '', array('order_goods', 'order_common', 'ppintuanorder', 'member'));
- $mobile_page = $order_model->page_info;
- //页面中显示那些操作
- foreach ($order_list as $key => $order_info) {
- //显示取消订单
- $order_info['if_cancel'] = $order_model->getOrderOperateState('store_cancel', $order_info);
- //显示调整运费
- $order_info['if_modify_price'] = $order_model->getOrderOperateState('modify_price', $order_info);
- //显示修改价格
- $order_info['if_spay_price'] = $order_model->getOrderOperateState('spay_price', $order_info);
- //显示发货
- $order_info['if_send'] = $order_model->getOrderOperateState('send', $order_info);
- //显示锁定中
- $order_info['if_lock'] = $order_model->getOrderOperateState('lock', $order_info);
- //显示物流跟踪
- $order_info['if_deliver'] = $order_model->getOrderOperateState('deliver', $order_info);
- foreach ($order_info['extend_order_goods'] as $value) {
- $value['image_240_url'] = goods_cthumb($value['goods_image'], 240, $value['store_id']);
- $value['goods_type_cn'] = get_order_goodstype($value['goods_type']);
- if ($value['goods_type'] == 5) {
- $order_info['zengpin_list'][] = $value;
- } else {
- $order_info['goods_list'][] = $value;
- }
- }
- if (empty($order_info['zengpin_list'])) {
- $order_info['goods_count'] = count($order_info['goods_list']);
- } else {
- $order_info['goods_count'] = count($order_info['goods_list']) + 1;
- }
- $order_list[$key] = $order_info;
- }
- $order_list = array_values($order_list);
- $result = array_merge(array('order_list' => $order_list), mobile_page($mobile_page));
- ds_json_encode(10000, '', $result);
- }
- /**
- * @api {POST} api/Sellerorder/search_deliver 物流跟踪
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {String} order_id 订单id
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {String} result.express_name 物流公司名称
- * @apiSuccess {String} result.shipping_code 物流单号
- * @apiSuccess {Object[]} result.deliver_info 物流数据
- * @apiSuccess {String} result.deliver_info.context 内容
- * @apiSuccess {String} result.deliver_info.time 时间
- */
- public function search_deliver()
- {
- $order_id = intval(input('post.order_id'));
- if ($order_id <= 0) {
- ds_json_encode(10001, lang('store_order_none_existr'));
- }
- $condition = array();
- $order_model = model('order');
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_info = $order_model->getOrderInfo($condition, array('order_common', 'order_goods'));
- if (empty($order_info) || !in_array($order_info['order_state'], array(ORDER_STATE_SEND, ORDER_STATE_SUCCESS))) {
- ds_json_encode(10001, lang('store_order_none_existr'));
- }
- $express = rkcache('express', true);
- if (isset($express[$order_info['extend_order_common']['shipping_express_id']])) {
- $express_code = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
- $express_name = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
- $deliver_info = $this->_get_express($express_code, $order_info['shipping_code'], $order_info['extend_order_common']['reciver_info']['phone']);
- } else {
- $express_name = '';
- $deliver_info = array();
- }
- ds_json_encode(10000, '', array('express_name' => $express_name, 'shipping_code' => $order_info['shipping_code'], 'deliver_info' => $deliver_info));
- }
- /**
- * 从第三方取快递信息
- *
- */
- public function _get_express($express_code, $shipping_code, $phone)
- {
- $result = model('express')->queryExpress($express_code, $shipping_code, $phone);
- if ($result['Success'] != true) {
- ds_json_encode(10001, lang('deliver_search_fail'));
- }
- $content['Traces'] = array_reverse($result['Traces']);
- $output = array();
- if (is_array($content['Traces'])) {
- foreach ($content['Traces'] as $k => $v) {
- if ($v['AcceptTime'] == '')
- continue;
- //$output[] = $v['time'] . ' ' . $v['context'];
- $output[$k]['AcceptTime'] = $v['AcceptTime'];
- $output[$k]['AcceptStation'] = $v['AcceptStation'];
- }
- }
- if (empty($output))
- ds_json_encode(10001, lang('deliver_not_exist'));
- return $output;
- }
- /**
- * 取得当前的物流最新信息
- */
- public function get_current_deliver()
- {
- $order_id = intval(input('post.order_id'));
- if ($order_id <= 0) {
- ds_json_encode(10001, lang('store_order_none_existr'));
- }
- $condition = array();
- $order_model = model('order');
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_info = $order_model->getOrderInfo($condition, array('order_common', 'order_goods'));
- if (empty($order_info) || !in_array($order_info['order_state'], array(ORDER_STATE_SEND, ORDER_STATE_SUCCESS))) {
- ds_json_encode(10001, lang('store_order_none_existr'));
- }
- $express = rkcache('express', true);
- if (isset($express[$order_info['extend_order_common']['shipping_express_id']])) {
- $express_code = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
- $express_name = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
- $deliver_info = $this->_get_express($express_code, $order_info['shipping_code'], $order_info['extend_order_common']['reciver_info']['phone']);
- } else {
- $express_code = '';
- $express_name = '';
- $deliver_info = array('0' => '');
- }
- $data = array();
- $data['deliver_info']['context'] = $express_name;
- $data['deliver_info']['time'] = $deliver_info['0'];
- ds_json_encode(10000, '', $data);
- }
- /**
- * @api {POST} api/Sellerorder/order_info 订单详情
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {String} order_id 订单id
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {Object} result.order_info 订单信息
- * @apiSuccess {Int} result.order_info.if_cancel 是否可取消 true是false否
- * @apiSuccess {Int} result.order_info.if_modify_price 是否可修改运费 true是false否
- * @apiSuccess {Int} result.order_info.if_spay_price 是否可修改商品价格 true是false否
- * @apiSuccess {Int} result.order_info.if_send 是否可发货 true是false否
- * @apiSuccess {Int} result.order_info.if_lock 是否被锁定 true是false否
- * @apiSuccess {Int} result.order_info.if_deliver 是否显示物流跟踪 true是false否
- * @apiSuccess {Object} result.order_info.extend_order_common 订单其他信息 (返回字段参考ordercommon表)
- * @apiSuccess {Object} result.order_info.extend_order_goods 订单商品信息 (返回字段参考ordergoods表)
- * @apiSuccess {Object} result.order_info.extend_order_goods.image_240_url 商品图片完整路径
- * @apiSuccess {Object} result.order_info.extend_order_goods.goods_type_cn 商品类型名称
- * @apiSuccess {Object} result.order_info.extend_order_goods.goods_url 商品PC链接
- * @apiSuccess {Object} result.order_info.extend_member 用户信息 (返回字段参考member表)
- * @apiSuccess {String} result.order_info.invoice 发票信息
- * @apiSuccess {String} result.order_info.reciver_phone 收货人手机号
- * @apiSuccess {String} result.order_info.reciver_name 收货人姓名
- * @apiSuccess {String} result.order_info.reciver_addr 收货地址
- * @apiSuccess {String} result.order_info.order_cancel_day 自动取消订单日期
- * @apiSuccess {Object} result.order_info.express_info 物流信息
- * @apiSuccess {String} result.order_info.express_info.express_code 物流公司代码
- * @apiSuccess {String} result.order_info.express_info.express_name 物流公司名称
- * @apiSuccess {String} result.order_info.express_info.express_url 物流公司官网
- * @apiSuccess {object} result.order_info.zengpin_list 赠品列表 (返回字段参考ordergoods表)
- * @apiSuccess {object} result.order_info.goods_list 订单商品列表 (返回字段参考ordergoods表)
- * @apiSuccess {object} result.order_info.goods_count 商品数量
- * @apiSuccess {object[]} result.order_info.extend_log.order_log_list 订单操作日志列表 (返回字段参考orderlog表)
- * @apiSuccess {object} result.order_info.daddress_info 发货信息 (返回字段参考daddress表)
- * @apiSuccess {object} result.order_info.real_pay_amount 实际支付金额
- */
- public function order_info()
- {
- $order_id = intval(input('param.order_id'));
- if (!$order_id) {
- ds_json_encode(10001, lang('param_error'));
- }
- $order_model = model('order');
- $condition = array();
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_info = $order_model->getOrderInfo($condition, array('order_common', 'order_goods', 'member'));
- if (empty($order_info)) {
- ds_json_encode(10001, lang('store_order_none_existr'));
- }
- $refundreturn_model = model('refundreturn');
- $order_list = array();
- $order_list[$order_id] = $order_info;
- //订单商品的退款退货显示
- $order_list = $refundreturn_model->getGoodsRefundList($order_list, 1);
- $order_info = $order_list[$order_id];
- $refund_all = isset($order_info['refund_list'][0]) ? $order_info['refund_list'][0] : '';
- //订单全部退款商家审核状态:1为待审核,2为同意,3为不同意
- if (!empty($refund_all) && $refund_all['seller_state'] < 3) {
- $order_info['extend_refund']['refund_all'] = $refund_all;
- }
- if ($order_info['payment_time']) {
- $order_info['payment_time'] = date('Y-m-d H:i:s', $order_info['payment_time']);
- } else {
- $order_info['payment_time'] = '';
- }
- if ($order_info['finnshed_time']) {
- $order_info['finnshed_time'] = date('Y-m-d H:i:s', $order_info['finnshed_time']);
- } else {
- $order_info['finnshed_time'] = '';
- }
- if ($order_info['add_time']) {
- $order_info['add_time'] = date('Y-m-d H:i:s', $order_info['add_time']);
- } else {
- $order_info['add_time'] = '';
- }
- if ($order_info['extend_order_common']['order_message']) {
- $order_info['order_message'] = $order_info['extend_order_common']['order_message'];
- }
- if (!empty($order_info['extend_order_common']['invoice_info'])) {
- $order_info['invoice'] = $order_info['extend_order_common']['invoice_info'];
- }
- $order_info['reciver_phone'] = $order_info['extend_order_common']['reciver_info']['phone'];
- $order_info['reciver_name'] = $order_info['extend_order_common']['reciver_name'];
- $order_info['reciver_addr'] = $order_info['extend_order_common']['reciver_info']['address'];
- //显示锁定中
- $order_info['if_lock'] = $order_model->getOrderOperateState('lock', $order_info);
- //显示调整运费
- $order_info['if_modify_price'] = $order_model->getOrderOperateState('modify_price', $order_info);
- //显示调整价格
- $order_info['if_spay_price'] = $order_model->getOrderOperateState('spay_price', $order_info);
- //显示取消订单
- $order_info['if_cancel'] = $order_model->getOrderOperateState('buyer_cancel', $order_info);
- //显示发货
- $order_info['if_send'] = $order_model->getOrderOperateState('send', $order_info);
- //显示物流跟踪
- $order_info['if_deliver'] = $order_model->getOrderOperateState('deliver', $order_info);
- //显示系统自动取消订单日期
- if ($order_info['order_state'] == ORDER_STATE_NEW) {
- $order_info['order_cancel_day'] = date('Y-m-d H:i:s', strtotime($order_info['add_time']) + config('ds_config.order_auto_cancel_day') * 24 * 3600);
- }
- //显示快递信息
- if ($order_info['shipping_code'] != '') {
- $express = rkcache('express', true);
- if (isset($express[$order_info['extend_order_common']['shipping_express_id']])) {
- $order_info['express_info']['express_code'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
- $order_info['express_info']['express_name'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
- $order_info['express_info']['express_url'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_url'];
- } else {
- $order_info['express_info']['express_code'] = '';
- $order_info['express_info']['express_name'] = '';
- $order_info['express_info']['express_url'] = '';
- }
- }
- //显示系统自动收获时间
- if ($order_info['order_state'] == ORDER_STATE_SEND) {
- $order_info['order_confirm_day'] = $order_info['delay_time'] + config('ds_config.order_auto_receive_day') * 24 * 3600;
- }
- //取得订单操作日志
- $order_log_list = $order_model->getOrderlogList(array('order_id' => $order_info['order_id']), 'log_id asc');
- $order_info['extend_log']['order_log_list'] = $order_log_list;
- //如果订单已取消,取得取消原因、时间,操作人
- if ($order_info['order_state'] == ORDER_STATE_CANCEL) {
- $last_log = end($order_log_list);
- if ($last_log['log_orderstate'] == ORDER_STATE_CANCEL) {
- $order_info['close_info'] = $last_log;
- }
- }
- $order_info['chain_order_type'] = 0;
- //如果是待自提则获取提货码
- $chain_order_model = model('chain_order');
- $chain_order_info = $chain_order_model->getChainOrderInfo(array(array('order_id', '=', $order_info['order_id'])));
- if ($chain_order_info) {
- $order_info['chain_order_type'] = $chain_order_info['chain_order_type'];
- }
- foreach ($order_info['extend_order_goods'] as $value) {
- $value['image_240_url'] = goods_cthumb($value['goods_image'], 240, $value['store_id']);
- $value['goods_type_cn'] = get_order_goodstype($value['goods_type']);
- $order_info['zengpin_list'] = array();
- if ($value['goods_type'] == 5) {
- $order_info['zengpin_list'][] = $value;
- } else {
- $order_info['goods_list'][] = $value;
- }
- }
- if (empty($order_info['zengpin_list'])) {
- $order_info['goods_count'] = count($order_info['goods_list']);
- } else {
- $order_info['goods_count'] = count($order_info['goods_list']) + 1;
- }
- //优惠信息
- $order_info['promotion'] = stripslashes(strip_tags($order_info['extend_order_common']['promotion_info']));
- $order_info['voucher_code'] = $order_info['extend_order_common']['voucher_code'];
- $order_info['voucher_price'] = $order_info['extend_order_common']['voucher_price'];
- //发货信息
- if (!empty($order_info['extend_order_common']['daddress_id'])) {
- $daddress_info = model('daddress')->getAddressInfo(array('daddress_id' => $order_info['extend_order_common']['daddress_id']));
- $order_info['daddress_info'] = $daddress_info;
- }
- $order_info['real_pay_amount'] = $order_info['order_amount'] + $order_info['shipping_fee'];
- ds_json_encode(10000, '', array('order_info' => $order_info));
- }
- /**
- * @api {POST} api/Sellerorder/order_cancel 取消订单
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {String} order_id 订单id
- * @apiParam {String} reason 理由
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function order_cancel()
- {
- $order_id = intval(input('post.order_id'));
- $reason = input('post.reason');
- $order_model = model('order');
- $condition = array();
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_info = $order_model->getOrderInfo($condition);
- $if_allow = $order_model->getOrderOperateState('store_cancel', $order_info);
- if (!$if_allow) {
- ds_json_encode(10001, lang('no_right'));
- }
- try {
- Db::startTrans();
- model('order', 'logic')->changeOrderStateCancel($order_info, 'seller', $this->seller_info['seller_name'], $reason);
- } catch (\Exception $e) {
- Db::rollback();
- ds_json_encode(10001, $e->getMessage());
- }
- Db::commit();
- ds_json_encode(10000, '', 1);
- }
- /**
- * @api {POST} api/Sellerorder/order_ship_price 修改运费
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {String} order_id 订单id
- * @apiParam {String} shipping_fee 运费
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function order_ship_price()
- {
- $order_id = intval(input('post.order_id'));
- $shipping_fee = ds_price_format(input('post.shipping_fee'));
- $order_model = model('order');
- $condition = array();
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_info = $order_model->getOrderInfo($condition);
- $if_allow = $order_model->getOrderOperateState('modify_price', $order_info);
- if (!$if_allow) {
- ds_json_encode(10001, lang('no_right'));
- }
- $result = model('order', 'logic')->changeOrderShipPrice($order_info, 'seller', $this->seller_info['seller_name'], $shipping_fee);
- if (!$result['code']) {
- ds_json_encode(10001, $result['msg']);
- }
- ds_json_encode(10000, '', 1);
- }
- /**
- * @api {POST} api/Sellerorder/order_spay_price 修改商品价格
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {String} order_id 订单id
- * @apiParam {String} order_fee 商品价格
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function order_spay_price()
- {
- $order_model = model('order');
- $logic_order = model('order', 'logic');
- $order_id = intval(input('post.order_id'));
- $condition = array();
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $goods_amount = input('post.order_fee');
- $order_info = $order_model->getOrderInfo($condition);
- $if_allow = $order_model->getOrderOperateState('spay_price', $order_info);
- if (!$if_allow) {
- ds_json_encode(10001, lang('no_right'));
- }
- $info = $logic_order->changeOrderSpayPrice($order_info, 'seller', $this->seller_info['seller_name'], $goods_amount);
- if ($info['code'] == TRUE) {
- ds_json_encode(10000, lang('ds_common_op_succ'));
- } else {
- ds_json_encode(10001, lang('ds_common_op_fail'));
- }
- }
- /**
- * @api {POST} api/Sellerorder/order_deliver_send 发货
- * @apiVersion 1.0.0
- * @apiGroup Sellerorder
- *
- * @apiHeader {String} X-DS-KEY 卖家授权token
- *
- * @apiParam {Int} order_id 订单id
- * @apiParam {Int} daddress_id 发货地址id
- * @apiParam {Int} shipping_express_id 物流公司id
- * @apiParam {String} shipping_code 物流单号
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function order_deliver_send()
- {
- $order_id = intval(input('post.order_id'));
- if ($order_id <= 0) {
- ds_json_encode(10001, lang('param_error'));
- }
- $order_model = model('order');
- $condition = array();
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('store_id', '=', $this->store_info['store_id']);
- $order_info = $order_model->getOrderInfo($condition, array('order_common', 'order_goods'));
- $if_allow_send = intval($order_info['lock_state']) || !in_array($order_info['order_state'], array(ORDER_STATE_PAY, ORDER_STATE_SEND));
- if ($if_allow_send) {
- ds_json_encode(10001, lang('no_right'));
- }
- //由于PC 端可以修改收货信息,手机端不可,则使用默认客户收货信息。
- $extend = array(
- 'reciver_name' => $order_info['extend_order_common']['reciver_name'],
- 'reciver_info' => serialize($order_info['extend_order_common']['reciver_info']),
- 'deliver_explain' => $order_info['extend_order_common']['deliver_explain'],
- 'daddress_id' => !empty(input('post.daddress_id')) ? input('post.daddress_id') : $order_info['extend_order_common']['daddress_id'],
- 'shipping_express_id' => !empty(input('post.shipping_express_id')) ? input('post.shipping_express_id') : $order_info['extend_order_common']['shipping_express_id'],
- 'shipping_code' => !empty(input('post.shipping_code')) ? input('post.shipping_code') : $order_info['shipping_code'],
- );
- $result = model('order', 'logic')->changeOrderSend($order_info, 'seller', $this->seller_info['seller_name'], $extend);
- if (!$result['code']) {
- ds_json_encode(10001, $result['msg']);
- }
- ds_json_encode(10000, lang('ds_common_op_succ'), 1);
- }
- }
|