Memberorder.php 55 KB

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