龙收银开放平台标准API接口文档

openapi


单点登录

<p><strong>简要描述:</strong> </p> <ul> <li>单点登陆接口</li> </ul> <p><strong>请求URL:</strong> </p> <ul> <li><code>http://192.168.12.86login.html#/redirectManage?to=/home/shopManage&amp;shopId=15454&amp;shopKey=zr0SuAfo+bPs9HTyioAUTC9CkIOsfiB4qxjthVOToZ0xdP7QksZlDKv6+f8RyyDmBSLCGTRT57vx\r\ne37SmNtIIA==</code></li> </ul> <p><strong>请求方式:</strong></p> <ul> <li>POST </li> </ul> <p><strong>请求类型:</strong></p> <ul> <li>application/json </li> </ul> <p><strong>请求参数说明:</strong> </p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">必选</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">shopId</td> <td style="text-align: left;">是</td> <td style="text-align: left;">Integer</td> <td>门店ID</td> </tr> <tr> <td style="text-align: left;">shopKey</td> <td style="text-align: left;">是</td> <td style="text-align: left;">String</td> <td>加密登录信息</td> </tr> </tbody> </table> <p><strong>shopKey加密必要字段说明:</strong> </p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">必选</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">shopId</td> <td style="text-align: left;">是</td> <td style="text-align: left;">Integer</td> <td>门店ID</td> </tr> <tr> <td style="text-align: left;">thirdId</td> <td style="text-align: left;">是</td> <td style="text-align: left;">String</td> <td>第三方员工账号</td> </tr> <tr> <td style="text-align: left;">password</td> <td style="text-align: left;">是</td> <td style="text-align: left;">String</td> <td>第三方员工密码</td> </tr> </tbody> </table> <p><strong>请求示例</strong></p> <ul> <li>采用AES对称加密算法 </li> <li>密钥K:tcsl</li> </ul> <pre><code>//加密代码示例 package demo.security; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Base64; import java.util.Scanner; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public MessageBox testKey(@RequestBody ThirdShopInfoCnd thirdTokenCnd) { try{ //1.构造密钥生成器,指定为AES算法,不区分大小写 KeyGenerator keygen=KeyGenerator.getInstance("AES"); //2.根据ecnodeRules规则初始化密钥生成器 SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); secureRandom.setSeed("tcsl".getBytes()); //生成一个128位的随机源,根据传入的字节数组 keygen.init(128, secureRandom); //3.产生原始对称密钥 SecretKey original_key=keygen.generateKey(); //4.获得原始对称密钥的字节数组 byte [] raw=original_key.getEncoded(); //5.根据字节数组生成AES密钥 SecretKey key=new SecretKeySpec(raw, "AES"); //6.根据指定算法AES自成密码器 Cipher cipher=Cipher.getInstance("AES"); //7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作,第二个参数为使用的KEY cipher.init(Cipher.ENCRYPT_MODE, key); //组装加密必要参数并转换为字符串 Map&lt;String,Object&gt; shopinfo = new HashMap&lt;&gt;(); shopinfo.put("shopId",thirdTokenCnd.getShopId()); shopinfo.put("thirdId",thirdTokenCnd.getUserName()); JSONObject jsonObject = JSONObject.fromObject(shopinfo); String result = jsonObject.toString(); //8.获取加密内容的字节数组(这里要设置为utf-8)不然内容中如果有中文和英文混合中文就会解密为乱码 byte [] byte_encode=result.getBytes("utf-8"); //9.根据密码器的初始化方式--加密:将数据加密 byte [] byte_AES=cipher.doFinal(byte_encode); //10.将加密后的数据转换为字符串 //这里用Base64Encoder中会找不到包 //解决办法://在项目的Build path中先移除JRE System Library,再添加库JRE System Library,重新编译后就一切正常了。 String AES_encode=new String(new BASE64Encoder().encode(byte_AES)); //11.将字符串返回 return build().success(AES_encode); }catch(NoSuchAlgorithmException e) { e.printStackTrace(); }catch(NoSuchPaddingException e) { e.printStackTrace(); }catch(InvalidKeyException e) { e.printStackTrace(); }catch(IllegalBlockSizeException e) { e.printStackTrace(); }catch(BadPaddingException e) { e.printStackTrace(); }catch( UnsupportedEncodingException e) { e.printStackTrace(); }//如果有错就返加nulll return null; }</code></pre>

页面列表

ITEM_HTML