123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace app\api\controller\v1;
- use OpenApi\Annotations as OA;
- use app\BaseController;
- use thans\jwt\facade\JWTAuth;
- use think\exception\ValidateException;
- use think\facade\Request as re;
- use think\Request;
- use thans\jwt\JWT;
- use app\api\model\Chandi as ChandiModel;
- use app\api\model\Qy_basic;
- use app\api\model\Zd_cpmc;
- use app\api\model\Nszy as NszyModel;
- use think\File;
- use app\validate\Product as ProductValidate;
- use rsa\Rsa;
- class Product extends BaseController{
- use ResponseJson;
- protected $request;
- protected $middleware = [
- 'jwt' => ['except' => [] ],
- ];
- public function __construct(Request $request)
- {
- $this->request = $request;
- }
-
- public function AddProductInfo() {
- $data = $this->request->post();
- $qydm=$data['qydm'];
- $qy=Qy_basic::Where('qydm','=',$qydm)->find();
- if($qy){
- $jd=Zd_cpmc::field('cpbh')->where('qydm','=',$qydm)->select();
-
- $wz=count($jd) - 1;
-
- if(count($jd)){
- $x="1".$jd[$wz]['cpbh'];
- $y=intval($x)+1;
- $data["cpbh"]=substr($y,1);
- }else{
- $data["cpbh"]='001';
- }
-
-
- $result = Zd_cpmc::create($data);
- if($result) {
- return $this->jsonData(0,"添加成功");
- }else {
- return $this->jsonData(-1,"添加错误");
- }
- }
- else{
- return $this->jsonData(-2,"企业未注册");
- }
- }
-
- public function DelProductInfo(){
-
- $data = $this->request->post();
- $Zd_cpmc = new Zd_cpmc();
- $bh = $data['bh'];
- $del=$Zd_cpmc->delproduct($bh);
- if ($del == '1') {
- return $this->jsonData(
- 0,
- "删除成功"
- );
- } else {
- return $this->jsonData(-1, "删除失败");
- }
- }
-
- public function DoEditProductInfo() {
- $data = $this->request->post();
-
- $condition = ['bh'=>$data['bh']];
-
- $result = Zd_cpmc::update($data,$condition);
- if ($result) {
- return $this->jsonData(0,"修改成功");
- } else {
- return $this->jsonData(-1, "修改失败");
- }
- }
-
- public function QueryProductInfo(){
-
- $data = $this->request->post();
- $pageNum=$data['pageNum'];
- $pageSize=$data['pageSize'];
- $query=$data['query'];
- $qydm=$data['qydm'];
- if($query){
- $result['rows']=Zd_cpmc::where([
- ['cpmc', 'like', '%'.$query .'%'],
- ['t_zd_cpmc.qydm', '=', $qydm]
- ])
- ->field("t_zd_cpmc.*,t_qy_basic.qymc")
- ->leftjoin('t_qy_basic',' t_zd_cpmc.qydm=t_qy_basic.qydm')
- ->page($pageNum,$pageSize)
- ->select();
- $result['pages']=$pageNum;
- $result['total']=Zd_cpmc::where(
- [
- ['cpmc', 'like', '%'.$query .'%'],
- ['t_zd_cpmc.qydm', '=', $qydm]
- ]
- )
- ->select()
- ->count('bh');
- }
- else{
- $result['rows']=Zd_cpmc::where([
- ['t_zd_cpmc.qydm', '=', $qydm]
- ])
- ->field("t_zd_cpmc.*,t_qy_basic.qymc")
- ->leftjoin('t_qy_basic',' t_zd_cpmc.qydm=t_qy_basic.qydm')
- ->page($pageNum,$pageSize)
- ->select();
- $result['pages']=$pageNum;
- $result['total']=Zd_cpmc::where(
- [
- ['cpmc', 'like', '%'.$query .'%'],
- ['t_zd_cpmc.qydm', '=', $qydm]
- ]
- )
- ->select()
- ->count('bh');
- }
-
- if($result){
- return $this->jsonSuccessData($result);
- }
- else{
- return $this->jsonData('-1',"查询错误");
- }
- }
- }
|