LogisticsController.class.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. namespace Seller\Controller;
  3. class LogisticsController extends CommonController{
  4. protected function _initialize(){
  5. parent::_initialize();
  6. //'pinjie' => '拼团介绍',
  7. }
  8. /**
  9. * 电子面单列表
  10. */
  11. public function index(){
  12. $_GPC = I('request.');
  13. $this->gpc = $_GPC;
  14. $condition = ' 1 ';
  15. $pindex = max(1, intval($_GPC['page']));
  16. $psize = 20;
  17. if (!empty($_GPC['keyword'])) {
  18. $_GPC['keyword'] = trim($_GPC['keyword']);
  19. $condition .= ' and express_name like "%'.$_GPC['keyword'].'%" ';
  20. }
  21. $label = M('lionfish_comshop_kdniao_list')->where( $condition )->order(' id desc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  22. $total = M('lionfish_comshop_kdniao_list')->where( $condition )->count();
  23. $pager = pagination2($total, $pindex, $psize);
  24. $this->label = $label;
  25. $this->pager = $pager;
  26. $this->display("kdniao_index");
  27. }
  28. /**
  29. * 添加快递
  30. */
  31. public function add_kdniao(){
  32. $_GPC = I('request.');
  33. if (IS_POST) {
  34. $data = $_GPC['data'];
  35. if (empty($data['express_code'])) {
  36. show_json(0, array('message' => '快递公司不能为空'));
  37. }
  38. $kdn_info = M('lionfish_comshop_kdniao_list')->where( array('express_code' => $data['express_code'] ) )->find();
  39. if(!empty($kdn_info)){
  40. show_json(0, array('message' => '快递公司电子面单已配置'));
  41. }
  42. if (empty($data['sender_name'])) {
  43. show_json(0, array('message' => '发件人名称不能为空'));
  44. }
  45. if (empty($data['sender_tel'])) {
  46. show_json(0, array('message' => '发件人电话不能为空'));
  47. }
  48. if (empty($data['sender_province_name']) || $data['sender_province_name'] == '请选择省份') {
  49. show_json(0, array('message' => '发件人省市区不能为空'));
  50. }
  51. if (empty($data['sender_city_name']) || $data['sender_city_name'] == '请选择城市') {
  52. show_json(0, array('message' => '发件人省市区不能为空'));
  53. }
  54. if (empty($data['sender_area_name']) || $data['sender_area_name'] == '请选择区域') {
  55. show_json(0, array('message' => '发件人省市区不能为空'));
  56. }
  57. if (empty($data['sender_address'])) {
  58. show_json(0, array('message' => '发件人详细地址不能为空'));
  59. }
  60. $express_info = M('lionfish_comshop_express')->where( array('simplecode' => $data['express_code'] ) )->find();
  61. $data['express_name'] = $express_info['name'];
  62. D('Seller/Kdniao')->update($data);
  63. show_json(1, array('url' => U('logistics/index')));
  64. }
  65. $this->express_list = D('Seller/Express')->load_kdn_express();
  66. $this->display("kdniao_add");
  67. }
  68. /**
  69. * 添加快递
  70. */
  71. public function edit_kdniao(){
  72. $_GPC = I('request.');
  73. $id = intval($_GPC['id']);
  74. if (!empty($id)) {
  75. $item = M('lionfish_comshop_kdniao_list')->where( array('id' =>$id ) )->find();
  76. $this->item = $item;
  77. }
  78. if (IS_POST) {
  79. $data = $_GPC['data'];
  80. if (empty($data['express_code'])) {
  81. show_json(0, array('message' => '快递公司不能为空'));
  82. }
  83. $kdn_info = M('lionfish_comshop_kdniao_list')->where("express_code='".$data['express_code']."' and id <> ".$id)->find();
  84. if(!empty($kdn_info)){
  85. show_json(0, array('message' => '快递公司电子面单已配置'));
  86. }
  87. if (empty($data['sender_name'])) {
  88. show_json(0, array('message' => '发件人名称不能为空'));
  89. }
  90. if (empty($data['sender_tel'])) {
  91. show_json(0, array('message' => '发件人电话不能为空'));
  92. }
  93. if (empty($data['sender_province_name']) || $data['sender_province_name'] == '请选择省份') {
  94. show_json(0, array('message' => '发件人省市区不能为空'));
  95. }
  96. if (empty($data['sender_city_name']) || $data['sender_city_name'] == '请选择城市') {
  97. show_json(0, array('message' => '发件人省市区不能为空'));
  98. }
  99. if (empty($data['sender_area_name']) || $data['sender_area_name'] == '请选择区域') {
  100. show_json(0, array('message' => '发件人省市区不能为空'));
  101. }
  102. if (empty($data['sender_address'])) {
  103. show_json(0, array('message' => '发件人详细地址不能为空'));
  104. }
  105. $express_info = M('lionfish_comshop_express')->where( array('simplecode' => $data['express_code'] ) )->find();
  106. $data['express_name'] = $express_info['name'];
  107. D('Seller/Kdniao')->update($data);
  108. show_json(1, array('url' => U('logistics/index')));
  109. }
  110. $this->express_list = D('Seller/Express')->load_kdn_express();
  111. $this->display("kdniao_add");
  112. }
  113. public function select_template(){
  114. $_GPC = I('request.');
  115. $code = $_GPC['code'];
  116. $list = M('lionfish_comshop_kdniao_template')->where(array('express_code'=>$code))->field('template_name,template_spec,template_size')->select();
  117. $result = array();
  118. if(empty($list)){
  119. $result['code'] = 0;
  120. }else{
  121. $result['code'] = 1;
  122. $result['list'] = $list;
  123. }
  124. echo json_encode($result);
  125. }
  126. public function delete_kdniao(){
  127. $_GPC = I('request.');
  128. $id = intval($_GPC['id']);
  129. if (empty($id)) {
  130. $id = $_GPC['ids'];
  131. }
  132. if( is_array($id) )
  133. {
  134. $items = M('lionfish_comshop_kdniao_list')->field('id')->where( array('id' => array('in', $id)) )->select();
  135. }else{
  136. $items = M('lionfish_comshop_kdniao_list')->field('id')->where( array('id' =>$id ) )->select();
  137. }
  138. if (empty($item)) {
  139. $item = array();
  140. }
  141. foreach ($items as $item) {
  142. M('lionfish_comshop_kdniao_list')->where( array('id' => $item['id']) )->delete();
  143. }
  144. show_json(1, array('url' => U('logistics/index')));
  145. }
  146. /**
  147. * 电子面单设置
  148. */
  149. public function inface()
  150. {
  151. $_GPC = I('request.');
  152. if (IS_POST) {
  153. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  154. $data['kdniao_id'] = trim($data['kdniao_id']);
  155. $data['kdniao_api_key'] = trim($data['kdniao_api_key']);
  156. $data['kdniao_status'] = trim($data['kdniao_status']);
  157. $data['kdniao_freestatus'] = trim($data['kdniao_freestatus']);
  158. //寄件人信息设置
  159. $data['kdn_sender_name'] = trim($data['kdn_sender_name']);
  160. $data['kdn_sender_mobile'] = trim($data['kdn_sender_mobile']);
  161. $data['kdn_province_id'] = trim($data['province_id']);
  162. $data['kdn_city_id'] = trim($data['city_id']);
  163. $data['kdn_area_id'] = trim($data['area_id']);
  164. $data['kdn_sender_address'] = trim($data['kdn_sender_address']);
  165. $data['kdn_sender_company'] = trim($data['kdn_sender_company']);
  166. $data['kdn_sender_postcode'] = trim($data['kdn_sender_postcode']);
  167. if($data['kdniao_status'] == 1){//开启快递鸟判断参数
  168. if(empty($data['kdniao_id'])){
  169. show_json(0, array('msg' => '快递鸟商户ID不能为空' ) );
  170. }
  171. if(empty($data['kdniao_api_key'])){
  172. show_json(0, array('msg' => '快递鸟API KEY不能为空' ) );
  173. }
  174. if(empty($data['kdn_sender_name'])){
  175. show_json(0, array('msg' => '寄件人不能为空' ) );
  176. }
  177. if(empty($data['kdn_sender_mobile'])){
  178. show_json(0, array('msg' => '寄件人联系电话不能为空' ) );
  179. }
  180. if(empty($data['kdn_province_id']) || $data['kdn_province_id']== '请选择省份'){
  181. show_json(0, array('msg' => '寄件人省份不能为空' ) );
  182. }
  183. if(empty($data['kdn_city_id']) || $data['kdn_province_id']== '请选择城市'){
  184. show_json(0, array('msg' => '寄件人城市不能为空' ) );
  185. }
  186. if(empty($data['kdn_area_id']) || $data['kdn_province_id']== '请选择区域'){
  187. show_json(0, array('msg' => '寄件人区域不能为空' ) );
  188. }
  189. if(empty($data['kdn_sender_address'])){
  190. show_json(0, array('msg' => '寄件人详细地址不能为空' ) );
  191. }
  192. }
  193. D('Seller/Config')->update($data);
  194. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  195. }
  196. $data = D('Seller/Config')->get_all_config();
  197. $this->data = $data;
  198. $this->display();
  199. }
  200. }
  201. ?>