Esempio n. 1
0
 /**
  * 生成合同号
  * @param bool $isAutomatic 是否自动生成
  * @return string
  */
 static function generateNumber($isAutomatic = true, $type, $oldcontr = '')
 {
     $arr_number = [];
     //生成号
     if ($isAutomatic) {
         $arr_number[] = Contract::CONTRNO_SYSTEM;
     } else {
         $arr_number[] = Contract::CONTRNO_APP;
     }
     //经营许可证号简写
     $user = AccessTokenService::getCurrentUser();
     $license = str_replace('-', '', $user->org->license);
     $arr_number[] = $license;
     if ($isAutomatic) {
         $arr_number[] = strtoupper($type);
         //类型
         $arr_number[] = DataHelper::getCurrentDate('Ymd');
         //年月日
         $arr_number[] = substr(microtime(), 2, 5);
         //5位流水号
     } else {
         $arr_number[] = $oldcontr;
     }
     return implode('', $arr_number);
 }
Esempio n. 2
0
 /**
  * 补充签名信息
  * @author  lvkui
  * @date 2016011
  */
 public function actionSubmitSign()
 {
     $map = self::getRestMap();
     try {
         //验证
         AccessTokenService::validateToken(Yii::$app->request);
         $ec = new EcService();
         if (!isset($_POST['data'])) {
             throw new Exception('an empty string is not allowed for $data');
         }
         $data = $_POST['data'];
         $ec->sys_submitSign($data);
         $map[AjaxStatus::PROPERTY_MESSAGES] = "业务处理成功";
         $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_SUCCESSFUL;
         $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_OK;
         $map[AjaxStatus::PROPERTY_DATA] = [];
     } catch (IllegalArgumentException $e) {
         $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED;
         $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503;
         $map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage();
     } catch (Exception $e) {
         $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED;
         $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503;
         $map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage();
     }
     echo json_encode($map);
 }
Esempio n. 3
0
 public function beforeSave($insert)
 {
     $user = AccessTokenService::getCurrentUser();
     if ($this->isNewRecord) {
         $this->contr_no = ContractService::generateNumber(empty($this->oldcontr), $this->type, $this->oldcontr);
         $this->orgid = $user->orgid;
         $this->createtime = BaseDataHelper::getCurrentTime();
         $this->userid = $user->id;
     }
     $this->modified = BaseDataHelper::getCurrentTime();
     return parent::beforeSave($insert);
     // TODO: Change the autogenerated stub
 }
Esempio n. 4
0
 /**
  * 上传或者提交合同
  * @author lvkui
  * @param $data
  * @param bool $method
  * @throws \Exception
  * @throws \yii\base\Exception
  */
 function sys_submitContract($data, $method = true)
 {
     $tran = null;
     try {
         $tran = Yii::$app->db->beginTransaction();
         if (!isset($data['contract']) || $this->isStrEmpty($data['contract'])) {
             throw new Exception('an empty string is not allowed for $contract');
         }
         $user = AccessTokenService::getCurrentUser();
         //电子合同
         $ec = $data['contract'];
         $model = new Contract();
         $model->vercode = $ec['vercode'];
         $model->type = $ec['type'];
         $model->is_lock = Contract::CONTRACT_NO;
         $model->status = $method ? Contract::CONTRACT_STATUS_COMMITIN : Contract::CONTRACT_STATUS_UNCOMMIT;
         $model->audit_status = $user->org->isaudit ? Contract::CONTRACT_YES : Contract::CONTRACT_NO;
         $model->is_submit = $model->status;
         $model->sub_time = $model->is_submit ? DataHelper::getCurrentTime() : '';
         $model->price = $ec['price'];
         $model->num = $ec['num'];
         $model->transactor = $ec['transactor'];
         $model->oldcontr = $ec['contr_no'];
         $model->save();
         //线路信息
         if (isset($data['group'])) {
             $g = $data['group'];
             $gModel = new Group();
             $gModel->contr_id = $model->contr_id;
             $gModel->teamcode = $g['teamcode'];
             $gModel->linename = $g['linename'];
             $gModel->personLimit = $g['personLimit'];
             $gModel->payGuide = $g['payGuide'];
             $gModel->days = $g['days'];
             $gModel->nights = $g['nights'];
             $gModel->bgndate = $g['bgndate'];
             $gModel->enddate = $g['enddate'];
             $gModel->from = $g['from'];
             $gModel->aim = $g['aim'];
             $gModel->save();
         }
         //游客信息
         if (isset($data['traveller'])) {
             $t = $data['traveller'];
             $tModel = new Traveller();
             $tModel->contr_id = $model->contr_id;
             $tModel->name = $t['name'];
             $tModel->sex = $t['sex'];
             $tModel->birthday = $t['birthday'];
             $tModel->nation = $t['nation'];
             $tModel->folk = $t['folk'];
             $tModel->mobile = $t['mobile'];
             $tModel->idtype = $t['idtype'];
             $tModel->idcode = $t['idcode'];
             $tModel->addr = $t['addr'];
             $tModel->no = $t['no'];
             $tModel->is_leader = $t['is_leader'];
             if ($tModel->is_leader) {
                 $tModel->extra_data = $t['extra_data'];
             }
             $tModel->save();
         }
         //行程信息
         if (isset($data['routes'])) {
             $r = $data['routes'];
             if (!empty($r['journeys'])) {
                 foreach ($r['journeys'] as $k => $j) {
                     $rModel = new Routes();
                     $rModel->contr_id = $model->contr_id;
                     $rModel->parentid = '0';
                     $rModel->title = $j['title'];
                     $rModel->ctype = Routes::ROUTE_TYPE_JOURNEY;
                     $rModel->index = $j['index'];
                     if ($rModel->save()) {
                         $parentid = $rModel->id;
                         if (!empty($j['citys'])) {
                             foreach ($j['citys'] as $i => $c) {
                                 $cModel = new Routes();
                                 $cModel->contr_id = $model->contr_id;
                                 $cModel->parentid = $parentid;
                                 $cModel->title = $c['title'];
                                 $cModel->ctype = Routes::ROUTE_TYPE_CITY;
                                 $cModel->transit = $c['transit'];
                                 $cModel->index = $c['index'];
                                 $cModel->from = $c['from'];
                                 $cModel->aim_city = $c['aim_city'];
                                 $cModel->aim_country = $c['aim_country'];
                                 $cModel->sign = DataHelper::getSign($c['content']);
                                 $text = Text::findOne($cModel->sign);
                                 if (empty($text)) {
                                     $text->sign = $cModel->sign;
                                     $text->content = $c['content'];
                                     $text->save();
                                 }
                                 //$cModel->extra_data=$c['extra_data'];
                                 $cModel->save();
                             }
                         }
                     }
                 }
             }
         }
         //购物协议
         if (isset($data['shops'])) {
             foreach ($data['shops'] as $shop) {
                 $sModel = new ShopAgreement();
                 $sModel->contr_id = $model->contr_id;
                 $sModel->name = $shop['name'];
                 $sModel->addr = $shop['addr'];
                 $sModel->time = $shop['time'];
                 $sModel->goods = $shop['goods'];
                 $sModel->duration = $shop['duration'];
                 $sModel->memo = $shop['memo'];
                 $sModel->agree = $shop['agree'];
                 $sModel->index = $shop['index'];
                 $sModel->save();
             }
         }
         //自费协议
         if (isset($data['chargeables'])) {
             foreach ($data['chargeables'] as $charge) {
                 $chModel = new Chargeable();
                 $chModel->contr_id = $model->contr_id;
                 $chModel->name = $charge['name'];
                 $chModel->addr = $charge['addr'];
                 $chModel->time = $charge['time'];
                 $chModel->price = $charge['price'];
                 $chModel->duration = $charge['duration'];
                 $chModel->memo = $charge['memo'];
                 $chModel->agree = $charge['agree'];
                 $chModel->index = $charge['index'];
                 $chModel->save();
             }
         }
         //合同其它信息
         if (isset($data['other'])) {
             $other = $data['other'];
             $oModel = new Other();
             $oModel->contr_id = $model->contr_id;
             $oModel->groupcorp = $other['groupcorp'];
             $oModel->pay = $other['pay'];
             $oModel->insurance = $other['insurance'];
             $oModel->group = $other['group'];
             if (!empty($other['goldenweek'])) {
                 $oModel->goldenweek = $other['goldenweek'];
             }
             if (!empty($other['controversy'])) {
                 $oModel->controversy = $other['controversy'];
             }
             $oModel->other = $other['other'];
             $oModel->effect = $other['effect'];
             $oModel->save();
         }
         $tran->commit();
     } catch (Exception $e) {
         $tran->rollBack();
         throw $e;
     }
 }