Trippest账单:处理拼团号相同的情况

feature/trippest
lyt 6 years ago
parent f8ff0f8eb0
commit dc908f4edd

@ -227,20 +227,21 @@ class OrderFinance_model extends CI_Model {
}
/** 判断各种项目的报表是否已存在 */
public function report_tour_exists($coli_id=null, $tourCode=null, $tourBz=null)
public function report_tour_exists($coli_id=null, $cold_sn=null)
{
$sql = "SELECT top 10 ordernumber from report_tour where ordernumber=? ";
if ($tourBz) {
$tourBz = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]$', '', strstr($tourBz, ",", true));
if (stripos($tourBz, "pvt") === false) {
$tourBz = str_replace("]", "", $tourBz);
}
$tourBz = str_replace("[", "[[]", $tourBz);
$sql .= " and (tourBz like '%" . $this->HT->escape_like_str($tourBz) . "%'
OR tourBz='') ";
} else {
$sql .= " AND tourCode='" . $tourCode . "' ";
}
$sql .= $cold_sn===null ? " " : " and RPT_COLD_SN=$cold_sn ";
// if ($tourBz) {
// $tourBz = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]$', '', strstr($tourBz, ",", true));
// if (stripos($tourBz, "pvt") === false) {
// $tourBz = str_replace("]", "", $tourBz);
// }
// $tourBz = str_replace("[", "[[]", $tourBz);
// $sql .= " and (tourBz like '%" . $this->HT->escape_like_str($tourBz) . "%'
// OR tourBz='') ";
// } else {
// $sql .= " AND tourCode='" . $tourCode . "' ";
// }
$num_rows = $this->HT->query($sql, array($coli_id))->num_rows();
return $num_rows>0;
}
@ -268,15 +269,15 @@ class OrderFinance_model extends CI_Model {
{
foreach ($report_tour_arr as $krt => $vrt) {
$tourBz_tmp = "";
if ($this->report_tour_exists($vrt['ordernumber'], $vrt['tourCode'], $vrt['tourBZ']) === TRUE) {
$where = " ordernumber='" . $vrt['ordernumber'] . "' "; //AND tourCode='" . $vrt['tourCode'] . "' ";
$tourBz_tmp = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]$', '', strstr($vrt['tourBZ'], ",", true));
if (stripos($tourBz_tmp, "pvt") === false) {
$tourBz_tmp = str_replace("]", "", $tourBz_tmp);
}
$tourBz_tmp = str_replace("[", "[[]", $tourBz_tmp);
$where .= " AND (tourBZ like '%" . $this->HT->escape_like_str($tourBz_tmp) . "%'
OR tourBZ='') ";
if ($this->report_tour_exists($vrt['ordernumber'], $vrt['RPT_COLD_SN']) === TRUE) {
$where = " ordernumber='" . $vrt['ordernumber'] . "' and RPT_COLD_SN=".$vrt['RPT_COLD_SN'] ; //AND tourCode='" . $vrt['tourCode'] . "' ";
// $tourBz_tmp = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]$', '', strstr($vrt['tourBZ'], ",", true));
// if (stripos($tourBz_tmp, "pvt") === false) {
// $tourBz_tmp = str_replace("]", "", $tourBz_tmp);
// }
// $tourBz_tmp = str_replace("[", "[[]", $tourBz_tmp);
// $where .= " AND (tourBZ like '%" . $this->HT->escape_like_str($tourBz_tmp) . "%'
// OR tourBZ='') ";
$delete_sql = "DELETE FROM tourmanager.dbo.Report_Tour where " . $where;
// $update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where);
$this->HT->query($delete_sql);
@ -388,9 +389,9 @@ class OrderFinance_model extends CI_Model {
{
$other_tour_cost = $this->get_report_tour_others_cost($coli_sn);
foreach ($other_tour_cost as $kotc => $votc) {
if ($this->report_tour_exists($votc->ordernumber, $votc->tourCode, $votc->tourBZ) === TRUE) {
$where = " ordernumber='" . $votc->ordernumber . "' AND tourCode='" . $votc->tourCode . "'";
$where .= " AND tourBZ='" . $votc->tourBZ . "' ";
if ($this->report_tour_exists($votc->ordernumber, $votc->RPT_COLD_SN) === TRUE) {
$where = " ordernumber='" . $votc->ordernumber . "' AND RPT_COLD_SN=" . $votc->RPT_COLD_SN;
// $where .= " AND tourBZ='" . $votc->tourBZ . "' ";
$update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE), $where);
$this->HT->query($update_sql);
} else {
@ -432,6 +433,7 @@ class OrderFinance_model extends CI_Model {
ORDER BY PKP_PriceGrade
) as tourCostRSx,
dbo.BIZ_ConfirmLineDetail.COLD_TotalCost tourcost,
dbo.BIZ_ConfirmLineDetail.COLD_SN RPT_COLD_SN,
dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice) tourPrice,
dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice)-dbo.BIZ_ConfirmLineDetail.COLD_TotalCost as tourProfit,
SUBSTRING(isnull(dbo.VEndorInfo2.VEI2_CompanyBN,'.'),1,50) as tourProvide,

Loading…
Cancel
Save