|
|
@@ -1982,6 +1982,7 @@ class Fullorderexcel extends Start_Controller {
|
|
|
'typeclass_lhdycc'=>$typeclass_lhdycc,
|
|
|
'goods_sku_list'=>$goods_sku_list,
|
|
|
'typeclass'=>$typeclass,
|
|
|
+ 'shopqz_list'=>$shopqz_list,
|
|
|
];
|
|
|
$dlz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorder',$extra);
|
|
|
$tt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordertt',$extra);
|
|
|
@@ -2013,12 +2014,35 @@ class Fullorderexcel extends Start_Controller {
|
|
|
public function _datahz($where,$field,$order_str,$sj,$extra){
|
|
|
$goods_sku_list = $extra['goods_sku_list'] ;
|
|
|
$typeclass = $extra['typeclass'];
|
|
|
- //取得信息列表,防止SQL字段不存在导致程序崩溃
|
|
|
- try {
|
|
|
- $info_list = $this->$sj->find_all($where,$field,$order_str);
|
|
|
- } catch (Throwable $e) {
|
|
|
- $info_list = array();
|
|
|
+ $shopqz_list = $extra['shopqz_list'];
|
|
|
+ //检查$field中的字段是否在表中存在,不存在的字段设置为空值
|
|
|
+ $table = $this->$sj->table;
|
|
|
+ $table_fields = $this->db->list_fields($table);
|
|
|
+ $field_arr = explode(',',$field);
|
|
|
+ $new_field_arr = array();
|
|
|
+ foreach($field_arr as $f){
|
|
|
+ $f = trim($f);
|
|
|
+ //处理带as别名的字段,如 "extra_price as subtotal"
|
|
|
+ if(preg_match('/^(.*?)\s+as\s+(.+)$/i',$f,$matches)){
|
|
|
+ $real_field = trim($matches[1]);
|
|
|
+ $alias = trim($matches[2]);
|
|
|
+ if(in_array($real_field,$table_fields)){
|
|
|
+ $new_field_arr[] = $f; //保留原始的 "field as alias" 语句
|
|
|
+ }else{
|
|
|
+ $new_field_arr[] = "'' as ".$alias; //字段不存在,设为空值
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //不带as的普通字段
|
|
|
+ if(in_array($f,$table_fields)){
|
|
|
+ $new_field_arr[] = $f;
|
|
|
+ }else{
|
|
|
+ $new_field_arr[] = "'' as ".$f; //字段不存在,设为空值
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ $field = implode(',',$new_field_arr);
|
|
|
+ //取得信息列表
|
|
|
+ $info_list = $this->$sj->find_all($where,$field,$order_str);
|
|
|
//格式化数据
|
|
|
$i = 1;$shouldmoney = 0;$hl=1;
|
|
|
$usp = $extra['usp'];
|
|
|
@@ -2113,11 +2137,13 @@ class Fullorderexcel extends Start_Controller {
|
|
|
if(isset($value['subtotal'])){
|
|
|
$tmp_sub_str = "";
|
|
|
$subtotal_list = json_decode($value['subtotal'],true);
|
|
|
- foreach($subtotal_list as $v){
|
|
|
- if(isset($v['sub_total'])){
|
|
|
- $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
|
|
|
- }else{
|
|
|
- $tmp_sub_str .= "0<br>";
|
|
|
+ if(is_array($subtotal_list)){
|
|
|
+ foreach($subtotal_list as $v){
|
|
|
+ if(isset($v['sub_total'])){
|
|
|
+ $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
|
|
|
+ }else{
|
|
|
+ $tmp_sub_str .= "0<br>";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$info_list[$key]['subtotal'] = $tmp_sub_str;
|
|
|
@@ -2125,11 +2151,13 @@ class Fullorderexcel extends Start_Controller {
|
|
|
if(isset($value['rowtotal'])){
|
|
|
$tmp_sub_str = "";
|
|
|
$subtotal_list = json_decode($value['rowtotal'],true);
|
|
|
- foreach($subtotal_list as $v){
|
|
|
- if(isset($v['row_total'])){
|
|
|
- $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
|
|
|
- }else{
|
|
|
- $tmp_sub_str .= "0<br>";
|
|
|
+ if(is_array($subtotal_list)){
|
|
|
+ foreach($subtotal_list as $v){
|
|
|
+ if(isset($v['row_total'])){
|
|
|
+ $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
|
|
|
+ }else{
|
|
|
+ $tmp_sub_str .= "0<br>";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$info_list[$key]['rowtotal'] = $tmp_sub_str;
|
|
|
@@ -2140,6 +2168,7 @@ class Fullorderexcel extends Start_Controller {
|
|
|
$jmlist_nocc = '';
|
|
|
$classid = $this->classid->sku();
|
|
|
$dbapi = explode(';',trim($value['dbapinocc'],';'));
|
|
|
+ if(empty($value['dbapinocc'])) $dbapi = array();
|
|
|
foreach ($dbapi as $va)
|
|
|
{
|
|
|
$jm_nocc = $classid;
|
|
|
@@ -2228,11 +2257,13 @@ class Fullorderexcel extends Start_Controller {
|
|
|
if(isset($value['product_id'])){
|
|
|
$tmp_product_id = "";
|
|
|
$product_ids = json_decode($value['product_id'],true);
|
|
|
- foreach($product_ids as $v){
|
|
|
- if(isset($v['product_id'])){
|
|
|
- $tmp_product_id .= $v['product_id']."<br>";
|
|
|
- }else{
|
|
|
- $tmp_product_id .= "<br>";
|
|
|
+ if(is_array($product_ids)){
|
|
|
+ foreach($product_ids as $v){
|
|
|
+ if(isset($v['product_id'])){
|
|
|
+ $tmp_product_id .= $v['product_id']."<br>";
|
|
|
+ }else{
|
|
|
+ $tmp_product_id .= "<br>";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$info_list[$key]['product_id'] = $tmp_product_id;
|
|
|
@@ -2313,6 +2344,7 @@ class Fullorderexcel extends Start_Controller {
|
|
|
if(isset($value['ccfpdata']))
|
|
|
{
|
|
|
$ccfpdata = explode(';',$value['fpdata']);
|
|
|
+ if(empty($value['fpdata'])) $ccfpdata = array();
|
|
|
$inc = 0;
|
|
|
foreach ($ccfpdata as $v)
|
|
|
{
|
|
|
@@ -2642,6 +2674,7 @@ class Fullorderexcel extends Start_Controller {
|
|
|
$jmlist = '';$shuliang = '';
|
|
|
$classid = $this->classid->sku();
|
|
|
$dbapi = explode(';',trim($value['fpdata'],';'));
|
|
|
+ if(empty($value['fpdata'])) $dbapi = array();
|
|
|
foreach ($dbapi as $va)
|
|
|
{
|
|
|
$pm = $classid;
|
|
|
@@ -2735,6 +2768,7 @@ class Fullorderexcel extends Start_Controller {
|
|
|
$jmlist = '';$shuliang = '';
|
|
|
$classid = $this->classid->sku();
|
|
|
$dbapi = explode(';',trim($value['fpdata'],';'));
|
|
|
+ if(empty($value['fpdata'])) $dbapi = array();
|
|
|
foreach ($dbapi as $va)
|
|
|
{
|
|
|
$pm = $classid;
|
|
|
@@ -2822,6 +2856,7 @@ class Fullorderexcel extends Start_Controller {
|
|
|
{
|
|
|
$fpread = '';
|
|
|
$cpfpdata = explode(';',trim($value['fpdata'],';'));
|
|
|
+ if(empty($value['fpdata'])) $cpfpdata = array();
|
|
|
foreach ($cpfpdata as $v)
|
|
|
{
|
|
|
$va = explode('|',trim($v,'|'));
|