Memberorder.php 56 KB

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