Пример #1
0
 /**
  * 卖家违约流程 
  * @param array $data 交易结果表全部字段的记录
  */
 public function main(array $data)
 {
     if (!in_array($data['t_status'], array(2, 4))) {
         throw new \Exception('交易状态错误不能执行违约操作');
     }
     $dn = $data['t_dn'];
     $money = $data['t_now_price'];
     $buyer = $data['t_buyer'];
     $seller = $data['t_enameId'];
     $sellerOrderId = $data['t_seller_order'];
     //卖家保证金订单
     $orderId = $this->createOrder($dn, $money, $buyer, $seller, $sellerOrderId);
     if (!$orderId) {
         return false;
         //违约失败
     }
     // 设置卖家违约
     $newTao = new \NewTaoModel();
     $newTao->updateTrans(array("t_status" => 7), array("t_id" => $data['t_id']));
     // 如果是我司域名 解锁域名
     if (1 == $data['t_is_out']) {
         $domains = new \common\Domain();
         $domains->lockDomain($data['t_dn'], 1);
     }
     // 如果买家已经确认 取消买家支付订单 一口价买家肯定是确认状态
     $finance = new \finance\Orders($buyer);
     if (!$finance->cancelOrder($data['t_order_id'])) {
         //log
     }
     // 如果买家未确认 取消买家保证金订单 一口价没有这个 竞价才有这个
     // 确认违约订单
     // $moneyType['UNWITHDRAWAL']
     $finance = new \finance\Orders($seller);
     if ($finance->confirmOrder($orderid, 2, $buyer)) {
         //log
     }
     // 违约是否要评论
     //移动交易记录 到历史表
     $newHistory = new \NewTransHistoryModel();
     if (!$newHistory->setTransHistory($data)) {
         //log
     }
     // 通知卖家
     $nowTime = date('Y-m-d H:i:s');
     $message = new \common\Message();
     $message->sendAuctionBuyerrefuseSeller($dn, $nowTime, $id, $seller);
     // 通知买家
     $message->sendAuctionBuyerrefuseBuyer($dn, $nowTime, $id, $buyer);
     return true;
 }
Пример #2
0
 /**
  * 判断一口价交易卖家是否违约
  */
 public function IndexAction()
 {
     $limit = 100;
     $condition = array('t_status' => 4, 't_end_time <' => time());
     $transResult = new \NewTransResultModel();
     $data = $transResult->getListByWhere($condition, '0,100', '*');
     $domains = new \common\Domain();
     foreach ($data as $v) {
         $transId = $v['t_id'];
         // 判断域名是否在卖家ID下
         $result = $domains->checkDnInUser($v['t_enameId'], $v['t_dn']);
         // 如果如果存在 则执行“一口价交易流程”
         if ($result) {
             $lock = $domains->lockDomain($v['t_dn'], 2);
             // 设置成交易状态
             if (!$lock) {
                 Logger::write('buynowtask_index', 'lock domain false ' . $v['t_id'] . '-' . $v['t_dn'] . '--' . $lock[1]);
                 continue;
             }
             $finance = new \finance\Orders($v['t_enameId']);
             if (!$finance->cancelOrder($v['t_seller_order'])) {
                 Logger::write('buynowtask_index', 'cancel order false .' . $v['t_seller_order']);
             }
             //PUSH域名
             $domains->PushDomain($v['t_enameId'], $v['t_buyer'], $v['t_dn']);
             //确认订单 扣掉买家的钱给卖家
             unset($finance);
             $finance = new \finance\Orders($v['t_buyer']);
             $finance->confirmOrder($v['t_order_id'], $v['t_money_type'], $v['t_enameId']);
             //更新关注表
             $transLogic = new \TransLogic();
             $transLogic->updateWatchInfo($v['t_id'], $v['t_now_price']);
             $messageObj = new \common\Message();
             //通知卖家
             $sms = (new \common\Users())->noticeSellerIsOk($v['t_enameId'], 'T204');
             $messageObj->sendBuyNowSeller($v['t_enameId'], $v['t_dn'], $v['t_now_price'], $v['t_id'], $sms);
             //通知买家
             $messageObj->sendBuyNowBuyer($v['t_buyer'], $v['t_dn'], $v['t_now_price'], $v['t_id']);
         } else {
             Logger::write('buynowtask_index', 'lock domain false not at user id ' . $v['t_id'] . '-' . $v['t_dn']);
             $trans = new \trans\Weiyue();
             $trans->main($v);
         }
     }
 }