MCommon.Class.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * 公共Model
  4. * Created by PhpStorm.
  5. * User: 小威
  6. * Date: 2019/11/18
  7. * Time: 09:22
  8. */
  9. namespace JinDouYun\Model\Common;
  10. use Mall\Framework\Core\ErrorCode;
  11. use Mall\Framework\Core\StatusCode;
  12. use Mall\Framework\Core\ResultWrapper;
  13. use JinDouYun\Model\SysAreaChina\MSysAreaChina;
  14. class MCommon
  15. {
  16. public function __construct()
  17. {
  18. }
  19. /**
  20. * 格式化source名称
  21. * @param $key
  22. * @return mixed
  23. */
  24. static function formatOrderSource($key)
  25. {
  26. $data = [
  27. StatusCode::$orderType['saleOrder'] => '销售订单',
  28. StatusCode::$orderType['purchaseOrder'] => '采购订单',
  29. StatusCode::$orderType['purchaseIn'] => '采购入库',
  30. StatusCode::$orderType['purchaseReturn'] => '采购退货',
  31. StatusCode::$orderType['saleOut'] => '销售出库',
  32. StatusCode::$orderType['saleReturn'] => '销售退货',
  33. StatusCode::$orderType['batch'] => '批次编号',
  34. StatusCode::$orderType['allocate'] => '调拨库存',
  35. StatusCode::$orderType['allocateOut'] => '调拨出库',
  36. StatusCode::$orderType['allocateIn'] => '调拨入库',
  37. StatusCode::$orderType['stocktaking'] => '盘点库存',
  38. StatusCode::$orderType['purchaseReturnOut'] => '采购退货出库',
  39. StatusCode::$orderType['saleReturnIn'] => '销售退货入库',
  40. StatusCode::$orderType['reportLoss'] => '库存报损',
  41. StatusCode::$orderType['merchantPurchase'] => '商户采购',
  42. StatusCode::$orderType['merchantPurchaseIn'] => '商户入库',
  43. ];
  44. if(!isset($data[$key])) return '';
  45. return $data[$key];
  46. }
  47. /**
  48. * 推
  49. */
  50. /**
  51. * 格式化地址信息
  52. * @param $data
  53. * @return
  54. */
  55. public function formatAddress($data)
  56. {
  57. $MSysAreaChina = new MSysAreaChina();
  58. foreach($data as $key => &$value){
  59. //处理地址
  60. if (isset($value['provinceCode']) && isset($value['cityCode']) && isset($value['districtCode'])) {
  61. $areaName = $MSysAreaChina->getNameByCode([
  62. $value['provinceCode'],
  63. $value['cityCode'],
  64. $value['districtCode']
  65. ]);
  66. $value['area']['provinceName'] = isset($areaName[$value['provinceCode']]) ? $areaName[$value['provinceCode']] : '';
  67. $value['area']['cityName'] = isset($areaName[$value['cityCode']]) ? $areaName[$value['cityCode']] : '';
  68. $value['area']['districtName'] = isset($areaName[$value['districtCode']]) ? $areaName[$value['districtCode']] : '';
  69. $value['area']['address'] = $value['address'];
  70. }
  71. }
  72. return $data;
  73. }
  74. }