|
@@ -210,6 +210,9 @@ class TagGood extends Base{
|
|
|
if($taginfo['type']==3|| $taginfo['type']==4){
|
|
|
$this->qrdTag($taginfo['type'],$code,$total_fee);
|
|
|
}
|
|
|
+ if($taginfo['type']==5|| $taginfo['type']==6){
|
|
|
+ $this->cgdTag($taginfo['type'],$code,$total_fee);
|
|
|
+ }
|
|
|
$tagdata=[
|
|
|
"code"=>$code,
|
|
|
"tag_id"=>$tagid,
|
|
@@ -249,6 +252,10 @@ class TagGood extends Base{
|
|
|
if($tag['type']==3|| $tag['type']==4){
|
|
|
$message="销售单{$loginfo->code}{$tag->tag_name}";
|
|
|
$this->qrdReTag($tag['type'],$loginfo->code,$loginfo->tag_fee);
|
|
|
+ }
|
|
|
+ if($loginfo['type']==5|| $loginfo['type']==6){
|
|
|
+ $message="采购单{$loginfo->code}{$loginfo->tag_name}";
|
|
|
+ $this->cgdReTag($loginfo['type'],$loginfo->code);
|
|
|
}
|
|
|
$loginfo->status=0;
|
|
|
$loginfo->id=null;
|
|
@@ -280,6 +287,10 @@ class TagGood extends Base{
|
|
|
$message="销售单{$loginfo->code}{$loginfo->tag_name}";
|
|
|
$fee= $this->qrdReTag($loginfo['type'],$loginfo->code);
|
|
|
}
|
|
|
+ if($loginfo['type']==5|| $loginfo['type']==6){
|
|
|
+ $message="采购单{$loginfo->code}{$loginfo->tag_name}";
|
|
|
+ $fee= $this->cgdReTag($loginfo['type'],$loginfo->code);
|
|
|
+ }
|
|
|
$loginfo['status']=0;
|
|
|
$loginfo['tag_fee']=$fee;
|
|
|
unset($loginfo['addtime'],$loginfo['updatetime']);
|
|
@@ -430,18 +441,88 @@ class TagGood extends Base{
|
|
|
if($resulr==false)throw new \Exception('销售单更新失败');
|
|
|
return $fee;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $tagId 标签类型 3 回款4开票
|
|
|
+ * @param $code 销售单编号
|
|
|
+ * @param $total_fee 标签金额
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ */
|
|
|
+ private function cgdTag($tagId,$code,$total_fee){
|
|
|
+ $qrd=Db::name('cgd_info')->where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
|
|
|
+ if(empty($qrd)){
|
|
|
+ throw new \Exception('未找到销售单数据');
|
|
|
+ }
|
|
|
+ $update=['updatetime'=>date('Y-m-d H:i:s')];
|
|
|
+ if($tagId==5){
|
|
|
+ if($qrd['wpay_fee']+$qrd['pay_tag_fee']<$total_fee){
|
|
|
+ throw new \Exception('销售单未付金额不足');
|
|
|
+ }
|
|
|
+ $update['wpay_fee']=$qrd['wpay_fee']+$qrd['pay_tag_fee']-$total_fee;
|
|
|
+ $status = $update['wpay_fee']==0 ? 3:($qrd['apay_fee']==0?1:2);
|
|
|
+ $update['pay_tag_fee'] =$qrd['pay_tag_fee']+ $total_fee;
|
|
|
+ $update['pay_status'] = $status;
|
|
|
+ $update['pay_tag'] = 1;
|
|
|
+ }
|
|
|
+ if($tagId==6){
|
|
|
+ if($qrd['winv_fee']+$qrd['inv_tag_fee']<$total_fee){
|
|
|
+ throw new \Exception('销售单未开票金额不足');
|
|
|
+ }
|
|
|
+ $update['winv_fee']=$qrd['winv_fee']+$qrd['inv_tag_fee']-$total_fee;
|
|
|
+ $status = $update['winv_fee']==0 ? 3:($qrd['ainv_fee']==0?1:2);
|
|
|
+ $update['inv_tag_fee'] = $qrd['inv_tag_fee']+$total_fee;
|
|
|
+ $update['inv_status'] = $status;
|
|
|
+ $update['inv_tag'] = 1;
|
|
|
+ }
|
|
|
+ $resulr= Db::name('cgd_info')->where($qrd)->update($update);
|
|
|
+ if($resulr==false) throw new \Exception('标签添加失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 解除标签销售单
|
|
|
+ * @param $tagId 标签类型 3 回款4开票
|
|
|
+ * @param $code 销售单编号
|
|
|
+ * @param $total_fee 标签金额
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ */
|
|
|
+ private function cgdReTag($tagId,$code){
|
|
|
+ $qrd=QrdInfo::where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
|
|
|
+ if($qrd->isEmpty())throw new \Exception('未找到销售单数据');
|
|
|
+ $fee =0 ;
|
|
|
+ if($tagId==5){
|
|
|
+ if($qrd->pay_tag_fee<0)throw new \Exception('销售单回款标签金额不足');
|
|
|
+ $fee =$qrd->pay_tag_fee ;
|
|
|
+ $qrd->wpay_fee=$qrd->wpay_fee+$qrd->pay_tag_fee;
|
|
|
+ $qrd->pay_tag_fee=0;
|
|
|
+ $qrd->pay_status = $qrd->wpay_fee==0?3:($qrd->apay_fee==0?1:2);
|
|
|
+ $qrd->pay_tag=0;
|
|
|
+ }
|
|
|
+ if($tagId==6){
|
|
|
+ if($qrd->inv_tag_fee<0)throw new \Exception('销售单开票标签金额不足');
|
|
|
+ $fee =$qrd->inv_tag_fee ;
|
|
|
+ $qrd->winv_fee=$qrd->winv_fee+$qrd->inv_tag_fee;
|
|
|
+ $qrd->inv_tag_fee=0;
|
|
|
+ $qrd->inv_status = $qrd->winv_fee==0?3:($qrd->ainv_fee==0?1:2);
|
|
|
+ $qrd->inv_tag=0;
|
|
|
+ }
|
|
|
+ $resulr= $qrd->save();
|
|
|
+ if($resulr==false)throw new \Exception('销售单更新失败');
|
|
|
+ return $fee;
|
|
|
+ }
|
|
|
|
|
|
public function logList(){
|
|
|
$param = $this->request->param(["betweenTime"=>[],"customerNo"=>"","supplierNo"=>"",'companyNo'=>'',
|
|
|
"type"=>'',"status"=>"","orderCode"=>"","creater"=>"","order_type"=>0,"size"=>10,"page"=>1],"post","trim");
|
|
|
- $sbtable = $param['order_type']==2?'payInfo':'orderInfo';
|
|
|
- $where=[["tagInfo.type","in",$param['order_type']==2?[1,2]:[3,4]],["{$sbtable}.is_del","=",0],["tagInfo.is_del",'=',0]];
|
|
|
+ $modela=['','payInfo','orderInfo','cgdInfo'];
|
|
|
+ $sbtable = $modela[$param['order_type']];
|
|
|
+ $type = [[],[1,2],[3,4],[5,6]];
|
|
|
+ $where=[["tagInfo.type","in",$type[$param['order_type']]],["{$sbtable}.is_del","=",0],["tagInfo.is_del",'=',0]];
|
|
|
|
|
|
empty($param['betweenTime'])?:$where[]=["tag_log.addtime","between",$param['betweenTime']];
|
|
|
|
|
|
- if($param['order_type']==1)$param['customerNo']==""?:$where[]=["{$sbtable}.customerNo","like","%{$param['customerNo']}%"];
|
|
|
- if($param['order_type']==2)$param['supplierNo']==""?:$where[]=["{$sbtable}.supplierNo","like","%{$param['supplierNo']}%"];
|
|
|
+ if($param['order_type']==1)$param['customerNo']==""?:$where[]=["{$sbtable}.customerNo","like","%{$param['customerNo']}%"];
|
|
|
+ if($param['order_type']!=1)$param['supplierNo']==""?:$where[]=["{$sbtable}.supplierNo","like","%{$param['supplierNo']}%"];
|
|
|
$param['companyNo']==""?:$where[]=["{$sbtable}.companyNo","like","%{$param['companyNo']}%"];
|
|
|
$param['type']==''?:$where[]=["tagInfo.type","=",$param['type']];
|
|
|
$param['status']===""?:$where[]=["tag_log.status","=",$param['status']];
|