trippest 各渠道重复的订单

feature/pay
lyt 7 years ago
parent 5081bf0921
commit 685484f822

@ -227,6 +227,7 @@ class TulanduoApi extends CI_Controller
$this->Orders_model->biz_groupcombineinfo_save();
}
}
log_message('error',"Got order list from TuLanDuo. count: " . $resp_arr["responseData"]["totalRows"] . " Insert COLI : " . $cnt);
echo "Got order list from TuLanDuo. count: " . $resp_arr["responseData"]["totalRows"] . "\r\n";
echo "Insert COLI : " . $cnt . "\r\n";
return;
@ -239,6 +240,9 @@ class TulanduoApi extends CI_Controller
*/
public function insert_HT_order_operation($coli_sn=null)
{
// if ($coli_sn == null) {
// return null;
// }
log_message('error','get_order_operation From TuLanDuo ');
$this->load->model('Order_update');
if ($coli_sn !== null) {
@ -247,11 +251,12 @@ class TulanduoApi extends CI_Controller
// $startDate = ('2018-04-21');
// $endDate = ('2018-04-22'); // test
$startDate = date('Y-m-d');
$endDate = date('Y-m-d', strtotime("+4 days"));
$endDate = date('Y-m-d', strtotime("+7 days"));
$to_update_list = $this->Orders_model->get_groupCombineInfo(0, $startDate, $endDate);
}
$unique_orderGroupCombine = array();
$unique_order = array();
$cnt = 0;
foreach ($to_update_list as $key => $order) {
if (in_array($order->GCI_VendorOrderId, $unique_order)) {
continue;
@ -295,43 +300,64 @@ class TulanduoApi extends CI_Controller
}
/** HT 开始 */
/** UPDATE */
/** BIZ_ConfirmLineInfo */
$this->Order_update->coli_where_update = " COLI_SN=" . $order->COLI_SN;
$old_memo = mb_strstr($order->COLI_Memo, "orderRemark", true)!==false ? mb_strstr($order->COLI_Memo, "orderRemark", true) : $order->COLI_Memo;
$new_memo = trim($detail_jsonResp->orderDetail->orderRemark)=="" ? $old_memo : $old_memo . " orderRemark\r\n" . $detail_jsonResp->orderDetail->orderRemark . "\r\n";
$old_detail = mb_strstr($order->COLI_OrderDetailText, "operations", true)!==false ? mb_strstr($order->COLI_OrderDetailText, "operations", true) : $order->COLI_OrderDetailText;
$new_detail = trim($allDetails_to_HT)=="" ? $old_detail : $old_detail . " operations\r\n" . $allDetails_to_HT . "\r\n";
$coli_update_column = array(
"COLI_Memo" => $new_memo
,"COLI_OrderDetailText" => $new_detail
);
$this->Order_update->biz_confirmlineinfo_update($coli_update_column);
/** BIZ_ConfirmLineDetail */ // nothing to update
/** biz_groupcombineinfo */
$this->Order_update->gci_where_update = " GCI_SN=" . $order->GCI_SN;
$cnt++;
$vei_SN = $this->city_info[$detail_jsonResp->orderDetail->operationDep]['PlanVEI_SN'] ? $this->city_info[$detail_jsonResp->orderDetail->operationDep]['PlanVEI_SN'] : $order->COLD_PlanVEI_SN;
$getInfo_byGroupCode = null;
if (in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest"))) {
$real_groupCode = $this->analysis_groupCode($detail_jsonResp->orderDetail->agcOrderNo);
$getInfo_byGroupCode = $this->Orders_model->get_SN_by_groupCode($real_groupCode, $real_groupCode);
}
$groupSN = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->GRI_SN : $order->COLI_GRI_SN;
$coli_sn = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_SN : $order->COLI_SN;
$coli_id = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_ID : $order->COLI_ID;
$coli_memo = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_Memo : $order->COLI_Memo;
$coli_orderdetailtext = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_OrderDetailText : $order->COLI_OrderDetailText;
$cold_sn = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLD_SN : $order->COLD_SN;
// HT 订单有重复时, 以图兰朵的团号为正确的订单, 原本已录入的设为无效
if ($getInfo_byGroupCode === null) {
} elseif ($getInfo_byGroupCode->GRI_SN != $order->COLI_GRI_SN && in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest"))) {
log_message('error','原订单' . $order->COLI_ID);
$allDetails_to_HT .= "\r\n疑似重复,请更新订单状态:" . $order->COLI_ID;
$this->order_cancel($order->COLI_ID);
}
/** biz_groupcombineinfo */
$this->Order_update->gci_where_update = " GCI_VEI_SN=$vei_SN and GCI_VendorOrderId='" . $detail_jsonResp->orderDetail->orderId . "'";
$gci_update_column = array(
"GCI_combineNo" => isset($detail_jsonResp->orderDetail->groupOrderNo) ? $detail_jsonResp->orderDetail->groupOrderNo : null
,"GCI_VEI_SN" => $vei_SN
,"GCI_GRI_SN" => $groupSN
,"GCI_travelDate" => $detail_jsonResp->orderDetail->travelDate
,"GCI_leaveDate" => $detail_jsonResp->orderDetail->leaveDate
,"GCI_createTime" => date('Y-m-d H:i:s')
);
$this->Order_update->biz_groupcombineinfo_update($gci_update_column);
/** BIZ_ConfirmLineInfo */
$this->Order_update->coli_where_update = " COLI_SN=" . $coli_sn;
$old_memo = mb_strstr($coli_memo, " orderRemark", true)!==false ? mb_strstr($coli_memo, " orderRemark", true) : $coli_memo;
$new_memo = trim($detail_jsonResp->orderDetail->orderRemark)=="" ? $old_memo : $old_memo . " orderRemark\r\n" . $detail_jsonResp->orderDetail->orderRemark . "\r\n";
$old_detail = mb_strstr($coli_orderdetailtext, " operations", true)!==false ? mb_strstr($coli_orderdetailtext, " operations", true) : $coli_orderdetailtext;
$new_detail = trim($allDetails_to_HT)=="" ? $old_detail : $old_detail . " operations\r\n" . $allDetails_to_HT . "\r\n";
$coli_update_column = array(
"COLI_Memo" => $new_memo
,"COLI_OrderDetailText" => $new_detail
,"COLI_State" => 7
);
$this->Order_update->biz_confirmlineinfo_update($coli_update_column);
/** BIZ_ConfirmLineDetail */ // nothing to update
/** INSERT */
/*BIZ_BookPeople*/
if ($this->Orders_model->bookpeople_exist($order->COLD_SN) === array()) {
if ($this->Orders_model->bookpeople_exist($cold_sn) === array()) {
foreach ($detail_jsonResp->orderDetail->customers as $kd => $vd) {
$this->Orders_model->BPE_FirstName = $vd->name;
$this->Orders_model->BPE_GuestType = $vd->peopleType=="成人" ? 1 : 2;
$this->Orders_model->BPE_Passport = $vd->documentNo;
$bpe_sn[] = $this->Orders_model->biz_book_people_save();
// BIZ_BookPeopleList
$this->Orders_model->biz_bookpeople_List_save($order->COLD_SN, $this->Orders_model->BPE_SN);
$this->Orders_model->biz_bookpeople_List_save($cold_sn, $this->Orders_model->BPE_SN);
}
}
/*BIZ_PackageOrderInfo*/
$this->Orders_model->POI_COLD_SN = $order->COLD_SN;
$this->Orders_model->POI_COLD_SN = $cold_sn;
$this->Orders_model->POI_Time = $detail_jsonResp->orderDetail->travelDate;
$this->Orders_model->POI_Hotel = $detail_jsonResp->orderDetail->scheduleDetails[0]->accommodation;
$this->Orders_model->POI_HotelAddress = $detail_jsonResp->orderDetail->scheduleDetails[0]->accommodationAddress;
@ -343,20 +369,24 @@ class TulanduoApi extends CI_Controller
// 团款, 只有其他社的订单, 目的地项目组的团款已经直接收入海纳账户
$paytype = 15006; // 地接代收
$pay_currency = 'RMB';
$auto_text = "dataAutoEnter ";
// 删除旧的录入
$this->Orders_model->biz_groupaccountinfo_cut($order->COLI_SN, $paytype);
$this->Orders_model->biz_groupaccountinfo_cut($coli_sn, $paytype);
if (isset($detail_jsonResp->orderDetail->travelFees) && ! in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest")) ) {
foreach ($detail_jsonResp->orderDetail->travelFees as $ktf => $vtf) {
// if ($vtf->reviewStatus == 0) { // 未审核的
// continue;
// }
$this->Orders_model->GAI_COLI_SN = $order->COLI_SN;
$this->Orders_model->GAI_GRI_SN = $order->COLI_GRI_SN;
$this->Orders_model->GAI_COLI_ID = $order->COLI_ID;
$this->Orders_model->GAI_Operator = 435;
$this->Orders_model->GAI_COLI_SN = $coli_sn;
$this->Orders_model->GAI_GRI_SN = $groupSN;
$this->Orders_model->GAI_COLI_ID = $coli_id;
$this->Orders_model->GAI_Type = $paytype;
$this->Orders_model->GAI_SQJE = $vtf->sumMoney;
$this->Orders_model->GAI_SQJECurrency = $pay_currency;
$this->Orders_model->GAI_Memo = $vtf->type . ", " . $vtf->remark;
$this->Orders_model->GAI_SSJE = $vtf->sumMoney;
$this->Orders_model->GAI_SSDate = date("Y-m-d H:i:s");
$this->Orders_model->GAI_Memo = $auto_text . "团款" . $vtf->type . ", " . $vtf->remark;
$this->Orders_model->biz_groupaccountinfo_save();
}
}
@ -366,13 +396,16 @@ class TulanduoApi extends CI_Controller
// if ($vrc->reviewStatus == 0) {
// continue;
// }
$this->Orders_model->GAI_COLI_SN = $order->COLI_SN;
$this->Orders_model->GAI_GRI_SN = $order->COLI_GRI_SN;
$this->Orders_model->GAI_COLI_ID = $order->COLI_ID;
$this->Orders_model->GAI_Operator = 435;
$this->Orders_model->GAI_COLI_SN = $coli_sn;
$this->Orders_model->GAI_GRI_SN = $groupSN;
$this->Orders_model->GAI_COLI_ID = $coli_id;
$this->Orders_model->GAI_Type = $paytype;
$this->Orders_model->GAI_SQJE = $vrc->money;
$this->Orders_model->GAI_SQJECurrency = $pay_currency;
$this->Orders_model->GAI_Memo = $vrc->type . ", " . $vrc->remark;
$this->Orders_model->GAI_SSJE = $vrc->money;
$this->Orders_model->GAI_SSDate = date("Y-m-d H:i:s");
$this->Orders_model->GAI_Memo = $auto_text . "代收" . $vrc->type . ", " . $vrc->remark;
$this->Orders_model->biz_groupaccountinfo_save();
}
}
@ -382,13 +415,16 @@ class TulanduoApi extends CI_Controller
// if ($vrp->reviewStatus == 0) {
// continue;
// }
$this->Orders_model->GAI_COLI_SN = $order->COLI_SN;
$this->Orders_model->GAI_GRI_SN = $order->COLI_GRI_SN;
$this->Orders_model->GAI_COLI_ID = $order->COLI_ID;
$this->Orders_model->GAI_Operator = 435;
$this->Orders_model->GAI_COLI_SN = $coli_sn;
$this->Orders_model->GAI_GRI_SN = $groupSN;
$this->Orders_model->GAI_COLI_ID = $coli_id;
$this->Orders_model->GAI_Type = $paytype;
$this->Orders_model->GAI_SQJE = "-" . $vrp->money;
$this->Orders_model->GAI_SQJECurrency = $pay_currency;
$this->Orders_model->GAI_Memo = $vrp->type . ", " . $vrp->remark;
$this->Orders_model->GAI_SSJE = $vrp->money;
$this->Orders_model->GAI_SSDate = date("Y-m-d H:i:s");
$this->Orders_model->GAI_Memo = $auto_text . $vrp->type . ", " . $vrp->remark;
$this->Orders_model->biz_groupaccountinfo_save();
}
}
@ -488,7 +524,8 @@ class TulanduoApi extends CI_Controller
}
}
} // end foreach order
echo "Got order from TuLanDuo, count: " . count($to_update_list);
log_message('error',"Got order operations from TuLanDuo, count: " . count($cnt));
echo "Got order operations from TuLanDuo, count: " . count($cnt);
return;
}
@ -499,9 +536,10 @@ class TulanduoApi extends CI_Controller
*/
public function order_cancel($COLI_ID="")
{
log_message('error','修改为不成行 order_cancel' . $COLI_ID);
/** UPDATE HT */
/** BIZ_ConfirmLineInfo */
$this->Order_update->coli_where_update = " COLI_ID=" . $COLI_ID;
$this->Order_update->coli_where_update = " COLI_ID='" . $COLI_ID . "'";
$coli_update_column = array(
"COLI_State" => 40
);

@ -487,7 +487,7 @@ class Orders_model extends CI_Model {
public function get_SN_by_groupCode($code, $NoName)
{
$sql = "SELECT top 1 COLI_SN,GRI_SN,cold.COLD_PlanVEI_SN
$sql = "SELECT top 1 COLI_SN,gri.GRI_SN,cold.COLD_PlanVEI_SN,cold.COLD_SN,coli.COLI_ID,coli.COLI_Memo,coli.COLI_OrderDetailText
FROM BIZ_ConfirmLineInfo coli
inner join BIZ_ConfirmLineDetail cold on cold.COLD_COLI_SN=COLI_SN
LEFT JOIN GRoupInfo gri ON coli.COLI_GRI_SN=gri.GRI_SN
@ -1169,10 +1169,8 @@ class Orders_model extends CI_Model {
*/
public function biz_groupaccountinfo_cut($coli_sn, $paytype)
{
$sql = "UPDATE BIZ_GroupAccountInfo
SET DeleteFlag=1
WHERE GAI_COLI_SN=?
AND GAI_Type=?";
$sql = "DELETE from BIZ_GroupAccountInfo
WHERE GAI_COLI_SN=? AND GAI_Type=? AND GAI_Operator = 435";
$query = $this->HT->query($sql, array($coli_sn, $paytype));
return $query;
}
@ -1189,6 +1187,9 @@ class Orders_model extends CI_Model {
public $GAI_SQJE;
public $GAI_SQDate;
public $GAI_SQJECurrency;
public $GAI_SSJE;
public $GAI_SSDate;
public $GAI_Operator;
public $GAI_Memo="";
public function biz_groupaccountinfo_save()
{
@ -1201,6 +1202,9 @@ class Orders_model extends CI_Model {
. " GAI_SQJE, \n"
. " GAI_SQDate, \n"
. " GAI_SQJECurrency, \n"
. " GAI_SSJE, \n"
. " GAI_SSDate, \n"
. " GAI_Operator, \n"
. " GAI_Memo \n"
. " ) \n"
. "VALUES \n"
@ -1212,6 +1216,9 @@ class Orders_model extends CI_Model {
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ? \n"
. " )";
$query = $this->HT->query($sql, array(
@ -1222,6 +1229,9 @@ class Orders_model extends CI_Model {
,$this->GAI_SQJE
,$this->GAI_SQDate
,$this->GAI_SQJECurrency
,$this->GAI_SSJE
,$this->GAI_SSDate
,$this->GAI_Operator
,$this->GAI_Memo
));
return $query;
@ -1704,18 +1714,8 @@ class Orders_model extends CI_Model {
public function test()
{
// return NULL;
$sql = "UPDATE groupcombineinfo
SET [GCI_VEI_SN]=1343
WHERE gci_vei_sn IS NULL
AND gci_sn IN
(SELECT gci.[GCI_SN]
FROM groupcombineinfo gci
INNER JOIN GRoupInfo gri ON gci.GCI_GRI_SN=gri.GRI_SN
INNER JOIN BIZ_ConfirmLineInfo coli ON GRI_SN=coli.COLI_GRI_SN
INNER JOIN BIZ_ConfirmLineDetail cold ON cold.COLD_COLI_SN=COLI_SN
WHERE 1=1
AND gci.gci_vei_sn IS NULL
AND COLD_PlanVEI_SN=1343)";
$sql = "
";
$query = $this->HT->query($sql);
}

Loading…
Cancel
Save