<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Express\Util; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use ModStart\Core\Type\TypeUtil; use ModStart\Core\Util\SerializeUtil; use Module\Express\Model\ExpressItem; use Module\Express\Provider\ExpressTransportProvider; use Module\Express\Type\ExpressItemStatus; class ExpressItemUtil { public static function update($g16tm, $hbx5Z, $EkpRH, $Lxm1k, $I2nM5, $w6bW5 = array()) { goto QY0pm; OC80Y: $YaV4m->phone = $I2nM5; goto ipe05; VcuxL: $YaV4m->expressName = $EkpRH; goto RT2ke; fzJvi: $YaV4m->save(); goto aFkG1; ipe05: $YaV4m->param = SerializeUtil::jsonEncode($w6bW5); goto fzJvi; RT2ke: $YaV4m->expressCode = $Lxm1k; goto OC80Y; uR0GX: if (!$YaV4m) { goto akzVR; E6Xeq: $YaV4m->biz = $g16tm; goto bVyqs; bVyqs: $YaV4m->bizId = $hbx5Z; goto htudr; XLjDh: $YaV4m->statusUpdateTime = date('Y-m-d H:i:s'); goto cTC7d; akzVR: $YaV4m = new ExpressItem(); goto E6Xeq; htudr: $YaV4m->status = ExpressItemStatus::UNKNOWN; goto XLjDh; cTC7d: } goto VcuxL; bliGn: $YaV4m = ExpressItem::where($dNpGx)->first(); goto uR0GX; QY0pm: $dNpGx = array('biz' => $g16tm, 'bizId' => $hbx5Z); goto bliGn; aFkG1: } public static function get($g16tm, $hbx5Z) { goto sC3ki; MYen6: return $lLaeU; goto hqP01; sC3ki: $YaV4m = ExpressItem::where(array('biz' => $g16tm, 'bizId' => $hbx5Z))->first(); goto zbCbf; zbCbf: if (!$YaV4m) { return null; } goto cuVR6; cuVR6: $lLaeU = $YaV4m->toArray(); goto f5z8N; f5z8N: ModelUtil::decodeRecordJson($lLaeU, array('content')); goto MYen6; hqP01: } public static function getUpdateIfNeed($g16tm, $hbx5Z) { goto K1_1B; u1wOK: return $lLaeU; goto MG2cG; wTtBp: $lLaeU['_expressName'] = ExpressUtil::getNameByCode($lLaeU['expressName']); goto ixpKS; ixpKS: $lLaeU['_status'] = TypeUtil::name(ExpressItemStatus::class, $lLaeU['status']); goto u1wOK; CZEv9: $lLaeU = self::updateStatusIfNeed($lLaeU); goto wTtBp; K1_1B: $lLaeU = self::get($g16tm, $hbx5Z); goto fNMly; fNMly: if (empty($lLaeU)) { return null; } goto CZEv9; MG2cG: } public static function merge($g16tm, &$MCyeh, $m2QRZ = 'id') { goto D1UJ_; po10z: $XdX3D = ExpressItem::where(array('biz' => $g16tm))->whereIn('bizId', $UaYkF)->get(); goto Zfy54; wFuMm: foreach ($XdX3D as $YaV4m) { $vE59_[$YaV4m->bizId] = $YaV4m; } goto q3zxH; q3zxH: foreach ($MCyeh as $i0YzC => $lLaeU) { if (isset($vE59_[$lLaeU[$m2QRZ]])) { goto C_27O; C_27O: $YaV4m = $vE59_[$lLaeU[$m2QRZ]]->toArray(); goto PrV1d; PrV1d: ModelUtil::decodeRecordJson($YaV4m, array('content')); goto TipHb; XneTm: $YaV4m['_status'] = TypeUtil::name(ExpressItemStatus::class, $YaV4m['status']); goto amS1_; TipHb: $YaV4m = self::updateStatusIfNeed($YaV4m); goto XneTm; amS1_: $MCyeh[$i0YzC]['_expressItem'] = $YaV4m; goto Milc0; Milc0: } } goto V5R0m; D1UJ_: $UaYkF = array(); goto RbP3d; Zfy54: $vE59_ = array(); goto wFuMm; RbP3d: foreach ($MCyeh as $lLaeU) { $UaYkF[] = $lLaeU[$m2QRZ]; } goto po10z; V5R0m: } public static function updateStatusIfNeed($lLaeU) { goto H9oez; ZcJNS: return $lLaeU; goto Xh_md; BhpBt: if (empty($lLaeU['status']) || !in_array($lLaeU['status'], array(ExpressItemStatus::RECEIVED, ExpressItemStatus::ERROR)) && strtotime($lLaeU['statusUpdateTime']) < time() - 3600) { goto iC7aa; oBDO8: if (Response::isSuccess($rhLXE)) { goto anCx0; BD3_H: $Gszjy['latestMessage'] = null; goto fMW8h; fMW8h: if (!empty($rhLXE['data']['content']['list'][0]['content'])) { $Gszjy['latestMessage'] = $rhLXE['data']['content']['list'][0]['content']; } goto WLY58; NC2yB: $Gszjy['content'] = SerializeUtil::jsonEncode($rhLXE['data']['content']); goto BD3_H; anCx0: $Gszjy['status'] = $rhLXE['data']['status']; goto z0A8c; z0A8c: $Gszjy['statusUpdateTime'] = date('Y-m-d H:i:s'); goto NC2yB; WLY58: } goto FaHuo; FaHuo: if (!empty($Gszjy)) { ModelUtil::update(ExpressItem::class, $lLaeU['id'], $Gszjy); $lLaeU = array_merge($lLaeU, $Gszjy); } goto ZClz0; TVMys: $Gszjy = array(); goto oBDO8; ZClz0: if (isset($lLaeU['content']) && is_string($lLaeU['content'])) { $lLaeU['content'] = SerializeUtil::jsonDecode($lLaeU['content']); } goto fMpoZ; iC7aa: $rhLXE = ExpressTransportProvider::query($lLaeU['expressName'], $lLaeU['expressCode'], $lLaeU['phone']); goto TVMys; fMpoZ: } goto ZcJNS; H9oez: if (empty($lLaeU)) { return null; } goto BhpBt; Xh_md: } }