ExpressCompany.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\model\express;
  13. use think\facade\Cache;
  14. use app\model\BaseModel;
  15. /**
  16. * 物流公司
  17. */
  18. class ExpressCompany extends BaseModel
  19. {
  20. /***************************************************************** 系统物流公司start **********************************************************************/
  21. /**
  22. * 添加系统物流公司
  23. * @param unknown $data
  24. */
  25. public function addExpressCompany($data)
  26. {
  27. $id = model('express_company')->add($data);
  28. Cache::tag("express_company")->clear();
  29. return $this->success($id);
  30. }
  31. /**
  32. * 修改系统物流公司
  33. * @param unknown $data
  34. * @return multitype:string
  35. */
  36. public function editExpressCompany($data)
  37. {
  38. $res = model('express_company')->update($data, [[ 'company_id', '=', $data['company_id'] ]]);
  39. Cache::tag("express_company")->clear();
  40. return $this->success($res);
  41. }
  42. /**
  43. * 删除系统物流公司
  44. * @param unknown $condition
  45. */
  46. public function deleteExpressCompany($condition)
  47. {
  48. $res = model('express_company')->delete($condition);
  49. Cache::tag("express_company")->clear();
  50. return $this->success($res);
  51. }
  52. /**
  53. * 获取物流公司信息
  54. * @param unknown $condition
  55. * @param string $field
  56. */
  57. public function getExpressCompanyInfo($condition, $field = '*')
  58. {
  59. $data = json_encode([ $condition, $field]);
  60. $cache = Cache::get("express_company_getExpressCompanyInfo_" . $data);
  61. if (!empty($cache)) {
  62. return $this->success($cache);
  63. }
  64. $res = model('express_company')->getInfo($condition, $field);
  65. if(!empty($res)){
  66. if(empty($res['content_json'])){
  67. $res['content_json'] = json_encode($this->getPrintItemList());
  68. }
  69. }
  70. Cache::tag("express_company")->set("express_company_getExpressCompanyInfo_" . $data, $res);
  71. return $this->success($res);
  72. }
  73. /**
  74. * 获取物流公司列表
  75. * @param array $condition
  76. * @param string $field
  77. * @param string $order
  78. * @param string $limit
  79. */
  80. public function getExpressCompanyList($condition = [], $field = '*', $order = '', $limit = null)
  81. {
  82. $data = json_encode([ $condition, $field, $order, $limit ]);
  83. $cache = Cache::get("express_company_getExpressCompanyList_" . $data);
  84. if (!empty($cache)) {
  85. return $this->success($cache);
  86. }
  87. $list = model('express_company')->getList($condition, $field, $order, '', '', '', $limit);
  88. Cache::tag("express_company")->set("express_company_getExpressCompanyList_" . $data, $list);
  89. return $this->success($list);
  90. }
  91. /**
  92. * 获取物流公司分页列表
  93. * @param array $condition
  94. * @param number $page
  95. * @param string $page_size
  96. * @param string $order
  97. * @param string $field
  98. */
  99. public function getExpressCompanyPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
  100. {
  101. $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
  102. $cache = Cache::get("express_company_getExpressCompanyPageList_" . $data);
  103. if (!empty($cache)) {
  104. return $this->success($cache);
  105. }
  106. $list = model('express_company')->pageList($condition, $field, $order, $page, $page_size);
  107. Cache::tag("express_company")->set("express_company_getExpressCompanyPageList_" . $data, $list);
  108. return $this->success($list);
  109. }
  110. /**
  111. * 修改物流公司排序
  112. * @param $sort
  113. * @param $company_id
  114. * @return array|\multitype
  115. */
  116. public function modifyExpressCompanySort($sort, $company_id)
  117. {
  118. Cache::tag("express_company")->clear();
  119. $res = model('express_company')->update(['sort' => $sort], [['company_id', '=', $company_id]]);
  120. return $this->success($res);
  121. }
  122. /***************************************************************** 系统物流公司end **********************************************************************/
  123. /***************************************************************** 店铺物流公司start **********************************************************************/
  124. /**
  125. * 添加店铺物流公司
  126. * @param unknown $data
  127. */
  128. public function addExpressCompanyShop($data)
  129. {
  130. $data["create_time"] = time();
  131. $data["modify_time"] = time();
  132. $company_info = $this->getExpressCompanyInfo([["company_id", "=", $data["company_id"]]]);
  133. $data["company_name"] = $company_info["data"]["company_name"];
  134. $brand_id = model('express_company_shop')->add($data);
  135. Cache::tag("express_company_shop")->clear();
  136. return $this->success($brand_id);
  137. }
  138. /**
  139. * 修改店铺物流公司
  140. * @param unknown $data
  141. * @return multitype:string
  142. */
  143. public function editExpressCompanyShop($data, $condition)
  144. {
  145. $data["modify_time"] = time();
  146. $res = model('express_company_shop')->update($data, $condition);
  147. Cache::tag("express_company_shop")->clear();
  148. return $this->success($res);
  149. }
  150. /**
  151. * 删除店铺物流公司
  152. * @param unknown $condition
  153. */
  154. public function deleteExpressCompanyShop($condition)
  155. {
  156. $res = model('express_company_shop')->delete($condition);
  157. Cache::tag("express_company_shop")->clear();
  158. return $this->success($res);
  159. }
  160. /**
  161. * 获取店铺物流公司信息
  162. * @param unknown $condition
  163. * @param string $field
  164. */
  165. public function getExpressCompanyShopInfo($condition, $field = 'id, site_id, company_id, content_json, background_image, font_size, width, height, create_time, modify_time, scale')
  166. {
  167. $data = json_encode([ $condition, $field]);
  168. $cache = Cache::get("express_company_shop_getExpressCompanyShopInfo_" . $data);
  169. if (!empty($cache)) {
  170. return $this->success($cache);
  171. }
  172. $res = model('express_company_shop')->getInfo($condition, $field);
  173. if(!empty($res)){
  174. if(empty($res['content_json'])){
  175. $res['content_json'] = json_encode($this->getPrintItemList());
  176. }
  177. }
  178. Cache::tag("express_company_shop")->set("express_company_shop_getExpressCompanyShopInfo_" . $data, $res);
  179. return $this->success($res);
  180. }
  181. /**
  182. * 获取店铺物流公司列表
  183. * @param array $condition
  184. * @param string $field
  185. * @param string $order
  186. * @param string $limit
  187. */
  188. public function getExpressCompanyShopList($condition = [], $field = 'id, site_id, company_id, content_json, background_image, font_size, width, height, create_time, modify_time, scale, company_name', $order = '', $limit = null)
  189. {
  190. $data = json_encode([ $condition, $field, $order, $limit ]);
  191. $cache = Cache::get("express_company_shop_getExpressCompanyShopList_" . $data);
  192. if (!empty($cache)) {
  193. return $this->success($cache);
  194. }
  195. $list = model('express_company_shop')->getList($condition, $field, $order, '', '', '', $limit);
  196. Cache::tag("express_company_shop")->set("express_company_shop_getExpressCompanyShopList_" . $data, $list);
  197. return $this->success($list);
  198. }
  199. /**
  200. * 获取店铺物流公司分页列表
  201. * @param array $condition
  202. * @param number $page
  203. * @param string $page_size
  204. * @param string $order
  205. * @param string $field
  206. */
  207. public function getExpressCompanyShopPageList($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')
  208. {
  209. $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
  210. $cache = Cache::get("express_company_shop_getExpressCompanyShopPageList_" . $data);
  211. if (!empty($cache)) {
  212. return $this->success($cache);
  213. }
  214. $list = model('express_company_shop')->pageList($condition, $field, $order, $page, $page_size);
  215. Cache::tag("express_company_shop")->set("express_company_shop_getExpressCompanyShopPageList_" . $data, $list);
  216. return $this->success($list);
  217. }
  218. /***************************************************************** 店铺物流公司end **********************************************************************/
  219. /**
  220. * 获取打印项
  221. * @return array
  222. */
  223. public function getPrintItemList()
  224. {
  225. $data = [
  226. [
  227. 'item_name' => 'order_no',
  228. 'item_title'=>'订单编号',
  229. ],
  230. [
  231. 'item_name' => 'sender_company',
  232. 'item_title'=>'发件人公司',
  233. ],
  234. [
  235. 'item_name' => 'sender_name',
  236. 'item_title'=>'发件人姓名',
  237. ],
  238. [
  239. 'item_name' => 'sender_address',
  240. 'item_title'=>'发件人地址',
  241. ],
  242. [
  243. 'item_name' => 'sender_phone',
  244. 'item_title'=>'发件人电话',
  245. ],
  246. [
  247. 'item_name' => 'sender_post_code',
  248. 'item_title'=>'发件人邮编',
  249. ],
  250. [
  251. 'item_name' => 'receiver_name',
  252. 'item_title'=>'收件人姓名',
  253. ],
  254. [
  255. 'item_name' => 'receiver_address',
  256. 'item_title'=>'收件人地址',
  257. ],
  258. [
  259. 'item_name' => 'receiver_phone',
  260. 'item_title'=>'收件人电话',
  261. ],
  262. [
  263. 'item_name' => 'receiver_post_code',
  264. 'item_title'=>'收件人邮编',
  265. ],
  266. [
  267. 'item_name' => 'logistics_number',
  268. 'item_title'=>'货到付款物流编号',
  269. ],
  270. [
  271. 'item_name' => 'collection_payment',
  272. 'item_title'=>'代收金额',
  273. ],
  274. [
  275. 'item_name' => 'remark',
  276. 'item_title'=>'备注',
  277. ],
  278. ];
  279. return $data;
  280. }
  281. }