Memberorder.php 56 KB

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