ExpressCompany.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\model\express;
  11. use think\facade\Cache;
  12. use app\model\BaseModel;
  13. /**
  14. * 物流公司
  15. */
  16. class ExpressCompany extends BaseModel
  17. {
  18. /**
  19. * 添加店铺物流公司
  20. * @param $data
  21. * @return array
  22. */
  23. public function addExpressCompany($data)
  24. {
  25. $data[ 'create_time' ] = time();
  26. $data[ 'modify_time' ] = time();
  27. $company_template = new ExpressCompanyTemplate();
  28. $company_info = $company_template->getExpressCompanyTemplateInfo([ [ 'company_id', '=', $data[ 'company_id' ] ] ]);
  29. $data[ 'company_name' ] = $company_info[ 'data' ][ 'company_name' ];
  30. $data[ 'logo' ] = $company_info[ 'data' ][ 'logo' ];
  31. $data[ 'express_no' ] = $company_info[ 'data' ][ 'express_no' ];
  32. $brand_id = model('express_company')->add($data);
  33. return $this->success($brand_id);
  34. }
  35. /**
  36. * 修改店铺物流公司
  37. * @param $data
  38. * @param $condition
  39. * @return array
  40. */
  41. public function editExpressCompany($data, $condition)
  42. {
  43. $data[ 'modify_time' ] = time();
  44. $res = model('express_company')->update($data, $condition);
  45. return $this->success($res);
  46. }
  47. /**
  48. * 删除店铺物流公司
  49. * @param $condition
  50. * @return array
  51. */
  52. public function deleteExpressCompany($condition)
  53. {
  54. $res = model('express_company')->delete($condition);
  55. return $this->success($res);
  56. }
  57. /**
  58. * 获取店铺物流公司信息
  59. * @param $condition
  60. * @param string $field
  61. * @return array
  62. */
  63. public function getExpressCompanyInfo($condition, $field = 'id, site_id, company_id, express_no, content_json, background_image, font_size, width, height, create_time, modify_time, scale')
  64. {
  65. $res = model('express_company')->getInfo($condition, $field);
  66. if (!empty($res)) {
  67. if (empty($res[ 'content_json' ])) {
  68. $res[ 'content_json' ] = json_encode($this->getPrintItemList());
  69. }
  70. }
  71. return $this->success($res);
  72. }
  73. /**
  74. * 获取店铺物流公司列表
  75. * @param array $condition
  76. * @param string $field
  77. * @param string $order
  78. * @param string $alias
  79. * @param array $join
  80. * @param string $group
  81. * @param null $limit
  82. * @return array
  83. */
  84. public function getExpressCompanyList($condition = [], $field = 'id, site_id, company_id, express_no, content_json, background_image, font_size, width, height, create_time, modify_time, scale, company_name', $order = '', $alias = '', $join = [], $group = '', $limit = null)
  85. {
  86. $list = model('express_company')->getList($condition, $field, $order, $alias, $join, $group, $limit);
  87. return $this->success($list);
  88. }
  89. /**
  90. * 获取店铺物流公司分页列表
  91. * @param array $condition
  92. * @param int $page
  93. * @param int $page_size
  94. * @param string $order
  95. * @param string $field
  96. * @return array
  97. */
  98. public function getExpressCompanyPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'id, site_id, company_id,express_no, content_json, background_image, font_size, width, height, create_time, modify_time, scale')
  99. {
  100. $list = model('express_company')->pageList($condition, $field, $order, $page, $page_size);
  101. return $this->success($list);
  102. }
  103. /**
  104. * 获取打印项
  105. * @return array
  106. */
  107. public function getPrintItemList()
  108. {
  109. $data = [
  110. [
  111. 'item_name' => 'order_no',
  112. 'item_title' => '订单编号',
  113. ],
  114. [
  115. 'item_name' => 'sender_company',
  116. 'item_title' => '发件人公司',
  117. ],
  118. [
  119. 'item_name' => 'sender_name',
  120. 'item_title' => '发件人姓名',
  121. ],
  122. [
  123. 'item_name' => 'sender_address',
  124. 'item_title' => '发件人地址',
  125. ],
  126. [
  127. 'item_name' => 'sender_phone',
  128. 'item_title' => '发件人电话',
  129. ],
  130. [
  131. 'item_name' => 'sender_post_code',
  132. 'item_title' => '发件人邮编',
  133. ],
  134. [
  135. 'item_name' => 'receiver_name',
  136. 'item_title' => '收件人姓名',
  137. ],
  138. [
  139. 'item_name' => 'receiver_address',
  140. 'item_title' => '收件人地址',
  141. ],
  142. [
  143. 'item_name' => 'receiver_phone',
  144. 'item_title' => '收件人电话',
  145. ],
  146. [
  147. 'item_name' => 'receiver_post_code',
  148. 'item_title' => '收件人邮编',
  149. ],
  150. [
  151. 'item_name' => 'logistics_number',
  152. 'item_title' => '货到付款物流编号',
  153. ],
  154. [
  155. 'item_name' => 'collection_payment',
  156. 'item_title' => '代收金额',
  157. ],
  158. [
  159. 'item_name' => 'remark',
  160. 'item_title' => '备注',
  161. ],
  162. ];
  163. return $data;
  164. }
  165. }