Memberorder.php 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. use think\facade\Db;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 订单控制器
  15. */
  16. class Memberorder extends MobileMember {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberorder.lang.php');
  20. }
  21. /**
  22. * @api {POST} api/Memberorder/order_list 订单列表
  23. * @apiVersion 1.0.0
  24. * @apiGroup MemberOrder
  25. *
  26. * @apiHeader {String} X-DS-KEY 用户授权token
  27. *
  28. * @apiParam {Int} page 当前页数
  29. * @apiParam {Int} state_type 订单状态
  30. * @apiParam {String} order_key 订单编号
  31. * @apiParam {Int} per_page 每页数量
  32. *
  33. * @apiSuccess {String} code 返回码,10000为成功
  34. * @apiSuccess {String} message 返回消息
  35. * @apiSuccess {Object} result 返回数据
  36. * @apiSuccess {Object[]} result.order_group_list 订单组列表
  37. * @apiSuccess {Int} result.order_group_list.add_time 添加时间
  38. * @apiSuccess {Object[]} result.order_group_list.order_list 订单列表
  39. * @apiSuccess {Int} result.order_group_list.order_list.add_time 退款添加时间
  40. * @apiSuccess {String} result.order_group_list.order_list.buyer_email 买家邮箱
  41. * @apiSuccess {Int} result.order_group_list.order_list.buyer_id 买家ID
  42. * @apiSuccess {String} result.order_group_list.order_list.buyer_name 买家用户名
  43. * @apiSuccess {Int} result.order_group_list.order_list.delay_time 自动收货时间
  44. * @apiSuccess {Int} result.order_group_list.order_list.delete_state 订单删除状态 0:未删除 1:放入回收站 2:彻底删除
  45. * @apiSuccess {Int} result.order_group_list.order_list.evaluation_state 评论状态
  46. * @apiSuccess {Object} result.order_group_list.order_list.extend_order_common 订单公共信息
  47. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.daddress_id 发货地址ID
  48. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.deliver_explain 订单发货备注
  49. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.evalseller_state 卖家是否已评价买家
  50. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.evalseller_time 卖家评价买家的时间
  51. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.evaluation_time 评价时间
  52. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.invoice_info 订单发票信息
  53. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.order_id 订单ID
  54. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.order_message 订单留言
  55. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.order_pointscount 订单赠送积分
  56. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.promotion_info 订单促销信息备注
  57. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.reciver_city_id 收货人市级ID
  58. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info 收货人其它信息
  59. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.address 收货地址
  60. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.area 收货地区
  61. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.mob_phone 收货人手机号
  62. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.phone 收货人联系号码
  63. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.street 街道地址
  64. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.tel_phone 座机号
  65. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_name 收货人姓名
  66. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.reciver_province_id 收货地区省ID
  67. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.shipping_express_id 配送公司ID
  68. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.shipping_time 发货时间
  69. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.store_id 店铺ID
  70. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.voucher_code 代金券编码
  71. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.voucher_price 代金券面额
  72. * @apiSuccess {Object} result.order_group_list.order_list.extend_store 店铺信息
  73. * @apiSuccess {String} result.order_group_list.order_list.extend_store.area_info 店铺地区
  74. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.bind_all_gc 是否绑定所有分类 0否1是
  75. * @apiSuccess {String} result.order_group_list.order_list.extend_store.deliver_region 店铺默认配送区域
  76. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.goods_count 商品数量
  77. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.grade_id 等级ID
  78. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.is_platform_store 是否自营店 0否1是
  79. * @apiSuccess {String} result.order_group_list.order_list.extend_store.mb_sliders 手机店铺轮播图序列化字符串
  80. * @apiSuccess {String} result.order_group_list.order_list.extend_store.mb_title_img 手机店铺背景图
  81. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.member_id 店铺用户ID
  82. * @apiSuccess {String} result.order_group_list.order_list.extend_store.member_name 店铺用户名
  83. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.region_id 店铺地区ID
  84. * @apiSuccess {String} result.order_group_list.order_list.extend_store.seller_name 卖家用户名
  85. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_address 店铺地址
  86. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_addtime 店铺添加时间
  87. * @apiSuccess {Object[]} result.order_group_list.order_list.extend_store.store_aftersales 售后列表
  88. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_aftersales.name 售后名称
  89. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_aftersales.num 售后账号
  90. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_aftersales.type 售后类型 1QQ2旺旺3站内IM
  91. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_avaliable_deposit 可用保证金
  92. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_avaliable_money 可用预存款
  93. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_avatar 店铺头像
  94. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_banner 店铺背景图
  95. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_baozh 是否已缴保证金 0否1是
  96. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_bill_time 上次结算时间
  97. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_close_info 店铺关闭原因
  98. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_collect 店铺收藏数量
  99. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_company_name 店铺公司名称
  100. * @apiSuccess {Object} result.order_group_list.order_list.extend_store.store_credit 店铺信用信息
  101. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_deliverycredit 发货速度信息
  102. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit.store_deliverycredit.credit 发货速度评分
  103. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_deliverycredit.text 发货速度描述
  104. * @apiSuccess {Object} result.order_group_list.order_list.extend_store.store_credit.store_desccredit 描述相符信息
  105. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit.store_desccredit.credit 描述相符评分
  106. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_desccredit.text 描述相符描述
  107. * @apiSuccess {Object} result.order_group_list.order_list.extend_store.store_credit.store_servicecredit 服务态度信息
  108. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit.store_servicecredit.credit 服务态度评分
  109. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_servicecredit.text 服务态度描述
  110. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit_average 平均评分
  111. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit_percent 好评率
  112. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_deliverycredit 发货速度评分
  113. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_desccredit 描述相符评分
  114. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_description 店铺SEO描述
  115. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_endtime 店铺到期时间
  116. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_erxiaoshi 是否两小时发货 0否1是
  117. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_free_price 超出该金额免运费 0未设置
  118. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_free_time 商家配送时间
  119. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_freeze_deposit 冻结保证金
  120. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_freeze_money 冻结预存款
  121. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_huodaofk 是否支持货到付款 0否1是
  122. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_id 店铺ID
  123. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_keywords 店铺SEO关键字
  124. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_latitude 纬度
  125. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_logo 店铺logo
  126. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_longitude 经度
  127. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_mainbusiness 主营商品
  128. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_mgdiscount 序列化会员等级折扣
  129. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_mgdiscount_state 店铺是否开启序列化会员等级折扣 0否1是
  130. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_name 店铺名称
  131. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_payable_deposit 应缴保证金
  132. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_phone 店铺电话
  133. * @apiSuccess {Object[]} result.order_group_list.order_list.extend_store.store_presales 售前列表
  134. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_presales.name 售前名称
  135. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_presales.num 售前账号
  136. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_presales.type 售前类型 1QQ2旺旺3站内IM
  137. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_printexplain 打印订单页面下方说明文字
  138. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_qq 店铺QQ
  139. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_qtian 是否支持7天退换 0否1是
  140. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_recommend 推荐店铺 0否1是
  141. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_sales 销量
  142. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_servicecredit 服务态度评分
  143. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_shiti 实体店认证 0否1是
  144. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_shiyong 是否支持试用 0否1是
  145. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_slide 店铺幻灯片
  146. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_slide_url 店铺幻灯片链接
  147. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_sort 店铺排序
  148. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_state 店铺状态 0关闭,1开启,2审核中
  149. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_tuihuo 是否支持退货承诺 0否1是
  150. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_vrcode_prefix 商家兑换码前缀
  151. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_workingtime 工作时间
  152. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_ww 店铺旺旺
  153. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_xiaoxie 是否消协保证 0否1是
  154. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_zhping 是否正品保障 0否1是
  155. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_zip 邮政编码
  156. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.storeclass_id 店铺分类ID
  157. * @apiSuccess {Int} result.order_group_list.order_list.finnshed_time 订单完成时间
  158. * @apiSuccess {Float} result.order_group_list.order_list.goods_amount 商品总额
  159. * @apiSuccess {Int} result.order_group_list.order_list.if_cancel 是否可取消 true是false否
  160. * @apiSuccess {Int} result.order_group_list.order_list.if_delete 是否可删除 true是false否
  161. * @apiSuccess {Int} result.order_group_list.order_list.if_deliver 是否可发货 true是false否
  162. * @apiSuccess {Int} result.order_group_list.order_list.if_evaluation 是否可评价 true是false否
  163. * @apiSuccess {Int} result.order_group_list.order_list.if_lock 是否被锁定 true是false否
  164. * @apiSuccess {Int} result.order_group_list.order_list.if_receive 是否可收货 true是false否
  165. * @apiSuccess {Int} result.order_group_list.order_list.if_refund_cancel 是否可全部退款 true是false否
  166. * @apiSuccess {Int} result.order_group_list.order_list.lock_state 锁定状态:0:正常,大于0:锁定
  167. * @apiSuccess {Int} result.order_group_list.order_list.ob_no 结算单号
  168. * @apiSuccess {Float} result.order_group_list.order_list.order_amount 订单总金额
  169. * @apiSuccess {Int} result.order_group_list.order_list.order_from 订单来源,1:PC 2:手机
  170. * @apiSuccess {Int} result.order_group_list.order_list.order_id 订单ID
  171. * @apiSuccess {String} result.order_group_list.order_list.order_sn 订单编号
  172. * @apiSuccess {Int} result.order_group_list.order_list.order_state 订单状态
  173. * @apiSuccess {Int} result.order_group_list.order_list.order_type 订单类型
  174. * @apiSuccess {String} result.order_group_list.order_list.pay_sn 支付单号
  175. * @apiSuccess {String} result.order_group_list.order_list.payment_code 支付方式代码
  176. * @apiSuccess {String} result.order_group_list.order_list.payment_name 支付方式名称
  177. * @apiSuccess {Int} result.order_group_list.order_list.payment_time 支付时间
  178. * @apiSuccess {Float} result.order_group_list.order_list.pd_amount 使用预存款金额
  179. * @apiSuccess {Float} result.order_group_list.order_list.rcb_amount 使用充值卡金额
  180. * @apiSuccess {Float} result.order_group_list.order_list.refund_amount 退款金额
  181. * @apiSuccess {Int} result.order_group_list.order_list.refund_state 退款状态 0:无退款 1:部分退款 2:全部退款
  182. * @apiSuccess {String} result.order_group_list.order_list.shipping_code 发货运单号
  183. * @apiSuccess {Float} result.order_group_list.order_list.shipping_fee 运费
  184. * @apiSuccess {String} result.order_group_list.order_list.state_desc 状态描述
  185. * @apiSuccess {Int} result.order_group_list.order_list.store_id 店铺ID
  186. * @apiSuccess {String} result.order_group_list.order_list.store_name 店铺名称
  187. * @apiSuccess {Int} result.order_group_list.pay_amount 支付时间
  188. * @apiSuccess {String} result.order_group_list.pay_sn 支付单号
  189. * @apiSuccess {Int} result.page_total 总页数
  190. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  191. */
  192. public function order_list() {
  193. $order_model = model('order');
  194. $condition = array();
  195. $condition = $this->order_type_no(input('post.state_type'));
  196. $condition[] = array('buyer_id', '=', $this->member_info['member_id']);
  197. $condition[] = array('delete_state', '=', 0); #订单未被删除
  198. $order_sn = input('post.order_key');
  199. if ($order_sn != '') {
  200. $condition[] = array('order_sn', 'like', '%' . $order_sn . '%');
  201. }
  202. $keyword = input('post.keyword');
  203. if ($keyword != '') {
  204. $goodscondition = array();
  205. $goodscondition[] = array('goods_name','like','%' . trim($keyword) . '%');
  206. $orderidarray = $order_model->getOrdergoodsList($goodscondition, 'order_id');
  207. $orderidarray = array_column($orderidarray, 'order_id');
  208. $orderstr = implode(',',$orderidarray);
  209. $condition[] = array('order_id','in',$orderstr);
  210. }
  211. $refundreturn_model = model('refundreturn');
  212. $order_list_array = $order_model->getOrderList($condition, 5, '*', 'order_id desc', 0, array('order_common', 'order_goods', 'store'));
  213. $order_list_array = $refundreturn_model->getGoodsRefundList($order_list_array, 1); //订单商品的退款退货显示
  214. $order_group_list = $order_pay_sn_array = array();
  215. foreach ($order_list_array as $value) {
  216. //$value['zengpin_list'] = false;
  217. //显示取消订单
  218. $value['if_cancel'] = $order_model->getOrderOperateState('buyer_cancel', $value);
  219. //显示退款取消订单
  220. $value['if_refund_cancel'] = $order_model->getOrderOperateState('refund_cancel', $value);
  221. //显示收货
  222. $value['if_receive'] = $order_model->getOrderOperateState('receive', $value);
  223. //显示投诉
  224. $order_info['if_complain'] = $order_model->getOrderOperateState('complain', $value);
  225. //显示锁定中
  226. $value['if_lock'] = $order_model->getOrderOperateState('lock', $value);
  227. //显示物流跟踪
  228. $value['if_deliver'] = $order_model->getOrderOperateState('deliver', $value);
  229. $value['if_evaluation'] = $order_model->getOrderOperateState('evaluation', $value);
  230. $value['if_delete'] = $order_model->getOrderOperateState('delete', $value);
  231. $value['ownshop'] = true;
  232. $value['zengpin_list'] = false;
  233. if (isset($value['extend_order_goods'])) {
  234. foreach ($value['extend_order_goods'] as $val) {
  235. $val['image_240_url'] = goods_cthumb($val['goods_image'], 240, $val['store_id']);
  236. $val['image_url'] = goods_cthumb($val['goods_image'], 240, $val['store_id']);
  237. $val['goods_type_cn'] = get_order_goodstype($val['goods_type']);
  238. if ($val['goods_type'] == 5) {
  239. $value['zengpin_list'][] = $val;
  240. }
  241. }
  242. }
  243. //商品图
  244. if (isset($value['extend_order_goods'])) {
  245. foreach ($value['extend_order_goods'] as $k => $goods_info) {
  246. if ($goods_info['goods_type'] == 5) {
  247. unset($value['extend_order_goods'][$k]);
  248. } else {
  249. $value['extend_order_goods'][$k] = $goods_info;
  250. $value['extend_order_goods'][$k]['goods_image_url'] = goods_cthumb($goods_info['goods_image'], 240, $value['store_id']);
  251. }
  252. }
  253. }
  254. $order_group_list[$value['pay_sn']]['order_list'][] = $value;
  255. //如果有在线支付且未付款的订单则显示合并付款链接
  256. if ($value['order_state'] == ORDER_STATE_NEW || $value['order_state'] == ORDER_STATE_DEPOSIT || $value['order_state'] == ORDER_STATE_REST) {
  257. if (!isset($order_group_list[$value['pay_sn']]['pay_amount'])) {
  258. $order_group_list[$value['pay_sn']]['pay_amount'] = 0;
  259. }
  260. $order_group_list[$value['pay_sn']]['pay_amount'] += ($value['order_state'] == ORDER_STATE_DEPOSIT?$value['presell_deposit_amount']:($value['order_amount'] - $value['presell_deposit_amount'] + $value['presell_rcb_amount'] + $value['presell_pd_amount'])) - $value['rcb_amount'] - $value['pd_amount'];
  261. }
  262. $order_group_list[$value['pay_sn']]['add_time'] = $value['add_time'];
  263. //记录一下pay_sn,后面需要查询支付单表
  264. $order_pay_sn_array[] = $value['pay_sn'];
  265. }
  266. $new_order_group_list = array();
  267. foreach ($order_group_list as $key => $value) {
  268. $value['pay_sn'] = strval($key);
  269. $new_order_group_list[] = $value;
  270. }
  271. $result = array_merge(array('order_group_list' => $new_order_group_list), mobile_page($order_model->page_info));
  272. ds_json_encode(10000, '', $result);
  273. }
  274. private function order_type_no($stage) {
  275. $condition = array();
  276. switch ($stage) {
  277. case 'state_new':
  278. $condition[] = array('order_state', '=', '10');
  279. break;
  280. case 'state_pay':
  281. $condition[] = array('order_state', '=', '20');
  282. break;
  283. case 'state_send':
  284. $condition[] = array('order_state', '=', '30');
  285. break;
  286. case 'state_noeval':
  287. $condition[] = array('order_state', '=', '40');
  288. $condition[] = array('refund_state','=',0);
  289. $condition[] = array('evaluation_state', '=', '0');
  290. break;
  291. }
  292. return $condition;
  293. }
  294. /**
  295. * @api {POST} api/Memberorder/order_cancel 取消订单
  296. * @apiVersion 1.0.0
  297. * @apiGroup MemberOrder
  298. *
  299. * @apiHeader {String} X-DS-KEY 用户授权token
  300. *
  301. * @apiParam {Int} order_id 订单号
  302. *
  303. * @apiSuccess {String} code 返回码,10000为成功
  304. * @apiSuccess {String} message 返回消息
  305. */
  306. public function order_cancel() {
  307. $order_model = model('order');
  308. $logic_order = model('order', 'logic');
  309. $order_id = intval(input('post.order_id'));
  310. $condition = array();
  311. $condition[] = array('order_id','=',$order_id);
  312. $condition[] = array('buyer_id','=',$this->member_info['member_id']);
  313. //$condition[] = array('order_type','=',1);
  314. $order_info = $order_model->getOrderInfo($condition);
  315. $if_allow = $order_model->getOrderOperateState('buyer_cancel', $order_info);
  316. if (!$if_allow) {
  317. ds_json_encode(10001, lang('have_right_operate'));
  318. }
  319. try{
  320. Db::startTrans();
  321. $logic_order->changeOrderStateCancel($order_info, 'buyer', $this->member_info['member_name'], lang('other_reason'));
  322. } catch (\Exception $e) {
  323. Db::rollback();
  324. ds_json_encode(10001, $e->getMessage());
  325. }
  326. Db::commit();
  327. ds_json_encode(10000, '', 1);
  328. }
  329. /**
  330. * @api {POST} api/Memberorder/order_receive 订单确认收货
  331. * @apiVersion 1.0.0
  332. * @apiGroup MemberOrder
  333. *
  334. * @apiHeader {String} X-DS-KEY 用户授权token
  335. *
  336. * @apiParam {Int} order_id 订单号
  337. *
  338. * @apiSuccess {String} code 返回码,10000为成功
  339. * @apiSuccess {String} message 返回消息
  340. */
  341. public function order_receive() {
  342. $order_model = model('order');
  343. $logic_order = model('order', 'logic');
  344. $order_id = intval(input('post.order_id'));
  345. $condition = array();
  346. $condition[] = array('order_id','=',$order_id);
  347. $condition[] = array('buyer_id','=',$this->member_info['member_id']);
  348. $order_info = $order_model->getOrderInfo($condition);
  349. $if_allow = $order_model->getOrderOperateState('receive', $order_info);
  350. if (!$if_allow) {
  351. ds_json_encode(10001, lang('have_right_operate'));
  352. }
  353. $result = $logic_order->changeOrderStateReceive($order_info, 'buyer', $this->member_info['member_name'], lang('receive_goods'));
  354. if (!$result['code']) {
  355. ds_json_encode(10001, $result['msg']);
  356. } else {
  357. ds_json_encode(10000, '', 1);
  358. }
  359. }
  360. /**
  361. * 回收站
  362. */
  363. public function order_delete() {
  364. $order_model = model('order');
  365. $logic_order = model('order', 'logic');
  366. $order_id = intval(input('post.order_id'));
  367. $condition = array();
  368. $condition[] = array('order_id','=',$order_id);
  369. $condition[] = array('buyer_id','=',$this->member_info['member_id']);
  370. $order_info = $order_model->getOrderInfo($condition);
  371. $if_allow = $order_model->getOrderOperateState('delete', $order_info);
  372. if (!$if_allow) {
  373. ds_json_encode(10001, lang('have_right_operate'));
  374. }
  375. $result = $logic_order->changeOrderStateRecycle($order_info, 'buyer', 'delete');
  376. if (!$result['code']) {
  377. ds_json_encode(10001, $result['msg']);
  378. } else {
  379. ds_json_encode(10000, '', 1);
  380. }
  381. }
  382. /**
  383. * @api {POST} api/Memberorder/search_deliver 物流跟踪
  384. * @apiVersion 1.0.0
  385. * @apiGroup Memberorder
  386. *
  387. * @apiHeader {String} X-DS-KEY 用户授权token
  388. *
  389. * @apiParam {String} order_id 订单id
  390. *
  391. * @apiSuccess {String} code 返回码,10000为成功
  392. * @apiSuccess {String} message 返回消息
  393. * @apiSuccess {Object} result 返回数据
  394. * @apiSuccess {String} result.express_name 物流公司名称
  395. * @apiSuccess {String} result.shipping_code 物流单号
  396. * @apiSuccess {Object[]} result.deliver_info 物流数据
  397. * @apiSuccess {String} result.deliver_info.context 内容
  398. * @apiSuccess {String} result.deliver_info.time 时间
  399. */
  400. public function search_deliver() {
  401. $order_id = intval(input('post.order_id'));
  402. if ($order_id <= 0) {
  403. ds_json_encode(10001, lang('member_order_none_exist'));
  404. }
  405. $order_model = model('order');
  406. $condition[] = array('order_id','=',$order_id);
  407. $condition[] = array('buyer_id','=',$this->member_info['member_id']);
  408. $order_info = $order_model->getOrderInfo($condition, array('order_common', 'order_goods'));
  409. if (empty($order_info) || !in_array($order_info['order_state'], array(ORDER_STATE_SEND, ORDER_STATE_SUCCESS))) {
  410. ds_json_encode(10001, lang('member_order_none_exist'));
  411. }
  412. $express = rkcache('express', true);
  413. if(isset($express[$order_info['extend_order_common']['shipping_express_id']])){
  414. $express_code = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
  415. $express_name = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
  416. $deliver_info = $this->_get_express($express_code, $order_info['shipping_code'], $order_info['extend_order_common']['reciver_info']['phone']);
  417. }else{
  418. $express_name='';
  419. $deliver_info=array();
  420. }
  421. ds_json_encode(10000, '', array('express_name' => $express_name, 'shipping_code' => $order_info['shipping_code'], 'deliver_info' => $deliver_info));
  422. }
  423. /**
  424. * @api {POST} api/Memberorder/order_info 订单详情
  425. * @apiVersion 1.0.0
  426. * @apiGroup MemberOrder
  427. *
  428. * @apiHeader {String} X-DS-KEY 用户授权token
  429. *
  430. * @apiParam {Int} order_id 订单ID
  431. *
  432. * @apiSuccess {String} code 返回码,10000为成功
  433. * @apiSuccess {String} message 返回消息
  434. * @apiSuccess {Object} result 返回数据
  435. * @apiSuccess {Object} result.order_info 订单信息
  436. * @apiSuccess {Int} result.order_info.add_time 退款添加时间
  437. * @apiSuccess {String} result.order_info.buyer_email 买家邮箱
  438. * @apiSuccess {Int} result.order_info.buyer_id 买家ID
  439. * @apiSuccess {String} result.order_info.buyer_name 买家用户名
  440. * @apiSuccess {Int} result.order_info.delay_time 自动收货时间
  441. * @apiSuccess {Int} result.order_info.delete_state 订单删除状态 0:未删除 1:放入回收站 2:彻底删除
  442. * @apiSuccess {Int} result.order_info.evaluation_state 评论状态
  443. * @apiSuccess {Object} result.order_info.extend_order_common 订单公共信息
  444. * @apiSuccess {Int} result.order_info.extend_order_common.daddress_id 发货地址ID
  445. * @apiSuccess {String} result.order_info.extend_order_common.deliver_explain 订单发货备注
  446. * @apiSuccess {Int} result.order_info.extend_order_common.evalseller_state 卖家是否已评价买家
  447. * @apiSuccess {Int} result.order_info.extend_order_common.evalseller_time 卖家评价买家的时间
  448. * @apiSuccess {Int} result.order_info.extend_order_common.evaluation_time 评价时间
  449. * @apiSuccess {String} result.order_info.extend_order_common.invoice_info 订单发票信息
  450. * @apiSuccess {Int} result.order_info.extend_order_common.order_id 订单ID
  451. * @apiSuccess {String} result.order_info.extend_order_common.order_message 订单留言
  452. * @apiSuccess {Int} result.order_info.extend_order_common.order_pointscount 订单赠送积分
  453. * @apiSuccess {String} result.order_info.extend_order_common.promotion_info 订单促销信息备注
  454. * @apiSuccess {Int} result.order_info.extend_order_common.reciver_city_id 收货人市级ID
  455. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info 收货人其它信息
  456. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.address 收货地址
  457. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.area 收货地区
  458. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.mob_phone 收货人手机号
  459. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.phone 收货人联系号码
  460. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.street 街道地址
  461. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.tel_phone 座机号
  462. * @apiSuccess {String} result.order_info.extend_order_common.reciver_name 收货人姓名
  463. * @apiSuccess {Int} result.order_info.extend_order_common.reciver_province_id 收货地区省ID
  464. * @apiSuccess {Int} result.order_info.extend_order_common.shipping_express_id 配送公司ID
  465. * @apiSuccess {Int} result.order_info.extend_order_common.shipping_time 发货时间
  466. * @apiSuccess {Int} result.order_info.extend_order_common.store_id 店铺ID
  467. * @apiSuccess {String} result.order_info.extend_order_common.voucher_code 代金券编码
  468. * @apiSuccess {Int} result.order_info.extend_order_common.voucher_price 代金券面额
  469. * @apiSuccess {Object} result.order_info.extend_store 店铺信息
  470. * @apiSuccess {String} result.order_info.extend_store.area_info 店铺地区
  471. * @apiSuccess {Int} result.order_info.extend_store.bind_all_gc 是否绑定所有分类 0否1是
  472. * @apiSuccess {String} result.order_info.extend_store.deliver_region 店铺默认配送区域
  473. * @apiSuccess {Int} result.order_info.extend_store.goods_count 商品数量
  474. * @apiSuccess {Int} result.order_info.extend_store.grade_id 等级ID
  475. * @apiSuccess {Int} result.order_info.extend_store.is_platform_store 是否自营店 0否1是
  476. * @apiSuccess {String} result.order_info.extend_store.mb_sliders 手机店铺轮播图序列化字符串
  477. * @apiSuccess {String} result.order_info.extend_store.mb_title_img 手机店铺背景图
  478. * @apiSuccess {Int} result.order_info.extend_store.member_id 店铺用户ID
  479. * @apiSuccess {String} result.order_info.extend_store.member_name 店铺用户名
  480. * @apiSuccess {Int} result.order_info.extend_store.region_id 店铺地区ID
  481. * @apiSuccess {String} result.order_info.extend_store.seller_name 卖家用户名
  482. * @apiSuccess {String} result.order_info.extend_store.store_address 店铺地址
  483. * @apiSuccess {Int} result.order_info.extend_store.store_addtime 店铺添加时间
  484. * @apiSuccess {Object[]} result.order_info.extend_store.store_aftersales 售后列表
  485. * @apiSuccess {String} result.order_info.extend_store.store_aftersales.name 售后名称
  486. * @apiSuccess {String} result.order_info.extend_store.store_aftersales.num 售后账号
  487. * @apiSuccess {String} result.order_info.extend_store.store_aftersales.type 售后类型 1QQ2旺旺3站内IM
  488. * @apiSuccess {Float} result.order_info.extend_store.store_avaliable_deposit 可用保证金
  489. * @apiSuccess {Float} result.order_info.extend_store.store_avaliable_money 可用预存款
  490. * @apiSuccess {String} result.order_info.extend_store.store_avatar 店铺头像
  491. * @apiSuccess {String} result.order_info.extend_store.store_banner 店铺背景图
  492. * @apiSuccess {Int} result.order_info.extend_store.store_baozh 是否已缴保证金 0否1是
  493. * @apiSuccess {Int} result.order_info.extend_store.store_bill_time 上次结算时间
  494. * @apiSuccess {String} result.order_info.extend_store.store_close_info 店铺关闭原因
  495. * @apiSuccess {Int} result.order_info.extend_store.store_collect 店铺收藏数量
  496. * @apiSuccess {String} result.order_info.extend_store.store_company_name 店铺公司名称
  497. * @apiSuccess {Object} result.order_info.extend_store.store_credit 店铺信用信息
  498. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_deliverycredit 发货速度信息
  499. * @apiSuccess {Int} result.order_info.extend_store.store_credit.store_deliverycredit.credit 发货速度评分
  500. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_deliverycredit.text 发货速度描述
  501. * @apiSuccess {Object} result.order_info.extend_store.store_credit.store_desccredit 描述相符信息
  502. * @apiSuccess {Int} result.order_info.extend_store.store_credit.store_desccredit.credit 描述相符评分
  503. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_desccredit.text 描述相符描述
  504. * @apiSuccess {Object} result.order_info.extend_store.store_credit.store_servicecredit 服务态度信息
  505. * @apiSuccess {Int} result.order_info.extend_store.store_credit.store_servicecredit.credit 服务态度评分
  506. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_servicecredit.text 服务态度描述
  507. * @apiSuccess {Int} result.order_info.extend_store.store_credit_average 平均评分
  508. * @apiSuccess {Int} result.order_info.extend_store.store_credit_percent 好评率
  509. * @apiSuccess {Int} result.order_info.extend_store.store_deliverycredit 发货速度评分
  510. * @apiSuccess {Int} result.order_info.extend_store.store_desccredit 描述相符评分
  511. * @apiSuccess {String} result.order_info.extend_store.store_description 店铺SEO描述
  512. * @apiSuccess {Int} result.order_info.extend_store.store_endtime 店铺到期时间
  513. * @apiSuccess {Int} result.order_info.extend_store.store_erxiaoshi 是否两小时发货 0否1是
  514. * @apiSuccess {Int} result.order_info.extend_store.store_free_price 超出该金额免运费 0未设置
  515. * @apiSuccess {Int} result.order_info.extend_store.store_free_time 商家配送时间
  516. * @apiSuccess {Float} result.order_info.extend_store.store_freeze_deposit 冻结保证金
  517. * @apiSuccess {Float} result.order_info.extend_store.store_freeze_money 冻结预存款
  518. * @apiSuccess {Int} result.order_info.extend_store.store_huodaofk 是否支持货到付款 0否1是
  519. * @apiSuccess {Int} result.order_info.extend_store.store_id 店铺ID
  520. * @apiSuccess {String} result.order_info.extend_store.store_keywords 店铺SEO关键字
  521. * @apiSuccess {String} result.order_info.extend_store.store_latitude 纬度
  522. * @apiSuccess {String} result.order_info.extend_store.store_logo 店铺logo
  523. * @apiSuccess {String} result.order_info.extend_store.store_longitude 经度
  524. * @apiSuccess {String} result.order_info.extend_store.store_mainbusiness 主营商品
  525. * @apiSuccess {String} result.order_info.extend_store.store_mgdiscount 序列化会员等级折扣
  526. * @apiSuccess {Int} result.order_info.extend_store.store_mgdiscount_state 店铺是否开启序列化会员等级折扣 0否1是
  527. * @apiSuccess {String} result.order_info.extend_store.store_name 店铺名称
  528. * @apiSuccess {Float} result.order_info.extend_store.store_payable_deposit 应缴保证金
  529. * @apiSuccess {String} result.order_info.extend_store.store_phone 店铺电话
  530. * @apiSuccess {Object[]} result.order_info.extend_store.store_presales 售前列表
  531. * @apiSuccess {String} result.order_info.extend_store.store_presales.name 售前名称
  532. * @apiSuccess {String} result.order_info.extend_store.store_presales.num 售前账号
  533. * @apiSuccess {String} result.order_info.extend_store.store_presales.type 售前类型 1QQ2旺旺3站内IM
  534. * @apiSuccess {String} result.order_info.extend_store.store_printexplain 打印订单页面下方说明文字
  535. * @apiSuccess {String} result.order_info.extend_store.store_qq 店铺QQ
  536. * @apiSuccess {Int} result.order_info.extend_store.store_qtian 是否支持7天退换 0否1是
  537. * @apiSuccess {Int} result.order_info.extend_store.store_recommend 推荐店铺 0否1是
  538. * @apiSuccess {Int} result.order_info.extend_store.store_sales 销量
  539. * @apiSuccess {Int} result.order_info.extend_store.store_servicecredit 服务态度评分
  540. * @apiSuccess {Int} result.order_info.extend_store.store_shiti 实体店认证 0否1是
  541. * @apiSuccess {Int} result.order_info.extend_store.store_shiyong 是否支持试用 0否1是
  542. * @apiSuccess {String} result.order_info.extend_store.store_slide 店铺幻灯片
  543. * @apiSuccess {String} result.order_info.extend_store.store_slide_url 店铺幻灯片链接
  544. * @apiSuccess {Int} result.order_info.extend_store.store_sort 店铺排序
  545. * @apiSuccess {Int} result.order_info.extend_store.store_state 店铺状态 0关闭,1开启,2审核中
  546. * @apiSuccess {Int} result.order_info.extend_store.store_tuihuo 是否支持退货承诺 0否1是
  547. * @apiSuccess {String} result.order_info.extend_store.store_vrcode_prefix 商家兑换码前缀
  548. * @apiSuccess {String} result.order_info.extend_store.store_workingtime 工作时间
  549. * @apiSuccess {String} result.order_info.extend_store.store_ww 店铺旺旺
  550. * @apiSuccess {Int} result.order_info.extend_store.store_xiaoxie 是否消协保证 0否1是
  551. * @apiSuccess {Int} result.order_info.extend_store.store_zhping 是否正品保障 0否1是
  552. * @apiSuccess {String} result.order_info.extend_store.store_zip 邮政编码
  553. * @apiSuccess {Int} result.order_info.extend_store.storeclass_id 店铺分类ID
  554. * @apiSuccess {Int} result.order_info.finnshed_time 订单完成时间
  555. * @apiSuccess {Float} result.order_info.goods_amount 商品总额
  556. * @apiSuccess {Int} result.order_info.goods_count 商品数量
  557. * @apiSuccess {Object[]} result.order_info.goods_list 商品列表
  558. * @apiSuccess {Int} result.order_info.goods_list.buyer_id 买家ID
  559. * @apiSuccess {Float} result.order_info.goods_list.commis_rate 佣金比例
  560. * @apiSuccess {Int} result.order_info.goods_list.gc_id 分类ID
  561. * @apiSuccess {Int} result.order_info.goods_list.goods_id 商品ID
  562. * @apiSuccess {String} result.order_info.goods_list.goods_image 商品图片
  563. * @apiSuccess {String} result.order_info.goods_list.goods_name 商品名称
  564. * @apiSuccess {Int} result.order_info.goods_list.goods_num 购买数量
  565. * @apiSuccess {Float} result.order_info.goods_list.goods_pay_price 实际支付金额
  566. * @apiSuccess {Float} result.order_info.goods_list.goods_price 商品金额
  567. * @apiSuccess {Int} result.order_info.goods_list.goods_type 商品类型 1默认2抢购商品3秒杀商品4组合套装5赠品6拼团7会员等级折扣
  568. * @apiSuccess {Int} result.order_info.goods_list.order_id 订单ID
  569. * @apiSuccess {Int} result.order_info.goods_list.promotions_id 促销ID
  570. * @apiSuccess {Int} result.order_info.goods_list.rec_id 订单商品ID
  571. * @apiSuccess {Int} result.order_info.goods_list.store_id 店铺ID
  572. * @apiSuccess {Int} result.order_info.if_cancel 是否可取消 true是false否
  573. * @apiSuccess {Int} result.order_info.if_delete 是否可删除 true是false否
  574. * @apiSuccess {Int} result.order_info.if_deliver 是否显示物流跟踪 true是false否
  575. * @apiSuccess {Int} result.order_info.if_evaluation 是否可评价 true是false否
  576. * @apiSuccess {Int} result.order_info.if_lock 是否被锁定 true是false否
  577. * @apiSuccess {Int} result.order_info.if_receive 是否可收货 true是false否
  578. * @apiSuccess {Int} result.order_info.if_refund_cancel 是否可全部退款 true是false否
  579. * @apiSuccess {Int} result.order_info.lock_state 锁定状态:0:正常,大于0:锁定
  580. * @apiSuccess {Int} result.order_info.ob_no 结算单号
  581. * @apiSuccess {Float} result.order_info.order_amount 订单总金额
  582. * @apiSuccess {Int} result.order_info.order_from 订单来源,1:PC 2:手机
  583. * @apiSuccess {Int} result.order_info.order_id 订单ID
  584. * @apiSuccess {String} result.order_info.order_sn 订单编号
  585. * @apiSuccess {Int} result.order_info.order_state 订单状态
  586. * @apiSuccess {Int} result.order_info.order_type 订单类型
  587. * @apiSuccess {String} result.order_info.pay_sn 支付单号
  588. * @apiSuccess {String} result.order_info.payment_code 支付方式代码
  589. * @apiSuccess {String} result.order_info.payment_name 支付方式名称
  590. * @apiSuccess {Int} result.order_info.payment_time 支付时间
  591. * @apiSuccess {Float} result.order_info.pd_amount 使用预存款金额
  592. * @apiSuccess {object} result.order_info.promotion 促销信息
  593. * @apiSuccess {Float} result.order_info.rcb_amount 使用充值卡金额
  594. * @apiSuccess {String} result.order_info.real_pay_amount 实际支付金额
  595. * @apiSuccess {String} result.order_info.reciver_addr 收货地址
  596. * @apiSuccess {String} result.order_info.reciver_name 收货人姓名
  597. * @apiSuccess {String} result.order_info.reciver_phone 收货人手机
  598. * @apiSuccess {Float} result.order_info.refund_amount 退款金额
  599. * @apiSuccess {Int} result.order_info.refund_state 退款状态 0:无退款 1:部分退款 2:全部退款
  600. * @apiSuccess {String} result.order_info.shipping_code 发货运单号
  601. * @apiSuccess {Float} result.order_info.shipping_fee 运费
  602. * @apiSuccess {String} result.order_info.state_desc 状态描述
  603. * @apiSuccess {Int} result.order_info.store_id 店铺ID
  604. * @apiSuccess {Int} result.order_info.store_member_id 店铺用户ID
  605. * @apiSuccess {String} result.order_info.store_name 店铺名称
  606. * @apiSuccess {String} result.order_info.store_phone 店铺电话
  607. * @apiSuccess {object} result.order_info.zengpin_list 赠品列表
  608. */
  609. public function order_info() {
  610. $order_id = intval(input('order_id'));
  611. if ($order_id <= 0) {
  612. ds_json_encode(10001, lang('member_order_none_exist'));
  613. }
  614. $order_model = model('order');
  615. $condition = array();
  616. $condition[] = array('order_id','=',$order_id);
  617. $condition[] = array('buyer_id','=',$this->member_info['member_id']);
  618. $order_info = $order_model->getOrderInfo($condition, array('order_goods', 'order_common', 'store'));
  619. if (empty($order_info) || $order_info['delete_state'] == ORDER_DEL_STATE_DROP) {
  620. ds_json_encode(10001, lang('member_order_none_exist'));
  621. }
  622. $refundreturn_model = model('refundreturn');
  623. $order_list = array();
  624. $order_list[$order_id] = $order_info;
  625. $order_list = $refundreturn_model->getGoodsRefundList($order_list, 1); //订单商品的退款退货显示
  626. $order_info = $order_list[$order_id];
  627. $refund_all = isset($order_info['refund_list'][0]) ? $order_info['refund_list'][0] : '';
  628. if (!empty($refund_all) && $refund_all['seller_state'] < 3) {//订单全部退款商家审核状态:1为待审核,2为同意,3为不同意
  629. $result['refund_all'] = $refund_all;
  630. }
  631. $order_info['store_member_id'] = $order_info['extend_store']['member_id'];
  632. $order_info['store_phone'] = $order_info['extend_store']['store_phone'];
  633. //显示系统自动取消订单日期
  634. if ($order_info['order_state'] == ORDER_STATE_NEW || $order_info['order_state'] == ORDER_STATE_DEPOSIT) {
  635. $order_info['order_cancel_day'] = $order_info['add_time'] + config('ds_config.order_auto_cancel_day') * 24 * 3600;
  636. }else if($order_info['order_state'] == ORDER_STATE_REST){
  637. $order_info['order_cancel_day'] = $order_info['presell_end_time'] + 72 * 3600;
  638. }
  639. if ($order_info['extend_order_common']['order_message']) {
  640. $order_info['order_message'] = $order_info['extend_order_common']['order_message'];
  641. }
  642. if (!empty($order_info['extend_order_common']['invoice_info'])) {
  643. $order_info['invoice'] = $order_info['extend_order_common']['invoice_info'];
  644. }
  645. $order_info['reciver_phone'] = $order_info['extend_order_common']['reciver_info']['phone'];
  646. $order_info['reciver_name'] = $order_info['extend_order_common']['reciver_name'];
  647. $order_info['reciver_addr'] = $order_info['extend_order_common']['reciver_info']['address'];
  648. $order_info['promotion'] = stripslashes(strip_tags($order_info['extend_order_common']['promotion_info']));
  649. $order_info['voucher_code'] = $order_info['extend_order_common']['voucher_code'];
  650. $order_info['voucher_price'] = $order_info['extend_order_common']['voucher_price'];
  651. //显示锁定中
  652. $order_info['if_lock'] = $order_model->getOrderOperateState('lock', $order_info);
  653. //显示取消订单
  654. $order_info['if_buyer_cancel'] = $order_model->getOrderOperateState('buyer_cancel', $order_info);
  655. //显示退款取消订单
  656. $order_info['if_refund_cancel'] = $order_model->getOrderOperateState('refund_cancel', $order_info);
  657. //显示投诉
  658. $order_info['if_complain'] = $order_model->getOrderOperateState('complain', $order_info);
  659. //显示收货
  660. $order_info['if_receive'] = $order_model->getOrderOperateState('receive', $order_info);
  661. //显示物流跟踪
  662. $order_info['if_deliver'] = $order_model->getOrderOperateState('deliver', $order_info);
  663. //显示评价
  664. $order_info['if_evaluation'] = $order_model->getOrderOperateState('evaluation', $order_info);
  665. //因为格式化了时间导致按钮判断错误
  666. if ($order_info['payment_time']) {
  667. $order_info['payment_time'] = date('Y-m-d H:i:s', $order_info['payment_time']);
  668. } else {
  669. $order_info['payment_time'] = '';
  670. }
  671. if ($order_info['finnshed_time']) {
  672. $order_info['finnshed_time'] = date('Y-m-d H:i:s', $order_info['finnshed_time']);
  673. } else {
  674. $order_info['finnshed_time'] = '';
  675. }
  676. if ($order_info['add_time']) {
  677. $order_info['add_time'] = date('Y-m-d H:i:s', $order_info['add_time']);
  678. } else {
  679. $order_info['add_time'] = '';
  680. }
  681. $order_info['if_deliver'] = false;
  682. //显示快递信息
  683. if ($order_info['shipping_code'] != '') {
  684. $order_info['if_deliver'] = true;
  685. $express = rkcache('express', true);
  686. if(isset($express[$order_info['extend_order_common']['shipping_express_id']])){
  687. $order_info['express_info']['express_code'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
  688. $order_info['express_info']['express_name'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
  689. $order_info['express_info']['express_url'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_url'];
  690. }else{
  691. $order_info['express_info']['express_code'] = '';
  692. $order_info['express_info']['express_name'] = '';
  693. $order_info['express_info']['express_url'] = '';
  694. }
  695. }
  696. //显示系统自动收获时间
  697. if ($order_info['order_state'] == ORDER_STATE_SEND) {
  698. $order_info['order_confirm_day'] = $order_info['delay_time'] + config('ds_config.order_auto_receive_day') * 24 * 3600;
  699. }
  700. //如果订单已取消,取得取消原因、时间,操作人
  701. if ($order_info['order_state'] == ORDER_STATE_CANCEL) {
  702. $close_info = $order_model->getOrderlogInfo(array('order_id' => $order_info['order_id']), 'log_id desc');
  703. $order_info['close_info'] = $close_info;
  704. // $order_info['state_desc'] = $close_info['log_orderstate'];
  705. $order_info['order_tips'] = $close_info['log_msg'];
  706. }
  707. $order_info['chain_order_type'] = 0;
  708. //如果是待自提则获取提货码
  709. $chain_order_model = model('chain_order');
  710. $chain_order_info = $chain_order_model->getChainOrderInfo(array(array('order_id', '=', $order_info['order_id'])));
  711. if ($chain_order_info) {
  712. $order_info['chain_order_type'] = $chain_order_info['chain_order_type'];
  713. $order_info['chain_order_pickup_code'] = $chain_order_info['chain_order_pickup_code'];
  714. $chain_model = model('chain');
  715. $chain_info = $chain_model->getChainInfo(array(array('chain_id', '=', $chain_order_info['chain_id'])));
  716. if ($chain_info) {
  717. $order_info['chain_addressname'] = $chain_info['chain_addressname'];
  718. $order_info['chain_address'] = $chain_info['chain_address'];
  719. $phone_list = array();
  720. if ($chain_info['chain_mobile']) {
  721. $phone_list[] = $chain_info['chain_mobile'];
  722. }
  723. if ($chain_info['chain_telephony']) {
  724. $phone_list[] = $chain_info['chain_telephony'];
  725. }
  726. $order_info['chain_phone'] = implode(',', $phone_list);
  727. }
  728. }
  729. foreach ($order_info['extend_order_goods'] as $value) {
  730. $value['image_240_url'] = goods_cthumb($value['goods_image'], 240, $value['store_id']);
  731. $value['image_url'] = goods_cthumb($value['goods_image'], 240, $value['store_id']);
  732. $value['goods_type_cn'] = get_order_goodstype($value['goods_type']);
  733. if ($value['goods_type'] == 5) {
  734. $order_info['zengpin_list'][] = $value;
  735. } else {
  736. $order_info['goods_list'][] = $value;
  737. }
  738. }
  739. if (empty($order_info['zengpin_list'])) {
  740. $order_info['goods_count'] = count($order_info['goods_list']);
  741. } else {
  742. $order_info['goods_count'] = count($order_info['goods_list']) + 1;
  743. }
  744. $order_info['real_pay_amount'] = $order_info['order_amount'] + $order_info['shipping_fee'];
  745. //取得其它订单类型的信息000--------------------------------
  746. //$order_model->getOrderExtendInfo($order_info);
  747. $result['order_info'] = $order_info;
  748. ds_json_encode(10000, '', $result);
  749. }
  750. /**
  751. * 订单详情
  752. */
  753. public function get_current_deliver() {
  754. $order_id = intval(input('post.order_id'));
  755. if ($order_id <= 0) {
  756. ds_json_encode(10001, lang('member_order_none_exist'));
  757. }
  758. $order_model = model('order');
  759. $condition = array();
  760. $condition[] = array('order_id','=',$order_id);
  761. $condition[] = array('buyer_id','=',$this->member_info['member_id']);
  762. $order_info = $order_model->getOrderInfo($condition, array('order_common', 'order_goods'));
  763. if (empty($order_info) || !in_array($order_info['order_state'], array(ORDER_STATE_SEND, ORDER_STATE_SUCCESS))) {
  764. ds_json_encode(10001, lang('member_order_none_exist'));
  765. }
  766. $express = rkcache('express', true);
  767. if (!empty($order_info['extend_order_common']['shipping_express_id'])) {
  768. $express_code = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
  769. $express_name = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
  770. } else {
  771. $express_code = '';
  772. $express_name = '';
  773. }
  774. $deliver_info = $this->_get_express($express_code, $order_info['shipping_code'], $order_info['extend_order_common']['reciver_info']['phone']);
  775. $data = array();
  776. $data['deliver_info']['context'] = $express_name;
  777. $data['deliver_info']['time'] = $deliver_info['0'];
  778. ds_json_encode(10000, '', $data);
  779. }
  780. /**
  781. * 从第三方取快递信息
  782. *
  783. */
  784. public function _get_express($express_code, $shipping_code, $phone) {
  785. $result = model('express')->queryExpress($express_code, $shipping_code, $phone);
  786. if ($result['Success'] != true) {
  787. ds_json_encode(10001, lang('deliver_search_fail'));
  788. }
  789. $content['Traces'] = array_reverse($result['Traces']);
  790. $output = array();
  791. if (is_array($content['Traces'])) {
  792. foreach ($content['Traces'] as $k => $v) {
  793. if ($v['AcceptTime'] == '')
  794. continue;
  795. //$output[] = $v['time'] . '&nbsp;&nbsp;' . $v['context'];
  796. $output[$k]['AcceptTime'] = $v['AcceptTime'];
  797. $output[$k]['AcceptStation'] = $v['AcceptStation'];
  798. }
  799. }
  800. if (empty($output))
  801. ds_json_encode(10001, lang('deliver_not_support'));
  802. return $output;
  803. }
  804. }
  805. ?>