|
@@ -146,6 +146,10 @@ class StatSaleClass extends BaseClass
|
|
|
|
|
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
|
|
+ // sendTime 不代表成交,发货口径只统计已确认付款
|
|
|
|
|
+ if ($timeType === 'send') {
|
|
|
|
|
+ $where['payStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, 'id,name,py', 'id');
|
|
$customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, 'id,name,py', 'id');
|
|
|
|
|
|
|
@@ -260,6 +264,8 @@ class StatSaleClass extends BaseClass
|
|
|
* 采购跨天售后:不改「花材采购」入库口径;通过日单独「采购隔天退货」(退货并退款+仅退款合计)计入收入。
|
|
* 采购跨天售后:不改「花材采购」入库口径;通过日单独「采购隔天退货」(退货并退款+仅退款合计)计入收入。
|
|
|
* timeType=bill(默认):销售按 payTime、采购按 entryTime、支出按 payTime;
|
|
* timeType=bill(默认):销售按 payTime、采购按 entryTime、支出按 payTime;
|
|
|
* timeType=send:销售/采购/支出均按 sendTime。
|
|
* timeType=send:销售/采购/支出均按 sendTime。
|
|
|
|
|
+ * 发货口径须补成功态:xhGhsOrder/xhOrder 加 payStatus=1,xhGhsCgOrder 加 status=4,xhExpend 加 delStatus=0
|
|
|
|
|
+ * (sendTime 开单即可写入,不代表成交;payTime/entryTime 本身即成功时间)。
|
|
|
* 仅切换 xhGhsOrder / xhOrder / xhGhsCgOrder / xhExpend,其它统计项时间字段不变。
|
|
* 仅切换 xhGhsOrder / xhOrder / xhGhsCgOrder / xhExpend,其它统计项时间字段不变。
|
|
|
*/
|
|
*/
|
|
|
public static function profile($mainId)
|
|
public static function profile($mainId)
|
|
@@ -297,7 +303,7 @@ class StatSaleClass extends BaseClass
|
|
|
//出库
|
|
//出库
|
|
|
$stockOut = StatStockOutClass::getSum($where);
|
|
$stockOut = StatStockOutClass::getSum($where);
|
|
|
|
|
|
|
|
- //采购入库(xhGhsCgOrder)
|
|
|
|
|
|
|
+ //采购入库(xhGhsCgOrder):status=4 已入库;发货口径也必须带,因为 sendTime 不代表已入库
|
|
|
$cgWhere = ['mainId' => $mainId, 'status' => 4];
|
|
$cgWhere = ['mainId' => $mainId, 'status' => 4];
|
|
|
$cgWhere[$cgTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$cgWhere[$cgTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$cgList = PurchaseOrderClass::getAllByCondition($cgWhere, null, '*');
|
|
$cgList = PurchaseOrderClass::getAllByCondition($cgWhere, null, '*');
|
|
@@ -366,6 +372,10 @@ class StatSaleClass extends BaseClass
|
|
|
$pfPack = 0;
|
|
$pfPack = 0;
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
|
|
+ // sendTime 不代表成交,发货口径只统计已确认付款
|
|
|
|
|
+ if ($useSendTime) {
|
|
|
|
|
+ $where['payStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
if (!empty($ghsOrderList)) {
|
|
if (!empty($ghsOrderList)) {
|
|
@@ -406,6 +416,10 @@ class StatSaleClass extends BaseClass
|
|
|
$lsServiceFee = 0;
|
|
$lsServiceFee = 0;
|
|
|
$hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
|
|
$hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$hdWhere[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$hdWhere[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
|
|
+ // sendTime 不代表成交,发货口径只统计已确认付款(xhOrder.payStatus=1)
|
|
|
|
|
+ if ($useSendTime) {
|
|
|
|
|
+ $hdWhere['payStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
$hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
|
|
$hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
|
|
|
foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
|
$actPrice = $hdOrder['mainPay'] ?? 0;
|
|
$actPrice = $hdOrder['mainPay'] ?? 0;
|
|
@@ -454,6 +468,7 @@ class StatSaleClass extends BaseClass
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 支出:delStatus=0 未删除;发货口径也必须带,因为 sendTime 不代表单据有效
|
|
|
$condition = [
|
|
$condition = [
|
|
|
'mainId' => $mainId,
|
|
'mainId' => $mainId,
|
|
|
$expendTimeField => ['between', [$currentStartTime, $currentEndTime]],
|
|
$expendTimeField => ['between', [$currentStartTime, $currentEndTime]],
|
|
@@ -887,6 +902,7 @@ class StatSaleClass extends BaseClass
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// timeType=bill:销售 payTime、采购 entryTime;send:均按 sendTime
|
|
// timeType=bill:销售 payTime、采购 entryTime;send:均按 sendTime
|
|
|
|
|
+ // 发货口径销售须补 payStatus=1、采购须 status=4(sendTime 不代表成交/入库)
|
|
|
$timeType = isset($get['timeType']) ? strval($get['timeType']) : 'bill';
|
|
$timeType = isset($get['timeType']) ? strval($get['timeType']) : 'bill';
|
|
|
$useSendTime = ($timeType === 'send');
|
|
$useSendTime = ($timeType === 'send');
|
|
|
$saleTimeField = $useSendTime ? 'sendTime' : 'payTime';
|
|
$saleTimeField = $useSendTime ? 'sendTime' : 'payTime';
|
|
@@ -905,7 +921,7 @@ class StatSaleClass extends BaseClass
|
|
|
$totalDiscountAmount = 0;
|
|
$totalDiscountAmount = 0;
|
|
|
$totalLabourCost = 0;
|
|
$totalLabourCost = 0;
|
|
|
|
|
|
|
|
- //采购入库
|
|
|
|
|
|
|
+ //采购入库:status=4 已入库;发货口径也必须带,sendTime 不代表已入库
|
|
|
$tbCgIncome = [];
|
|
$tbCgIncome = [];
|
|
|
$tbCgIncomeStaff = [];
|
|
$tbCgIncomeStaff = [];
|
|
|
$cgWhere = ['mainId' => $mainId, 'status' => 4];
|
|
$cgWhere = ['mainId' => $mainId, 'status' => 4];
|
|
@@ -1051,6 +1067,10 @@ class StatSaleClass extends BaseClass
|
|
|
$tbSaleIncomeStaff = [];
|
|
$tbSaleIncomeStaff = [];
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
|
|
+ // sendTime 不代表成交,发货口径只统计已确认付款
|
|
|
|
|
+ if ($useSendTime) {
|
|
|
|
|
+ $where['payStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
if (!empty($ghsOrderList)) {
|
|
if (!empty($ghsOrderList)) {
|
|
|
foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
|
|
foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
|
|
@@ -1180,6 +1200,10 @@ class StatSaleClass extends BaseClass
|
|
|
$lsIncome = 0;
|
|
$lsIncome = 0;
|
|
|
$hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
|
|
$hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$hdWhere[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$hdWhere[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
|
|
+ // sendTime 不代表成交,发货口径只统计已确认付款(xhOrder.payStatus=1)
|
|
|
|
|
+ if ($useSendTime) {
|
|
|
|
|
+ $hdWhere['payStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
$hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
|
|
$hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
|
|
|
foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
foreach ($hdOrderList as $hdKey => $hdOrder) {
|
|
|
$actPrice = $hdOrder['mainPay'] ?? 0;
|
|
$actPrice = $hdOrder['mainPay'] ?? 0;
|
|
@@ -1659,6 +1683,10 @@ class StatSaleClass extends BaseClass
|
|
|
|
|
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
$where[$saleTimeField] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
|
|
+ // sendTime 不代表成交,发货口径只统计已确认付款
|
|
|
|
|
+ if ($timeType === 'send') {
|
|
|
|
|
+ $where['payStatus'] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, 'id,name,distId', 'id');
|
|
$customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, 'id,name,distId', 'id');
|
|
|
|
|
|