ExpressCompanyTemplate.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 ExpressCompanyTemplate extends BaseModel
  17. {
  18. /***************************************************************** 系统物流公司start **********************************************************************/
  19. /**
  20. * 添加系统物流公司
  21. * @param unknown $data
  22. */
  23. public function addExpressCompanyTemplate($data)
  24. {
  25. $id = model('express_company_template')->add($data);
  26. return $this->success($id);
  27. }
  28. /**
  29. * 添加多个系统物流公司
  30. * @param unknown $data
  31. */
  32. public function addExpressCompanyTemplateList($data)
  33. {
  34. $id = model('express_company_template')->addList($data);
  35. return $this->success($id);
  36. }
  37. /**
  38. * 修改系统物流公司
  39. * @param $data
  40. * @return array
  41. */
  42. public function editExpressCompanyTemplate($data)
  43. {
  44. $res = model('express_company_template')->update($data, [ [ 'company_id', '=', $data[ 'company_id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ] ]);
  45. return $this->success($res);
  46. }
  47. /**
  48. * 删除系统物流公司
  49. * @param array $condition
  50. */
  51. public function deleteExpressCompanyTemplate($condition)
  52. {
  53. $res = model('express_company_template')->delete($condition);
  54. return $this->success($res);
  55. }
  56. /**
  57. * 获取物流公司信息
  58. * @param array $condition
  59. * @param string $field
  60. */
  61. public function getExpressCompanyTemplateInfo($condition, $field = '*')
  62. {
  63. $res = model('express_company_template')->getInfo($condition, $field);
  64. if (!empty($res)) {
  65. if (empty($res[ 'content_json' ])) {
  66. $res[ 'content_json' ] = json_encode($this->getPrintItemList());
  67. }
  68. }
  69. return $this->success($res);
  70. }
  71. /**
  72. * 获取物流公司列表
  73. * @param array $condition
  74. * @param string $field
  75. * @param string $order
  76. * @param string $limit
  77. */
  78. public function getExpressCompanyTemplateList($condition = [], $field = '*', $order = '', $limit = null)
  79. {
  80. $list = model('express_company_template')->getList($condition, $field, $order, '', '', '', $limit);
  81. return $this->success($list);
  82. }
  83. /**
  84. * 获取物流公司分页列表
  85. * @param array $condition
  86. * @param number $page
  87. * @param string $page_size
  88. * @param string $order
  89. * @param string $field
  90. */
  91. public function getExpressCompanyTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
  92. {
  93. $list = model('express_company_template')->pageList($condition, $field, $order, $page, $page_size);
  94. return $this->success($list);
  95. }
  96. /**
  97. * 修改物流公司排序
  98. * @param $sort
  99. * @param $company_id
  100. * @return array|\multitype
  101. */
  102. public function modifyExpressCompanyTemplateSort($sort, $company_id)
  103. {
  104. $res = model('express_company_template')->update([ 'sort' => $sort ], [ [ 'company_id', '=', $company_id ] ]);
  105. return $this->success($res);
  106. }
  107. /***************************************************************** 系统物流公司end **********************************************************************/
  108. /***************************************************************** 店铺物流公司start **********************************************************************/
  109. /**
  110. * 添加店铺物流公司
  111. * @param unknown $data
  112. */
  113. public function addExpressCompanyTemplateShop($data)
  114. {
  115. $data[ 'create_time' ] = time();
  116. $data[ 'modify_time' ] = time();
  117. $company_info = $this->getExpressCompanyTemplateInfo([ [ 'company_id', '=', $data[ 'company_id' ] ] ]);
  118. $data[ 'company_name' ] = $company_info[ 'data' ][ 'company_name' ];
  119. $brand_id = model('express_company_template_shop')->add($data);
  120. return $this->success($brand_id);
  121. }
  122. /**
  123. * 修改店铺物流公司
  124. * @param unknown $data
  125. * @return multitype:string
  126. */
  127. public function editExpressCompanyTemplateShop($data, $condition)
  128. {
  129. $data[ 'modify_time' ] = time();
  130. $res = model('express_company_template_shop')->update($data, $condition);
  131. return $this->success($res);
  132. }
  133. /**
  134. * 删除店铺物流公司
  135. * @param unknown $condition
  136. */
  137. public function deleteExpressCompanyTemplateShop($condition)
  138. {
  139. $res = model('express_company_template_shop')->delete($condition);
  140. return $this->success($res);
  141. }
  142. /**
  143. * 获取店铺物流公司信息
  144. * @param unknown $condition
  145. * @param string $field
  146. */
  147. public function getExpressCompanyTemplateShopInfo($condition, $field = 'id, site_id, company_id, content_json, background_image, font_size, width, height, create_time, modify_time, scale')
  148. {
  149. $res = model('express_company_template_shop')->getInfo($condition, $field);
  150. if (!empty($res)) {
  151. if (empty($res[ 'content_json' ])) {
  152. $res[ 'content_json' ] = json_encode($this->getPrintItemList());
  153. }
  154. }
  155. return $this->success($res);
  156. }
  157. /**
  158. * 获取店铺物流公司列表
  159. * @param array $condition
  160. * @param string $field
  161. * @param string $order
  162. * @param string $limit
  163. */
  164. public function getExpressCompanyTemplateShopList($condition = [], $field = 'company_id as id, site_id, company_id, content_json, background_image, font_size, width, height, create_time, modify_time, scale, company_name', $order = '', $limit = null)
  165. {
  166. $list = model('express_company_template')->getList($condition, $field, $order, '', '', '', $limit);
  167. return $this->success($list);
  168. }
  169. /**
  170. * 获取店铺物流公司分页列表
  171. * @param array $condition
  172. * @param number $page
  173. * @param string $page_size
  174. * @param string $order
  175. * @param string $field
  176. */
  177. public function getExpressCompanyTemplateShopPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'id, site_id, company_id, content_json, background_image, font_size, width, height, create_time, modify_time, scale')
  178. {
  179. $list = model('express_company_template_shop')->pageList($condition, $field, $order, $page, $page_size);
  180. return $this->success($list);
  181. }
  182. /***************************************************************** 店铺物流公司end **********************************************************************/
  183. /**
  184. * 获取打印项
  185. * @return array
  186. */
  187. public function getPrintItemList()
  188. {
  189. $data = [
  190. [
  191. 'item_name' => 'order_no',
  192. 'item_title' => '订单编号',
  193. ],
  194. [
  195. 'item_name' => 'sender_company',
  196. 'item_title' => '发件人公司',
  197. ],
  198. [
  199. 'item_name' => 'sender_name',
  200. 'item_title' => '发件人姓名',
  201. ],
  202. [
  203. 'item_name' => 'sender_address',
  204. 'item_title' => '发件人地址',
  205. ],
  206. [
  207. 'item_name' => 'sender_phone',
  208. 'item_title' => '发件人电话',
  209. ],
  210. [
  211. 'item_name' => 'sender_post_code',
  212. 'item_title' => '发件人邮编',
  213. ],
  214. [
  215. 'item_name' => 'receiver_name',
  216. 'item_title' => '收件人姓名',
  217. ],
  218. [
  219. 'item_name' => 'receiver_address',
  220. 'item_title' => '收件人地址',
  221. ],
  222. [
  223. 'item_name' => 'receiver_phone',
  224. 'item_title' => '收件人电话',
  225. ],
  226. [
  227. 'item_name' => 'receiver_post_code',
  228. 'item_title' => '收件人邮编',
  229. ],
  230. [
  231. 'item_name' => 'logistics_number',
  232. 'item_title' => '货到付款物流编号',
  233. ],
  234. [
  235. 'item_name' => 'collection_payment',
  236. 'item_title' => '代收金额',
  237. ],
  238. [
  239. 'item_name' => 'remark',
  240. 'item_title' => '备注',
  241. ],
  242. ];
  243. return $data;
  244. }
  245. }