@@ -18,9 +20,9 @@ class OrderGoodsModel extends \DAO\AbstractModel {
...
@@ -18,9 +20,9 @@ class OrderGoodsModel extends \DAO\AbstractModel {
* @var string
* @var string
*/
*/
protected$_tableName='han_order_goods';
protected$_tableName='han_order_goods';
public$sumField="rec_id,store_id as storeId,buyer_id as buyerId,goods_num as goodsNum,goods_price as goodsPrice,gmt_create as gmtCreate,order_id as orderId";
public$sumField="rec_id,store_id as storeId,buyer_id as buyerId,goods_num as goodsNum,goods_price as goodsPrice,gmt_create as gmtCreate,order_id as orderId";
public$groupField=array('buyer_id','store_id');
public$groupField=array('buyer_id','store_id');
public$sumGoodsNum=' store_id as storeId,buyer_id as buyerId,sum(goods_num) as orderGoodsCount';
public$sumGoodsNum=' store_id as storeId,buyer_id as buyerId,sum(goods_num) as orderGoodsCount';
public$orderGoodsField="order_id as orderId,rec_id as recId,goods_id as goodsId,goods_name as goodsName,goods_price as goodsPrice,goods_num as goodsNum,goods_image as goodsImage,goods_pay_price as goodsPayPrice,sale_act_id as saleActId,sale_id as saleId,comment_state as commentState,is_refund as isRefund,goods_spec as goodsSpec,refund_state_name as refundStateName,refund_id as refundId,goods_commonid as goodsCommonId,goods_commonid as goodsCommonid,goods_group as goodsGroup";
public$orderGoodsField="order_id as orderId,rec_id as recId,goods_id as goodsId,goods_name as goodsName,goods_price as goodsPrice,goods_num as goodsNum,goods_image as goodsImage,goods_pay_price as goodsPayPrice,sale_act_id as saleActId,sale_id as saleId,comment_state as commentState,is_refund as isRefund,goods_spec as goodsSpec,refund_state_name as refundStateName,refund_id as refundId,goods_commonid as goodsCommonId,goods_commonid as goodsCommonid,goods_group as goodsGroup";
/**
/**
* 主键
* 主键
...
@@ -29,193 +31,232 @@ class OrderGoodsModel extends \DAO\AbstractModel {
...
@@ -29,193 +31,232 @@ class OrderGoodsModel extends \DAO\AbstractModel {
*/
*/
protected$_primaryKey='rec_id';
protected$_primaryKey='rec_id';
public$orderGoodsGoodsNumCountField=" sum(goods_num) as goodsNum";
public$orderGoodsGoodsNumCountField=" sum(goods_num) as goodsNum";
$baseSql="insert IGNORE into {$this->_tableName}(order_id,store_id,goods_id,goods_name,goods_num,goods_image,goods_price,goods_pay_price,buyer_id,snapshot_id,goods_spec,goods_commonid,gc_id,gc_id_1,gc_id_2,gc_id_3,gmt_create,gmt_update,sale_act_id,sale_id,goods_group) values";
$baseSql="insert IGNORE into {$this->_tableName}(order_id,store_id,goods_id,goods_name,goods_num,goods_image,goods_price,goods_pay_price,buyer_id,snapshot_id,goods_spec,goods_commonid,gc_id,gc_id_1,gc_id_2,gc_id_3,gmt_create,gmt_update,sale_act_id,sale_id,goods_group) values";
$selectSql=Common::format("select {0} from {1} where store_id={2} and buyer_id={3} and is_refund<>{4} and order_id in (select order_id from han_order where store_id={2} and buyer_id={3} and order_state not in({5}) ) ",$this->sumGoodsNum,$this->_tableName,$storeId,$memberId,ApiConst::refundSuccess,"0,-1");
$selectSql=Common::format("select {0} from {1} where store_id={2} and buyer_id={3} and is_refund<>{4} and order_id in (select order_id from han_order where store_id={2} and buyer_id={3} and order_state not in({5}) ) ",$this->sumGoodsNum,$this->_tableName,$storeId,$memberId,ApiConst::refundSuccess,"0,-1");
}else{
}else{
$selectSql=Common::format("select {0} from {1} where store_id={2} and is_refund<>{4} and order_id in (select order_id from han_order where store_id={2} and order_state not in({5}) ) ",$this->sumGoodsNum,$this->_tableName,$storeId,$memberId,ApiConst::refundSuccess,"0,-1");
$selectSql=Common::format("select {0} from {1} where store_id={2} and is_refund<>{4} and order_id in (select order_id from han_order where store_id={2} and order_state not in({5}) ) ",$this->sumGoodsNum,$this->_tableName,$storeId,$memberId,ApiConst::refundSuccess,"0,-1");